------------------------------------------------------------------------------------------------ Get a specific property from a material
| 57 | // ------------------------------------------------------------------------------------------------ |
| 58 | // Get a specific property from a material |
| 59 | aiReturn 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 | |
| 87 | namespace { |
| 88 |
no outgoing calls
no test coverage detected