mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
update assimp lib
This commit is contained in:
parent
03a348deb7
commit
d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions
|
|
@ -3,9 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
|
||||
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -60,12 +58,7 @@ using namespace Assimp;
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
ValidateDSProcess::ValidateDSProcess() :
|
||||
mScene() {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
ValidateDSProcess::~ValidateDSProcess() = default;
|
||||
ValidateDSProcess::ValidateDSProcess() : mScene(nullptr) {}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the processing step is present in the given flag field.
|
||||
|
|
@ -80,7 +73,7 @@ AI_WONT_RETURN void ValidateDSProcess::ReportError(const char *msg, ...) {
|
|||
va_start(args, msg);
|
||||
|
||||
char szBuffer[3000];
|
||||
const int iLen = vsprintf(szBuffer, msg, args);
|
||||
const int iLen = vsnprintf(szBuffer, sizeof(szBuffer), msg, args);
|
||||
ai_assert(iLen > 0);
|
||||
|
||||
va_end(args);
|
||||
|
|
@ -95,7 +88,7 @@ void ValidateDSProcess::ReportWarning(const char *msg, ...) {
|
|||
va_start(args, msg);
|
||||
|
||||
char szBuffer[3000];
|
||||
const int iLen = vsprintf(szBuffer, msg, args);
|
||||
const int iLen = vsnprintf(szBuffer, sizeof(szBuffer), msg, args);
|
||||
ai_assert(iLen > 0);
|
||||
|
||||
va_end(args);
|
||||
|
|
@ -115,18 +108,21 @@ inline int HasNameMatch(const aiString &in, aiNode *node) {
|
|||
template <typename T>
|
||||
inline void ValidateDSProcess::DoValidation(T **parray, unsigned int size, const char *firstName, const char *secondName) {
|
||||
// validate all entries
|
||||
if (size) {
|
||||
if (!parray) {
|
||||
ReportError("aiScene::%s is nullptr (aiScene::%s is %i)",
|
||||
firstName, secondName, size);
|
||||
}
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
if (!parray[i]) {
|
||||
ReportError("aiScene::%s[%i] is nullptr (aiScene::%s is %i)",
|
||||
firstName, i, secondName, size);
|
||||
}
|
||||
Validate(parray[i]);
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parray) {
|
||||
ReportError("aiScene::%s is nullptr (aiScene::%s is %i)",
|
||||
firstName, secondName, size);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
if (!parray[i]) {
|
||||
ReportError("aiScene::%s[%i] is nullptr (aiScene::%s is %i)",
|
||||
firstName, i, secondName, size);
|
||||
}
|
||||
Validate(parray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -135,25 +131,27 @@ template <typename T>
|
|||
inline void ValidateDSProcess::DoValidationEx(T **parray, unsigned int size,
|
||||
const char *firstName, const char *secondName) {
|
||||
// validate all entries
|
||||
if (size) {
|
||||
if (!parray) {
|
||||
ReportError("aiScene::%s is nullptr (aiScene::%s is %i)",
|
||||
firstName, secondName, size);
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parray) {
|
||||
ReportError("aiScene::%s is nullptr (aiScene::%s is %i)",
|
||||
firstName, secondName, size);
|
||||
}
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
if (!parray[i]) {
|
||||
ReportError("aiScene::%s[%u] is nullptr (aiScene::%s is %u)",
|
||||
firstName, i, secondName, size);
|
||||
}
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
if (!parray[i]) {
|
||||
ReportError("aiScene::%s[%u] is nullptr (aiScene::%s is %u)",
|
||||
firstName, i, secondName, size);
|
||||
}
|
||||
Validate(parray[i]);
|
||||
Validate(parray[i]);
|
||||
|
||||
// check whether there are duplicate names
|
||||
for (unsigned int a = i + 1; a < size; ++a) {
|
||||
if (parray[i]->mName == parray[a]->mName) {
|
||||
ReportError("aiScene::%s[%u] has the same name as "
|
||||
"aiScene::%s[%u]",
|
||||
firstName, i, secondName, a);
|
||||
}
|
||||
// check whether there are duplicate names
|
||||
for (unsigned int a = i + 1; a < size; ++a) {
|
||||
if (parray[i]->mName == parray[a]->mName) {
|
||||
ReportError("aiScene::%s[%u] has the same name as "
|
||||
"aiScene::%s[%u]",
|
||||
firstName, i, secondName, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -234,12 +232,6 @@ void ValidateDSProcess::Execute(aiScene *pScene) {
|
|||
if (pScene->mNumMaterials) {
|
||||
DoValidation(pScene->mMaterials, pScene->mNumMaterials, "mMaterials", "mNumMaterials");
|
||||
}
|
||||
#if 0
|
||||
// NOTE: ScenePreprocessor generates a default material if none is there
|
||||
else if (!(mScene->mFlags & AI_SCENE_FLAGS_INCOMPLETE)) {
|
||||
ReportError("aiScene::mNumMaterials is 0. At least one material must be there");
|
||||
}
|
||||
#endif
|
||||
else if (pScene->mMaterials) {
|
||||
ReportError("aiScene::mMaterials is non-null although there are no materials");
|
||||
}
|
||||
|
|
@ -272,8 +264,7 @@ void ValidateDSProcess::Validate(const aiCamera *pCamera) {
|
|||
if (pCamera->mClipPlaneFar <= pCamera->mClipPlaneNear)
|
||||
ReportError("aiCamera::mClipPlaneFar must be >= aiCamera::mClipPlaneNear");
|
||||
|
||||
// FIX: there are many 3ds files with invalid FOVs. No reason to
|
||||
// reject them at all ... a warning is appropriate.
|
||||
// There are many 3ds files with invalid FOVs. No reason to reject them at all ... a warning is appropriate.
|
||||
if (!pCamera->mHorizontalFOV || pCamera->mHorizontalFOV >= (float)AI_MATH_PI)
|
||||
ReportWarning("%f is not a valid value for aiCamera::mHorizontalFOV", pCamera->mHorizontalFOV);
|
||||
}
|
||||
|
|
@ -295,7 +286,6 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh) {
|
|||
switch (face.mNumIndices) {
|
||||
case 0:
|
||||
ReportError("aiMesh::mFaces[%i].mNumIndices is 0", i);
|
||||
break;
|
||||
case 1:
|
||||
if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT)) {
|
||||
ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimitiveTypes "
|
||||
|
|
@ -367,15 +357,6 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh) {
|
|||
if (face.mIndices[a] >= pMesh->mNumVertices) {
|
||||
ReportError("aiMesh::mFaces[%i]::mIndices[%i] is out of range", i, a);
|
||||
}
|
||||
// the MSB flag is temporarily used by the extra verbose
|
||||
// mode to tell us that the JoinVerticesProcess might have
|
||||
// been executed already.
|
||||
/*if ( !(this->mScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT ) && !(this->mScene->mFlags & AI_SCENE_FLAGS_ALLOW_SHARED) &&
|
||||
abRefList[face.mIndices[a]])
|
||||
{
|
||||
ReportError("aiMesh::mVertices[%i] is referenced twice - second "
|
||||
"time by aiMesh::mFaces[%i]::mIndices[%i]",face.mIndices[a],i,a);
|
||||
}*/
|
||||
abRefList[face.mIndices[a]] = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -390,20 +371,7 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh) {
|
|||
ReportWarning("There are unreferenced vertices");
|
||||
}
|
||||
|
||||
// texture channel 2 may not be set if channel 1 is zero ...
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
|
||||
if (!pMesh->HasTextureCoords(i)) break;
|
||||
}
|
||||
for (; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i)
|
||||
if (pMesh->HasTextureCoords(i)) {
|
||||
ReportError("Texture coordinate channel %i exists "
|
||||
"although the previous channel was nullptr.",
|
||||
i);
|
||||
}
|
||||
}
|
||||
// the same for the vertex colors
|
||||
// vertex color channel 2 may not be set if channel 1 is zero ...
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for (; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
|
||||
|
|
@ -471,7 +439,7 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh, const aiBone *pBone, float
|
|||
this->Validate(&pBone->mName);
|
||||
|
||||
if (!pBone->mNumWeights) {
|
||||
//ReportError("aiBone::mNumWeights is zero");
|
||||
ReportWarning("aiBone::mNumWeights is zero");
|
||||
}
|
||||
|
||||
// check whether all vertices affected by this bone are valid
|
||||
|
|
@ -479,7 +447,7 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh, const aiBone *pBone, float
|
|||
if (pBone->mWeights[i].mVertexId >= pMesh->mNumVertices) {
|
||||
ReportError("aiBone::mWeights[%i].mVertexId is out of range", i);
|
||||
} else if (!pBone->mWeights[i].mWeight || pBone->mWeights[i].mWeight > 1.0f) {
|
||||
ReportWarning("aiBone::mWeights[%i].mWeight has an invalid value", i);
|
||||
ReportWarning("aiBone::mWeights[%i].mWeight has an invalid value %i. Value must be greater than zero and less than 1.", i, pBone->mWeights[i].mWeight);
|
||||
}
|
||||
afSum[pBone->mWeights[i].mVertexId] += pBone->mWeights[i].mWeight;
|
||||
}
|
||||
|
|
@ -916,16 +884,24 @@ void ValidateDSProcess::Validate(const aiNode *pNode) {
|
|||
nodeName, pNode->mNumChildren);
|
||||
}
|
||||
for (unsigned int i = 0; i < pNode->mNumChildren; ++i) {
|
||||
Validate(pNode->mChildren[i]);
|
||||
const aiNode *pChild = pNode->mChildren[i];
|
||||
Validate(pChild);
|
||||
if (pChild->mParent != pNode) {
|
||||
const char *parentName = (pChild->mParent != nullptr) ? pChild->mParent->mName.C_Str() : "null";
|
||||
ReportError("aiNode \"%s\" child %i \"%s\" parent is someone else: \"%s\"", pNode->mName.C_Str(), i, pChild->mName.C_Str(), parentName);
|
||||
}
|
||||
}
|
||||
} else if (pNode->mChildren) {
|
||||
ReportError("aiNode::mChildren is not nullptr for empty node %s (aiNode::mNumChildren is %i)",
|
||||
nodeName, pNode->mNumChildren);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void ValidateDSProcess::Validate(const aiString *pString) {
|
||||
if (pString->length > MAXLEN) {
|
||||
if (pString->length > AI_MAXLEN) {
|
||||
ReportError("aiString::length is too large (%u, maximum is %lu)",
|
||||
pString->length, MAXLEN);
|
||||
pString->length, AI_MAXLEN);
|
||||
}
|
||||
const char *sz = pString->data;
|
||||
while (true) {
|
||||
|
|
@ -934,7 +910,7 @@ void ValidateDSProcess::Validate(const aiString *pString) {
|
|||
ReportError("aiString::data is invalid: the terminal zero is at a wrong offset");
|
||||
}
|
||||
break;
|
||||
} else if (sz >= &pString->data[MAXLEN]) {
|
||||
} else if (sz >= &pString->data[AI_MAXLEN]) {
|
||||
ReportError("aiString::data is invalid. There is no terminal character");
|
||||
}
|
||||
++sz;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue