MCPcopy Create free account
hub / github.com/assimp/assimp / aiGetMaterialProperty

Function aiGetMaterialProperty

code/Material/MaterialSystem.cpp:59–85  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Get a specific property from a material

Source from the content-addressed store, hash-verified

57// ------------------------------------------------------------------------------------------------
58// Get a specific property from a material
59aiReturn aiGetMaterialProperty(const aiMaterial *pMat,
60 const char *pKey,
61 unsigned int type,
62 unsigned int index,
63 const aiMaterialProperty **pPropOut) {
64 ai_assert(pMat != nullptr);
65 ai_assert(pKey != nullptr);
66 ai_assert(pPropOut != nullptr);
67
68 /* Just search for a property with exactly this name ..
69 * could be improved by hashing, but it's possibly
70 * no worth the effort (we're bound to C structures,
71 * thus std::map or derivates are not applicable. */
72 for (unsigned int i = 0; i < pMat->mNumProperties; ++i) {
73 aiMaterialProperty *prop = pMat->mProperties[i];
74
75 if (prop /* just for safety ... */
76 && 0 == strncmp(prop->mKey.data, pKey, strlen(pKey)) && (UINT_MAX == type || prop->mSemantic == type) /* UINT_MAX is a wild-card, but this is undocumented :-) */
77 && (UINT_MAX == index || prop->mIndex == index)) {
78 *pPropOut = pMat->mProperties[i];
79 return AI_SUCCESS;
80 }
81 }
82 *pPropOut = nullptr;
83
84 return AI_FAILURE;
85}
86
87namespace {
88

Callers 4

MergeMaterialsMethod · 0.85
GetMaterialFloatArrayFunction · 0.85
aiGetMaterialStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected