Updated assimp to latest

This commit is contained in:
Areloch 2019-03-05 14:39:38 -06:00
parent 25ce4477ce
commit 161bf7f83b
461 changed files with 34662 additions and 30165 deletions

View file

@ -3,7 +3,8 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2017, assimp team
Copyright (c) 2006-2019, assimp team
All rights reserved.
@ -50,46 +51,44 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// internal headers
#include "FindInvalidDataProcess.h"
#include "ProcessHelper.h"
#include "Macros.h"
#include "Exceptional.h"
#include "qnan.h"
#include <assimp/Macros.h>
#include <assimp/Exceptional.h>
#include <assimp/qnan.h>
using namespace Assimp;
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
FindInvalidDataProcess::FindInvalidDataProcess()
: configEpsilon(0.0)
{
: configEpsilon(0.0)
, mIgnoreTexCoods( false ){
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
FindInvalidDataProcess::~FindInvalidDataProcess()
{
FindInvalidDataProcess::~FindInvalidDataProcess() {
// nothing to do here
}
// ------------------------------------------------------------------------------------------------
// Returns whether the processing step is present in the given flag field.
bool FindInvalidDataProcess::IsActive( unsigned int pFlags) const
{
bool FindInvalidDataProcess::IsActive( unsigned int pFlags) const {
return 0 != (pFlags & aiProcess_FindInvalidData);
}
// ------------------------------------------------------------------------------------------------
// Setup import configuration
void FindInvalidDataProcess::SetupProperties(const Importer* pImp)
{
void FindInvalidDataProcess::SetupProperties(const Importer* pImp) {
// Get the current value of AI_CONFIG_PP_FID_ANIM_ACCURACY
configEpsilon = (0 != pImp->GetPropertyFloat(AI_CONFIG_PP_FID_ANIM_ACCURACY,0.f));
mIgnoreTexCoods = pImp->GetPropertyBool(AI_CONFIG_PP_FID_IGNORE_TEXTURECOORDS, false);
}
// ------------------------------------------------------------------------------------------------
// Update mesh references in the node graph
void UpdateMeshReferences(aiNode* node, const std::vector<unsigned int>& meshMapping)
{
void UpdateMeshReferences(aiNode* node, const std::vector<unsigned int>& meshMapping) {
if (node->mNumMeshes) {
unsigned int out = 0;
for (unsigned int a = 0; a < node->mNumMeshes;++a) {
@ -115,9 +114,8 @@ void UpdateMeshReferences(aiNode* node, const std::vector<unsigned int>& meshMap
// ------------------------------------------------------------------------------------------------
// Executes the post processing step on the given imported data.
void FindInvalidDataProcess::Execute( aiScene* pScene)
{
DefaultLogger::get()->debug("FindInvalidDataProcess begin");
void FindInvalidDataProcess::Execute( aiScene* pScene) {
ASSIMP_LOG_DEBUG("FindInvalidDataProcess begin");
bool out = false;
std::vector<unsigned int> meshMapping(pScene->mNumMeshes);
@ -162,24 +160,26 @@ void FindInvalidDataProcess::Execute( aiScene* pScene)
pScene->mNumMeshes = real;
}
DefaultLogger::get()->info("FindInvalidDataProcess finished. Found issues ...");
ASSIMP_LOG_INFO("FindInvalidDataProcess finished. Found issues ...");
} else {
ASSIMP_LOG_DEBUG("FindInvalidDataProcess finished. Everything seems to be OK.");
}
else DefaultLogger::get()->debug("FindInvalidDataProcess finished. Everything seems to be OK.");
}
// ------------------------------------------------------------------------------------------------
template <typename T>
inline const char* ValidateArrayContents(const T* /*arr*/, unsigned int /*size*/,
const std::vector<bool>& /*dirtyMask*/, bool /*mayBeIdentical = false*/, bool /*mayBeZero = true*/)
inline
const char* ValidateArrayContents(const T* /*arr*/, unsigned int /*size*/,
const std::vector<bool>& /*dirtyMask*/, bool /*mayBeIdentical = false*/, bool /*mayBeZero = true*/)
{
return NULL;
return nullptr;
}
// ------------------------------------------------------------------------------------------------
template <>
inline const char* ValidateArrayContents<aiVector3D>(const aiVector3D* arr, unsigned int size,
const std::vector<bool>& dirtyMask, bool mayBeIdentical , bool mayBeZero )
{
inline
const char* ValidateArrayContents<aiVector3D>(const aiVector3D* arr, unsigned int size,
const std::vector<bool>& dirtyMask, bool mayBeIdentical , bool mayBeZero ) {
bool b = false;
unsigned int cnt = 0;
for (unsigned int i = 0; i < size;++i) {
@ -201,18 +201,17 @@ inline const char* ValidateArrayContents<aiVector3D>(const aiVector3D* arr, unsi
if (cnt > 1 && !b && !mayBeIdentical) {
return "All vectors are identical";
}
return NULL;
return nullptr;
}
// ------------------------------------------------------------------------------------------------
template <typename T>
inline bool ProcessArray(T*& in, unsigned int num,const char* name,
const std::vector<bool>& dirtyMask, bool mayBeIdentical = false, bool mayBeZero = true)
{
inline
bool ProcessArray(T*& in, unsigned int num,const char* name,
const std::vector<bool>& dirtyMask, bool mayBeIdentical = false, bool mayBeZero = true) {
const char* err = ValidateArrayContents(in,num,dirtyMask,mayBeIdentical,mayBeZero);
if (err) {
DefaultLogger::get()->error(std::string("FindInvalidDataProcess fails on mesh ") + name + ": " + err);
ASSIMP_LOG_ERROR_F( "FindInvalidDataProcess fails on mesh ", name, ": ", err);
delete[] in;
in = NULL;
return true;
@ -250,23 +249,20 @@ bool EpsilonCompare<aiQuatKey>(const aiQuatKey& n, const aiQuatKey& s, ai_real e
// ------------------------------------------------------------------------------------------------
template <typename T>
inline bool AllIdentical(T* in, unsigned int num, ai_real epsilon)
{
inline
bool AllIdentical(T* in, unsigned int num, ai_real epsilon) {
if (num <= 1) {
return true;
}
if (epsilon > 0.f) {
if (fabs(epsilon) > 0.f) {
for (unsigned int i = 0; i < num-1;++i) {
if (!EpsilonCompare(in[i],in[i+1],epsilon)) {
return false;
}
}
}
else {
} else {
for (unsigned int i = 0; i < num-1;++i) {
if (in[i] != in[i+1]) {
return false;
}
@ -277,27 +273,26 @@ inline bool AllIdentical(T* in, unsigned int num, ai_real epsilon)
// ------------------------------------------------------------------------------------------------
// Search an animation for invalid content
void FindInvalidDataProcess::ProcessAnimation (aiAnimation* anim)
{
void FindInvalidDataProcess::ProcessAnimation (aiAnimation* anim) {
// Process all animation channels
for (unsigned int a = 0; a < anim->mNumChannels;++a) {
for ( unsigned int a = 0; a < anim->mNumChannels; ++a ) {
ProcessAnimationChannel( anim->mChannels[a]);
}
}
// ------------------------------------------------------------------------------------------------
void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim)
{
int i = 0;
// ScenePreprocessor's work ...
ai_assert((0 != anim->mPositionKeys && 0 != anim->mRotationKeys && 0 != anim->mScalingKeys));
void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim) {
ai_assert( nullptr != anim );
if (anim->mNumPositionKeys == 0 && anim->mNumRotationKeys == 0 && anim->mNumScalingKeys == 0) {
ai_assert_entry();
return;
}
// Check whether all values in a tracks are identical - in this case
// we can remove al keys except one.
// POSITIONS
if (anim->mNumPositionKeys > 1 && AllIdentical(anim->mPositionKeys,anim->mNumPositionKeys,configEpsilon))
{
int i = 0;
if (anim->mNumPositionKeys > 1 && AllIdentical(anim->mPositionKeys,anim->mNumPositionKeys,configEpsilon)) {
aiVectorKey v = anim->mPositionKeys[0];
// Reallocate ... we need just ONE element, it makes no sense to reuse the array
@ -308,8 +303,7 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim)
}
// ROTATIONS
if (anim->mNumRotationKeys > 1 && AllIdentical(anim->mRotationKeys,anim->mNumRotationKeys,configEpsilon))
{
if (anim->mNumRotationKeys > 1 && AllIdentical(anim->mRotationKeys,anim->mNumRotationKeys,configEpsilon)) {
aiQuatKey v = anim->mRotationKeys[0];
// Reallocate ... we need just ONE element, it makes no sense to reuse the array
@ -320,8 +314,7 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim)
}
// SCALINGS
if (anim->mNumScalingKeys > 1 && AllIdentical(anim->mScalingKeys,anim->mNumScalingKeys,configEpsilon))
{
if (anim->mNumScalingKeys > 1 && AllIdentical(anim->mScalingKeys,anim->mNumScalingKeys,configEpsilon)) {
aiVectorKey v = anim->mScalingKeys[0];
// Reallocate ... we need just ONE element, it makes no sense to reuse the array
@ -330,13 +323,14 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim)
anim->mScalingKeys[0] = v;
i = 1;
}
if (1 == i)
DefaultLogger::get()->warn("Simplified dummy tracks with just one key");
if ( 1 == i ) {
ASSIMP_LOG_WARN("Simplified dummy tracks with just one key");
}
}
// ------------------------------------------------------------------------------------------------
// Search a mesh for invalid contents
int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
int FindInvalidDataProcess::ProcessMesh(aiMesh* pMesh)
{
bool ret = false;
std::vector<bool> dirtyMask(pMesh->mNumVertices, pMesh->mNumFaces != 0);
@ -353,24 +347,26 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
// Process vertex positions
if (pMesh->mVertices && ProcessArray(pMesh->mVertices, pMesh->mNumVertices, "positions", dirtyMask)) {
DefaultLogger::get()->error("Deleting mesh: Unable to continue without vertex positions");
ASSIMP_LOG_ERROR("Deleting mesh: Unable to continue without vertex positions");
return 2;
}
// process texture coordinates
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i]; ++i) {
if (ProcessArray(pMesh->mTextureCoords[i], pMesh->mNumVertices, "uvcoords", dirtyMask)) {
pMesh->mNumUVComponents[i] = 0;
if (!mIgnoreTexCoods) {
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS && pMesh->mTextureCoords[i]; ++i) {
if (ProcessArray(pMesh->mTextureCoords[i], pMesh->mNumVertices, "uvcoords", dirtyMask)) {
pMesh->mNumUVComponents[i] = 0;
// delete all subsequent texture coordinate sets.
for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
delete[] pMesh->mTextureCoords[a];
pMesh->mTextureCoords[a] = NULL;
pMesh->mNumUVComponents[a] = 0;
// delete all subsequent texture coordinate sets.
for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) {
delete[] pMesh->mTextureCoords[a];
pMesh->mTextureCoords[a] = NULL;
pMesh->mNumUVComponents[a] = 0;
}
ret = true;
}
ret = true;
}
}
@ -387,13 +383,11 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
aiPrimitiveType_POLYGON & pMesh->mPrimitiveTypes)
{
// We need to update the lookup-table
for (unsigned int m = 0; m < pMesh->mNumFaces;++m)
{
const aiFace& f = pMesh->mFaces[m];
for (unsigned int m = 0; m < pMesh->mNumFaces;++m) {
const aiFace& f = pMesh->mFaces[ m ];
if (f.mNumIndices < 3) {
dirtyMask[f.mIndices[0]] = true;
if (f.mNumIndices == 2) {
dirtyMask[f.mIndices[1]] = true;
}
@ -402,7 +396,9 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
}
// Normals, tangents and bitangents are undefined for
// the whole mesh (and should not even be there)
else return ret;
else {
return ret;
}
}
// Process mesh normals
@ -425,5 +421,4 @@ int FindInvalidDataProcess::ProcessMesh (aiMesh* pMesh)
return ret ? 1 : 0;
}
#endif // !! ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS