# TextureTransform-Step: fix memory leak due to uvtrafo keys not being deleted properly. This fixes [3463286].
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1104 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/4/merge
parent
afd462045d
commit
aa189c0247
|
@ -241,52 +241,53 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||||
update.index = prop->mIndex;
|
update.index = prop->mIndex;
|
||||||
|
|
||||||
// Get textured properties and transform
|
// Get textured properties and transform
|
||||||
for (unsigned int a2 = 0; a2 < mat->mNumProperties;++a2)
|
for (unsigned int a2 = 0; a2 < mat->mNumProperties;++a2) {
|
||||||
{
|
|
||||||
aiMaterialProperty* prop2 = mat->mProperties[a2];
|
aiMaterialProperty* prop2 = mat->mProperties[a2];
|
||||||
if (prop2->mSemantic != prop->mSemantic || prop2->mIndex != prop->mIndex)
|
if (prop2->mSemantic != prop->mSemantic || prop2->mIndex != prop->mIndex) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !::strcmp( prop2->mKey.data, "$tex.uvwsrc"))
|
if ( !::strcmp( prop2->mKey.data, "$tex.uvwsrc")) {
|
||||||
{
|
|
||||||
info.uvIndex = *((int*)prop2->mData);
|
info.uvIndex = *((int*)prop2->mData);
|
||||||
|
|
||||||
// Store a direct pointer for later use
|
// Store a direct pointer for later use
|
||||||
update.directShortcut = (unsigned int*) prop2->mData;
|
update.directShortcut = (unsigned int*) prop2->mData;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( !::strcmp( prop2->mKey.data, "$tex.mapmodeu"))
|
else if ( !::strcmp( prop2->mKey.data, "$tex.mapmodeu")) {
|
||||||
info.mapU = *((aiTextureMapMode*)prop2->mData);
|
info.mapU = *((aiTextureMapMode*)prop2->mData);
|
||||||
|
}
|
||||||
else if ( !::strcmp( prop2->mKey.data, "$tex.mapmodev"))
|
else if ( !::strcmp( prop2->mKey.data, "$tex.mapmodev")) {
|
||||||
info.mapV = *((aiTextureMapMode*)prop2->mData);
|
info.mapV = *((aiTextureMapMode*)prop2->mData);
|
||||||
|
}
|
||||||
else if ( !::strcmp( prop2->mKey.data, "$tex.uvtrafo"))
|
else if ( !::strcmp( prop2->mKey.data, "$tex.uvtrafo")) {
|
||||||
{
|
|
||||||
// ValidateDS should check this
|
// ValidateDS should check this
|
||||||
ai_assert(prop2->mDataLength >= 20);
|
ai_assert(prop2->mDataLength >= 20);
|
||||||
::memcpy(&info.mTranslation.x,prop2->mData,sizeof(float)*5);
|
::memcpy(&info.mTranslation.x,prop2->mData,sizeof(float)*5);
|
||||||
delete[] prop2->mData;
|
|
||||||
|
|
||||||
// Directly remove this property from the list
|
// Directly remove this property from the list
|
||||||
mat->mNumProperties--;
|
mat->mNumProperties--;
|
||||||
for (unsigned int a3 = a2; a3 < mat->mNumProperties;++a3)
|
for (unsigned int a3 = a2; a3 < mat->mNumProperties;++a3) {
|
||||||
mat->mProperties[a3] = mat->mProperties[a3+1];
|
mat->mProperties[a3] = mat->mProperties[a3+1];
|
||||||
|
}
|
||||||
|
|
||||||
// Warn: could be an underflow, but nevertheless it should work
|
delete prop2;
|
||||||
|
|
||||||
|
// Warn: could be an underflow, but this does not invoke undefined behaviour
|
||||||
--a2;
|
--a2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out which transformations are to be evaluated
|
// Find out which transformations are to be evaluated
|
||||||
if (!(configFlags & AI_UVTRAFO_ROTATION))
|
if (!(configFlags & AI_UVTRAFO_ROTATION)) {
|
||||||
info.mRotation = 0.f;
|
info.mRotation = 0.f;
|
||||||
|
}
|
||||||
if (!(configFlags & AI_UVTRAFO_SCALING))
|
if (!(configFlags & AI_UVTRAFO_SCALING)) {
|
||||||
info.mScaling = aiVector2D(1.f,1.f);
|
info.mScaling = aiVector2D(1.f,1.f);
|
||||||
|
}
|
||||||
if (!(configFlags & AI_UVTRAFO_TRANSLATION))
|
if (!(configFlags & AI_UVTRAFO_TRANSLATION)) {
|
||||||
info.mTranslation = aiVector2D(0.f,0.f);
|
info.mTranslation = aiVector2D(0.f,0.f);
|
||||||
|
}
|
||||||
|
|
||||||
// Do some preprocessing
|
// Do some preprocessing
|
||||||
PreProcessUVTransform(info);
|
PreProcessUVTransform(info);
|
||||||
|
|
Loading…
Reference in New Issue