OpenClonk
material-handle.cpp File Reference
Include dependency graph for material-handle.cpp:

Go to the source code of this file.

Macros

#define MATERIAL_MAP_TO_HANDLE(material_map)   (reinterpret_cast<C4MaterialMapHandle*>(material_map))
 
#define HANDLE_TO_MATERIAL_MAP(handle)   (reinterpret_cast<C4MaterialMap*>(handle))
 
#define MATERIAL_TO_HANDLE(material)   (reinterpret_cast<C4MaterialHandle*>(material))
 
#define HANDLE_TO_MATERIAL(handle)   (reinterpret_cast<C4Material*>(handle))
 
#define HANDLE_TO_TEXTURE_MAP(handle)   (reinterpret_cast<C4TextureMap*>(handle))
 
#define GROUP_TO_HANDLE(group)   (reinterpret_cast<C4GroupHandle*>(group))
 
#define HANDLE_TO_GROUP(handle)   (reinterpret_cast<C4Group*>(handle))
 

Functions

C4MaterialMapHandlec4_material_map_handle_new (void)
 
void c4_material_map_handle_free (C4MaterialMapHandle *material_map)
 
guint c4_material_map_handle_load (C4MaterialMapHandle *material_map, C4GroupHandle *group)
 
void c4_material_map_crossmap_materials (C4MaterialMapHandle *material_map, C4TextureMapHandle *texture_map)
 
guint c4_material_map_handle_get_num (C4MaterialMapHandle *material_map)
 
C4MaterialHandlec4_material_map_handle_get_material (C4MaterialMapHandle *material_map, guint index)
 
const gchar * c4_material_handle_get_name (C4MaterialHandle *material)
 
const gchar * c4_material_handle_get_texture_overlay (C4MaterialHandle *material)
 

Macro Definition Documentation

◆ GROUP_TO_HANDLE

#define GROUP_TO_HANDLE (   group)    (reinterpret_cast<C4GroupHandle*>(group))

Definition at line 29 of file material-handle.cpp.

◆ HANDLE_TO_GROUP

#define HANDLE_TO_GROUP (   handle)    (reinterpret_cast<C4Group*>(handle))

Definition at line 30 of file material-handle.cpp.

◆ HANDLE_TO_MATERIAL

#define HANDLE_TO_MATERIAL (   handle)    (reinterpret_cast<C4Material*>(handle))

Definition at line 25 of file material-handle.cpp.

◆ HANDLE_TO_MATERIAL_MAP

#define HANDLE_TO_MATERIAL_MAP (   handle)    (reinterpret_cast<C4MaterialMap*>(handle))

Definition at line 22 of file material-handle.cpp.

◆ HANDLE_TO_TEXTURE_MAP

#define HANDLE_TO_TEXTURE_MAP (   handle)    (reinterpret_cast<C4TextureMap*>(handle))

Definition at line 27 of file material-handle.cpp.

◆ MATERIAL_MAP_TO_HANDLE

#define MATERIAL_MAP_TO_HANDLE (   material_map)    (reinterpret_cast<C4MaterialMapHandle*>(material_map))

Definition at line 21 of file material-handle.cpp.

◆ MATERIAL_TO_HANDLE

#define MATERIAL_TO_HANDLE (   material)    (reinterpret_cast<C4MaterialHandle*>(material))

Definition at line 24 of file material-handle.cpp.

Function Documentation

◆ c4_material_handle_get_name()

const gchar* c4_material_handle_get_name ( C4MaterialHandle material)

Definition at line 85 of file material-handle.cpp.

86 {
87  return HANDLE_TO_MATERIAL(material)->Name;
88 }
#define HANDLE_TO_MATERIAL(handle)

References HANDLE_TO_MATERIAL.

Referenced by mape_material_get_name(), and mape_material_map_get_material_by_name().

Here is the caller graph for this function:

◆ c4_material_handle_get_texture_overlay()

const gchar* c4_material_handle_get_texture_overlay ( C4MaterialHandle material)

Definition at line 89 of file material-handle.cpp.

90 {
91  return HANDLE_TO_MATERIAL(material)->sTextureOverlay.getData();
92 }

References HANDLE_TO_MATERIAL.

Referenced by mape_material_get_texture_overlay().

Here is the caller graph for this function:

◆ c4_material_map_crossmap_materials()

void c4_material_map_crossmap_materials ( C4MaterialMapHandle material_map,
C4TextureMapHandle texture_map 
)

Definition at line 55 of file material-handle.cpp.

