update assimp to 5.2.3 Bugfix-Release

This commit is contained in:
AzaezelX 2022-04-26 11:56:24 -05:00
parent 3f796d2a06
commit f297476092
1150 changed files with 165834 additions and 112019 deletions

View file

@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2019, assimp team
Copyright (c) 2006-2022, assimp team
@ -44,43 +44,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* any parts of the mesh structure from the imported data.
*/
#include "RemoveVCProcess.h"
#include <assimp/postprocess.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h>
#include <assimp/DefaultLogger.hpp>
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
RemoveVCProcess::RemoveVCProcess() :
configDeleteFlags()
, mScene()
{}
configDeleteFlags(), mScene() {}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
RemoveVCProcess::~RemoveVCProcess()
{}
RemoveVCProcess::~RemoveVCProcess() {}
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool RemoveVCProcess::IsActive( unsigned int pFlags) const
{
bool RemoveVCProcess::IsActive(unsigned int pFlags) const {
return (pFlags & aiProcess_RemoveComponent) != 0;
}
// ------------------------------------------------------------------------------------------------
// Small helper function to delete all elements in a T** aray using delete
// Small helper function to delete all elements in a T** array using delete
template <typename T>
inline void ArrayDelete(T**& in, unsigned int& num)
{
inline void ArrayDelete(T **&in, unsigned int &num) {
for (unsigned int i = 0; i < num; ++i)
delete in[i];
delete[] in;
in = NULL;
in = nullptr;
num = 0;
}
@ -108,9 +102,9 @@ bool UpdateNodeGraph(aiNode* node,std::list<aiNode*>& childsOfParent,bool root)
{
childsOfParent.insert(childsOfParent.end(),mine.begin(),mine.end());
// set all children to NULL to make sure they are not deleted when we delete ourself
// set all children to nullptr to make sure they are not deleted when we delete ourself
for (unsigned int i = 0; i < node->mNumChildren;++i)
node->mChildren[i] = NULL;
node->mChildren[i] = nullptr;
}
b = true;
delete node;
@ -143,86 +137,74 @@ 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)
{
void RemoveVCProcess::Execute(aiScene *pScene) {
ASSIMP_LOG_DEBUG("RemoveVCProcess begin");
bool bHas = false; //,bMasked = false;
mScene = pScene;
// handle animations
if ( configDeleteFlags & aiComponent_ANIMATIONS)
{
if (configDeleteFlags & aiComponent_ANIMATIONS) {
bHas = true;
ArrayDelete(pScene->mAnimations,pScene->mNumAnimations);
ArrayDelete(pScene->mAnimations, pScene->mNumAnimations);
}
// handle textures
if ( configDeleteFlags & aiComponent_TEXTURES)
{
if (configDeleteFlags & aiComponent_TEXTURES) {
bHas = true;
ArrayDelete(pScene->mTextures,pScene->mNumTextures);
ArrayDelete(pScene->mTextures, pScene->mNumTextures);
}
// handle materials
if ( configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials)
{
if (configDeleteFlags & aiComponent_MATERIALS && pScene->mNumMaterials) {
bHas = true;
for (unsigned int i = 1;i < pScene->mNumMaterials;++i)
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);
aiMaterial *helper = (aiMaterial *)pScene->mMaterials[0];
ai_assert(nullptr != helper);
helper->Clear();
// gray
aiColor3D clr(0.6f,0.6f,0.6f);
helper->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE);
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);
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);
helper->AddProperty(&s, AI_MATKEY_NAME);
}
// handle light sources
if ( configDeleteFlags & aiComponent_LIGHTS)
{
bHas = true;
ArrayDelete(pScene->mLights,pScene->mNumLights);
if (configDeleteFlags & aiComponent_LIGHTS) {
bHas = true;
ArrayDelete(pScene->mLights, pScene->mNumLights);
}
// handle camneras
if ( configDeleteFlags & aiComponent_CAMERAS)
{
if (configDeleteFlags & aiComponent_CAMERAS) {
bHas = true;
ArrayDelete(pScene->mCameras,pScene->mNumCameras);
ArrayDelete(pScene->mCameras, pScene->mNumCameras);
}
// handle meshes
if (configDeleteFlags & aiComponent_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]))
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)
{
if (!pScene->mNumMeshes || !pScene->mNumMaterials) {
pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
ASSIMP_LOG_DEBUG("Setting AI_SCENE_FLAGS_INCOMPLETE flag");
@ -240,63 +222,55 @@ void RemoveVCProcess::Execute( aiScene* pScene)
// ------------------------------------------------------------------------------------------------
// Setup configuration properties for the step
void RemoveVCProcess::SetupProperties(const Importer* pImp)
{
configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,0x0);
if (!configDeleteFlags)
{
void RemoveVCProcess::SetupProperties(const Importer *pImp) {
configDeleteFlags = pImp->GetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, 0x0);
if (!configDeleteFlags) {
ASSIMP_LOG_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 RemoveVCProcess::ProcessMesh(aiMesh *pMesh) {
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)
if (configDeleteFlags & aiComponent_MATERIALS)
pMesh->mMaterialIndex = 0;
// handle normals
if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals)
{
if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals) {
delete[] pMesh->mNormals;
pMesh->mNormals = NULL;
pMesh->mNormals = nullptr;
ret = true;
}
// handle tangents and bitangents
if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents)
{
if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents) {
delete[] pMesh->mTangents;
pMesh->mTangents = NULL;
pMesh->mTangents = nullptr;
delete[] pMesh->mBitangents;
pMesh->mBitangents = NULL;
pMesh->mBitangents = nullptr;
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;
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] = nullptr;
ret = true;
if (!b)
{
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];
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;
pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS - 1] = nullptr;
continue;
}
}
@ -305,22 +279,19 @@ bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
// 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;
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] = nullptr;
ret = true;
if (!b)
{
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];
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;
pMesh->mColors[AI_MAX_NUMBER_OF_COLOR_SETS - 1] = nullptr;
continue;
}
}
@ -328,9 +299,8 @@ bool RemoveVCProcess::ProcessMesh(aiMesh* pMesh)
}
// handle bones
if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones)
{
ArrayDelete(pMesh->mBones,pMesh->mNumBones);
if (configDeleteFlags & aiComponent_BONEWEIGHTS && pMesh->mBones) {
ArrayDelete(pMesh->mBones, pMesh->mNumBones);
ret = true;
}
return ret;