Merge pull request #2189 from gongminmin/FixTwoSided

Fix the wrong results when calling aiGetMaterialInteger on bool type properties, such as AI_MATKEY_TWOSIDED
pull/2197/head
Kim Kulling 2018-10-22 21:48:07 +02:00 committed by GitHub
commit 19844d0cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -194,12 +194,18 @@ aiReturn aiGetMaterialIntegerArray(const aiMaterial* pMat,
// data is given in ints, simply copy it
unsigned int iWrite = 0;
if( aiPTI_Integer == prop->mType || aiPTI_Buffer == prop->mType) {
iWrite = prop->mDataLength / sizeof(int32_t);
iWrite = std::max(static_cast<unsigned int>(prop->mDataLength / sizeof(int32_t)), 1u);
if (pMax) {
iWrite = std::min(*pMax,iWrite); ;
iWrite = std::min(*pMax,iWrite);
}
for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<int>(reinterpret_cast<int32_t*>(prop->mData)[a]);
if (1 == prop->mDataLength) {
// bool type, 1 byte
*pOut = static_cast<int>(*prop->mData);
}
else {
for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<int>(reinterpret_cast<int32_t*>(prop->mData)[a]);
}
}
if (pMax) {
*pMax = iWrite;