Refactor: Expand tabs to 4 spaces
This commit is contained in:
@@ -68,7 +68,7 @@ RemoveVCProcess::~RemoveVCProcess()
|
||||
// Returns whether the processing step is present in the given flag field.
|
||||
bool RemoveVCProcess::IsActive( unsigned int pFlags) const
|
||||
{
|
||||
return (pFlags & aiProcess_RemoveComponent) != 0;
|
||||
return (pFlags & aiProcess_RemoveComponent) != 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -76,12 +76,12 @@ bool RemoveVCProcess::IsActive( unsigned int pFlags) const
|
||||
template <typename T>
|
||||
inline void ArrayDelete(T**& in, unsigned int& num)
|
||||
{
|
||||
for (unsigned int i = 0; i < num; ++i)
|
||||
delete in[i];
|
||||
for (unsigned int i = 0; i < num; ++i)
|
||||
delete in[i];
|
||||
|
||||
delete[] in;
|
||||
in = NULL;
|
||||
num = 0;
|
||||
delete[] in;
|
||||
in = NULL;
|
||||
num = 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -90,54 +90,54 @@ inline void ArrayDelete(T**& in, unsigned int& num)
|
||||
// "don't remove" flag not set. Nodes with meshes are never deleted.
|
||||
bool UpdateNodeGraph(aiNode* node,std::list<aiNode*>& childsOfParent,bool root)
|
||||
{
|
||||
bool b = false;
|
||||
bool b = false;
|
||||
|
||||
std::list<aiNode*> mine;
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
{
|
||||
if(UpdateNodeGraph(node->mChildren[i],mine,false))
|
||||
b = true;
|
||||
}
|
||||
std::list<aiNode*> mine;
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
{
|
||||
if(UpdateNodeGraph(node->mChildren[i],mine,false))
|
||||
b = true;
|
||||
}
|
||||
|
||||
// somewhat tricky ... mNumMeshes must be originally 0 and MSB2 may not be set,
|
||||
// so we can do a simple comparison against MSB here
|
||||
if (!root && AI_RC_UINT_MSB == node->mNumMeshes )
|
||||
{
|
||||
// this node needs to be removed
|
||||
if(node->mNumChildren)
|
||||
{
|
||||
childsOfParent.insert(childsOfParent.end(),mine.begin(),mine.end());
|
||||
// somewhat tricky ... mNumMeshes must be originally 0 and MSB2 may not be set,
|
||||
// so we can do a simple comparison against MSB here
|
||||
if (!root && AI_RC_UINT_MSB == node->mNumMeshes )
|
||||
{
|
||||
// this node needs to be removed
|
||||
if(node->mNumChildren)
|
||||
{
|
||||
childsOfParent.insert(childsOfParent.end(),mine.begin(),mine.end());
|
||||
|
||||
// set all children to NULL to make sure they are not deleted when we delete ourself
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
node->mChildren[i] = NULL;
|
||||
}
|
||||
b = true;
|
||||
delete node;
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_RC_UNMASK(node->mNumMeshes);
|
||||
childsOfParent.push_back(node);
|
||||
// set all children to NULL to make sure they are not deleted when we delete ourself
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
node->mChildren[i] = NULL;
|
||||
}
|
||||
b = true;
|
||||
delete node;
|
||||
}
|
||||
else
|
||||
{
|
||||
AI_RC_UNMASK(node->mNumMeshes);
|
||||
childsOfParent.push_back(node);
|
||||
|
||||
if (b)
|
||||
{
|
||||
// reallocate the array of our children here
|
||||
node->mNumChildren = (unsigned int)mine.size();
|
||||
aiNode** const children = new aiNode*[mine.size()];
|
||||
aiNode** ptr = children;
|
||||
if (b)
|
||||
{
|
||||
// reallocate the array of our children here
|
||||
node->mNumChildren = (unsigned int)mine.size();
|
||||
aiNode** const children = new aiNode*[mine.size()];
|
||||
aiNode** ptr = children;
|
||||
|
||||
for (std::list<aiNode*>::iterator it = mine.begin(), end = mine.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
*ptr++ = *it;
|
||||
}
|
||||
delete[] node->mChildren;
|
||||
node->mChildren = children;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
for (std::list<aiNode*>::iterator it = mine.begin(), end = mine.end();
|
||||
it != end; ++it)
|
||||
{
|
||||
*ptr++ = *it;
|
||||
}
|
||||
delete[] node->mChildren;
|
||||
node->mChildren = children;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -145,190 +145,190 @@ bool UpdateNodeGraph(aiNode* node,std::list<aiNode*>& childsOfParent,bool root)
|
||||
// Executes the post processing step on the given imported data.
|
||||
void RemoveVCProcess::Execute( aiScene* pScene)
|
||||
{
|
||||
DefaultLogger::get()->debug("RemoveVCProcess begin");
|
||||
bool bHas = false; //,bMasked = false;
|
||||
DefaultLogger::get()->debug("RemoveVCProcess begin");
|
||||
bool bHas = false; //,bMasked = false;
|
||||
|
||||
mScene = pScene;
|
||||
mScene = pScene;
|
||||
|
||||
// handle animations
|
||||
if ( configDeleteFlags & aiComponent_ANIMATIONS)
|
||||
{
|
||||
// handle animations
|
||||
if ( configDeleteFlags & aiComponent_ANIMATIONS)
|
||||
{
|
||||
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mAnimations,pScene->mNumAnimations);
|
||||
}
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mAnimations,pScene->mNumAnimations);
|
||||
}
|
||||
|
||||
// handle textures
|
||||
if ( configDeleteFlags & aiComponent_TEXTURES)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mTextures,pScene->mNumTextures);
|
||||
}
|
||||
// handle textures
|
||||
if ( configDeleteFlags & aiComponent_TEXTURES)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mTextures,pScene->mNumTextures);
|
||||
}
|
||||
|
||||
// handle materials
|
||||
if ( configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials)
|
||||
{
|
||||
bHas = true;
|
||||
for (unsigned int i = 1;i < pScene->mNumMaterials;++i)
|
||||
delete pScene->mMaterials[i];
|
||||
// handle materials
|
||||
if ( configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials)
|
||||
{
|
||||
bHas = true;
|
||||
for (unsigned int i = 1;i < pScene->mNumMaterials;++i)
|
||||
delete pScene->mMaterials[i];
|
||||
|
||||
pScene->mNumMaterials = 1;
|
||||
aiMaterial* helper = (aiMaterial*) pScene->mMaterials[0];
|
||||
ai_assert(NULL != helper);
|
||||
helper->Clear();
|
||||
pScene->mNumMaterials = 1;
|
||||
aiMaterial* helper = (aiMaterial*) pScene->mMaterials[0];
|
||||
ai_assert(NULL != helper);
|
||||
helper->Clear();
|
||||
|
||||
// gray
|
||||
aiColor3D clr(0.6f,0.6f,0.6f);
|
||||
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||
// gray
|
||||
aiColor3D clr(0.6f,0.6f,0.6f);
|
||||
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||
|
||||
// add a small ambient color value
|
||||
clr = aiColor3D(0.05f,0.05f,0.05f);
|
||||
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_AMBIENT);
|
||||
// add a small ambient color value
|
||||
clr = aiColor3D(0.05f,0.05f,0.05f);
|
||||
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_AMBIENT);
|
||||
|
||||
aiString s;
|
||||
s.Set("Dummy_MaterialsRemoved");
|
||||
helper->AddProperty(&s,AI_MATKEY_NAME);
|
||||
}
|
||||
aiString s;
|
||||
s.Set("Dummy_MaterialsRemoved");
|
||||
helper->AddProperty(&s,AI_MATKEY_NAME);
|
||||
}
|
||||
|
||||
// handle light sources
|
||||
if ( configDeleteFlags & aiComponent_LIGHTS)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mLights,pScene->mNumLights);
|
||||
}
|
||||
// handle light sources
|
||||
if ( configDeleteFlags & aiComponent_LIGHTS)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mLights,pScene->mNumLights);
|
||||
}
|
||||
|
||||
// handle camneras
|
||||
if ( configDeleteFlags & aiComponent_CAMERAS)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mCameras,pScene->mNumCameras);
|
||||
}
|
||||
// handle camneras
|
||||
if ( configDeleteFlags & aiComponent_CAMERAS)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mCameras,pScene->mNumCameras);
|
||||
}
|
||||
|
||||
// handle meshes
|
||||
if (configDeleteFlags & aiComponent_MESHES)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mMeshes,pScene->mNumMeshes);
|
||||
}
|
||||
else
|
||||
{
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||
{
|
||||
if( ProcessMesh( pScene->mMeshes[a]))
|
||||
bHas = true;
|
||||
}
|
||||
}
|
||||
// handle meshes
|
||||
if (configDeleteFlags & aiComponent_MESHES)
|
||||
{
|
||||
bHas = true;
|
||||
ArrayDelete(pScene->mMeshes,pScene->mNumMeshes);
|
||||
}
|
||||
else
|
||||
{
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||
{
|
||||
if( ProcessMesh( pScene->mMeshes[a]))
|
||||
bHas = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now check whether the result is still a full scene
|
||||
if (!pScene->mNumMeshes || !pScene->mNumMaterials)
|
||||
{
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||
DefaultLogger::get()->debug("Setting AI_SCENE_FLAGS_INCOMPLETE flag");
|
||||
// now check whether the result is still a full scene
|
||||
if (!pScene->mNumMeshes || !pScene->mNumMaterials)
|
||||
{
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
|
||||
DefaultLogger::get()->debug("Setting AI_SCENE_FLAGS_INCOMPLETE flag");
|
||||
|
||||
// If we have no meshes anymore we should also clear another flag ...
|
||||
if (!pScene->mNumMeshes)
|
||||
pScene->mFlags &= ~AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
|
||||
}
|
||||
// If we have no meshes anymore we should also clear another flag ...
|
||||
if (!pScene->mNumMeshes)
|
||||
pScene->mFlags &= ~AI_SCENE_FLAGS_NON_VERBOSE_FORMAT;
|
||||
}
|
||||
|
||||
if (bHas)DefaultLogger::get()->info("RemoveVCProcess finished. Data structure cleanup has been done.");
|
||||
else DefaultLogger::get()->debug("RemoveVCProcess finished. Nothing to be done ...");
|
||||
if (bHas)DefaultLogger::get()->info("RemoveVCProcess finished. Data structure cleanup has been done.");
|
||||
else DefaultLogger::get()->debug("RemoveVCProcess finished. Nothing to be done ...");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Setup configuration properties for the step
|
||||
void RemoveVCProcess::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0);
|
||||
if (!configDeleteFlags)
|
||||
{
|
||||
DefaultLogger::get()->warn("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero.");
|
||||
}
|
||||
configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0);
|
||||
if (!configDeleteFlags)
|
||||
{
|
||||
DefaultLogger::get()->warn("RemoveVCProcess: AI_CONFIG_PP_RVC_FLAGS is zero.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
|
||||
{
|
||||
bool ret = false;
|
||||
bool ret = false;
|
||||
|
||||
// if all materials have been deleted let the material
|
||||
// index of the mesh point to the created default material
|
||||
if ( configDeleteFlags & aiComponent_MATERIALS)
|
||||
pMesh->mMaterialIndex = 0;
|
||||
// if all materials have been deleted let the material
|
||||
// index of the mesh point to the created default material
|
||||
if ( configDeleteFlags & aiComponent_MATERIALS)
|
||||
pMesh->mMaterialIndex = 0;
|
||||
|
||||
// handle normals
|
||||
if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals)
|
||||
{
|
||||
delete[] pMesh->mNormals;
|
||||
pMesh->mNormals = NULL;
|
||||
ret = true;
|
||||
}
|
||||
// handle normals
|
||||
if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals)
|
||||
{
|
||||
delete[] pMesh->mNormals;
|
||||
pMesh->mNormals = NULL;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// handle tangents and bitangents
|
||||
if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents)
|
||||
{
|
||||
delete[] pMesh->mTangents;
|
||||
pMesh->mTangents = NULL;
|
||||
// handle tangents and bitangents
|
||||
if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents)
|
||||
{
|
||||
delete[] pMesh->mTangents;
|
||||
pMesh->mTangents = NULL;
|
||||
|
||||
delete[] pMesh->mBitangents;
|
||||
pMesh->mBitangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
delete[] pMesh->mBitangents;
|
||||
pMesh->mBitangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// handle texture coordinates
|
||||
bool b = (0 != (configDeleteFlags & aiComponent_TEXCOORDS));
|
||||
for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++real)
|
||||
{
|
||||
if (!pMesh->mTextureCoords[i])break;
|
||||
if (configDeleteFlags & aiComponent_TEXCOORDSn(real) || b)
|
||||
{
|
||||
delete pMesh->mTextureCoords[i];
|
||||
pMesh->mTextureCoords[i] = NULL;
|
||||
ret = true;
|
||||
// handle texture coordinates
|
||||
bool b = (0 != (configDeleteFlags & aiComponent_TEXCOORDS));
|
||||
for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++real)
|
||||
{
|
||||
if (!pMesh->mTextureCoords[i])break;
|
||||
if (configDeleteFlags & aiComponent_TEXCOORDSn(real) || b)
|
||||
{
|
||||
delete pMesh->mTextureCoords[i];
|
||||
pMesh->mTextureCoords[i] = NULL;
|
||||
ret = true;
|
||||
|
||||
if (!b)
|
||||
{
|
||||
// collapse the rest of the array
|
||||
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
|
||||
pMesh->mTextureCoords[a-1] = pMesh->mTextureCoords[a];
|
||||
if (!b)
|
||||
{
|
||||
// collapse the rest of the array
|
||||
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a)
|
||||
pMesh->mTextureCoords[a-1] = pMesh->mTextureCoords[a];
|
||||
|
||||
pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS-1] = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS-1] = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
// handle vertex colors
|
||||
b = (0 != (configDeleteFlags & aiComponent_COLORS));
|
||||
for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_COLOR_SETS; ++real)
|
||||
{
|
||||
if (!pMesh->mColors[i])break;
|
||||
if (configDeleteFlags & aiComponent_COLORSn(i) || b)
|
||||
{
|
||||
delete pMesh->mColors[i];
|
||||
pMesh->mColors[i] = NULL;
|
||||
ret = true;
|
||||
// handle vertex colors
|
||||
b = (0 != (configDeleteFlags & aiComponent_COLORS));
|
||||
for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_COLOR_SETS; ++real)
|
||||
{
|
||||
if (!pMesh->mColors[i])break;
|
||||
if (configDeleteFlags & aiComponent_COLORSn(i) || b)
|
||||
{
|
||||
delete pMesh->mColors[i];
|
||||
pMesh->mColors[i] = NULL;
|
||||
ret = true;
|
||||
|
||||
if (!b)
|
||||
{
|
||||
// collapse the rest of the array
|
||||
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a)
|
||||
pMesh->mColors[a-1] = pMesh->mColors[a];
|
||||
if (!b)
|
||||
{
|
||||
// collapse the rest of the array
|
||||
for (unsigned int a = i+1; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a)
|
||||
pMesh->mColors[a-1] = pMesh->mColors[a];
|
||||
|
||||
pMesh->mColors[AI_MAX_NUMBER_OF_COLOR_SETS-1] = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
pMesh->mColors[AI_MAX_NUMBER_OF_COLOR_SETS-1] = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
||||
// handle bones
|
||||
if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones)
|
||||
{
|
||||
ArrayDelete(pMesh->mBones,pMesh->mNumBones);
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
// handle bones
|
||||
if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones)
|
||||
{
|
||||
ArrayDelete(pMesh->mBones,pMesh->mNumBones);
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user