56 {
57  // Don't call the official crossmap function since it tries to load some surfaces.
58  // All we need is the default texture.
59  for(int i = 0; i < HANDLE_TO_MATERIAL_MAP(material_map)->Num; ++i)
60  {
61  C4Material* mat = &HANDLE_TO_MATERIAL_MAP(material_map)->Map[i];
62  const char* overlay = mat->sTextureOverlay.getData();
63  if(!overlay || *overlay == '\0')
64  {
65  int first_tex_map_entry = HANDLE_TO_TEXTURE_MAP(texture_map)->GetIndex(mat->Name, nullptr, false);
66  overlay = HANDLE_TO_TEXTURE_MAP(texture_map)->GetEntry(first_tex_map_entry)->GetTextureName();
67  }
68 
69  if(overlay)
70  mat->DefaultMatTex = HANDLE_TO_TEXTURE_MAP(texture_map)->GetIndex(mat->Name, overlay, true);
71  }
72 }
char Name[C4M_MaxName+1]
Definition: C4Material.h:89
StdCopyStrBuf sTextureOverlay
Definition: C4Material.h:114
int32_t DefaultMatTex
Definition: C4Material.h:155
const char * getData() const
Definition: StdBuf.h:442
#define HANDLE_TO_MATERIAL_MAP(handle)
#define HANDLE_TO_TEXTURE_MAP(handle)

References C4Material::DefaultMatTex, StdStrBuf::getData(), HANDLE_TO_MATERIAL_MAP, HANDLE_TO_TEXTURE_MAP, C4MaterialCore::Name, and C4MaterialCore::sTextureOverlay.

Referenced by mape_material_map_set_default_textures().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ c4_material_map_handle_free()

void c4_material_map_handle_free ( C4MaterialMapHandle material_map)

Definition at line 45 of file material-handle.cpp.

46 {
47  //delete HANDLE_TO_MATERIAL_MAP(material_map);
48 }

◆ c4_material_map_handle_get_material()

C4MaterialHandle* c4_material_map_handle_get_material ( C4MaterialMapHandle material_map,
guint  index 
)

Definition at line 79 of file material-handle.cpp.

80 {
81  g_assert(index < (guint)(HANDLE_TO_MATERIAL_MAP(material_map)->Num));
82  return MATERIAL_TO_HANDLE(&HANDLE_TO_MATERIAL_MAP(material_map)->Map[index]);
83 }
#define MATERIAL_TO_HANDLE(material)

References HANDLE_TO_MATERIAL_MAP, and MATERIAL_TO_HANDLE.

Referenced by mape_material_map_get_material_by_name().

Here is the caller graph for this function:

◆ c4_material_map_handle_get_num()

guint c4_material_map_handle_get_num ( C4MaterialMapHandle material_map)

Definition at line 74 of file material-handle.cpp.

75 {
76  return HANDLE_TO_MATERIAL_MAP(material_map)->Num;
77 }

References HANDLE_TO_MATERIAL_MAP.

Referenced by mape_material_map_get_material(), mape_material_map_get_material_by_name(), and mape_material_map_get_material_count().

Here is the caller graph for this function:

◆ c4_material_map_handle_load()

guint c4_material_map_handle_load ( C4MaterialMapHandle material_map,
C4GroupHandle group 
)

Definition at line 50 of file material-handle.cpp.

51 {
52  return HANDLE_TO_MATERIAL_MAP(material_map)->Load(*HANDLE_TO_GROUP(group));
53 }
#define HANDLE_TO_GROUP(handle)

References HANDLE_TO_GROUP, and HANDLE_TO_MATERIAL_MAP.

Referenced by mape_material_map_load().

Here is the caller graph for this function:

◆ c4_material_map_handle_new()

C4MaterialMapHandle* c4_material_map_handle_new ( void  )

Definition at line 34 of file material-handle.cpp.

35 {
36  // Simply return a pointer to the global material map. This is a bit stupid,
37  // but when looking up a material-texture combination, C4TextureMap uses the
38  // global material map for the material lookup when the default texture is
39  // requested. This should be changed to get rid of the global variable, but yeah...
41  map->Clear();
42  return MATERIAL_MAP_TO_HANDLE(map); //new C4MaterialMap);
43 }
C4MaterialMap MaterialMap
Definition: C4Material.cpp:974
#define MATERIAL_MAP_TO_HANDLE(material_map)

References C4MaterialMap::Clear(), MATERIAL_MAP_TO_HANDLE, and MaterialMap.

Here is the call graph for this function: