Merge branch 'master' of https://github.com/assimp/assimp
This commit is contained in:
@@ -62,7 +62,7 @@ bool ArmaturePopulate::IsActive(unsigned int pFlags) const {
|
||||
return (pFlags & aiProcess_PopulateArmatureData) != 0;
|
||||
}
|
||||
|
||||
void ArmaturePopulate::SetupProperties(const Importer *pImp) {
|
||||
void ArmaturePopulate::SetupProperties(const Importer *) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -162,9 +162,9 @@ void ArmaturePopulate::BuildNodeList(const aiNode *current_node,
|
||||
// A bone stack allows us to have multiple armatures, with the same bone names
|
||||
// A bone stack allows us also to retrieve bones true transform even with
|
||||
// duplicate names :)
|
||||
void ArmaturePopulate::BuildBoneStack(aiNode *current_node,
|
||||
void ArmaturePopulate::BuildBoneStack(aiNode *,
|
||||
const aiNode *root_node,
|
||||
const aiScene *scene,
|
||||
const aiScene*,
|
||||
const std::vector<aiBone *> &bones,
|
||||
std::map<aiBone *, aiNode *> &bone_stack,
|
||||
std::vector<aiNode *> &node_stack) {
|
||||
|
||||
@@ -238,7 +238,7 @@ bool CalcTangentsProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||
// FIX: check whether we can reuse the SpatialSort of a previous step
|
||||
SpatialSort* vertexFinder = NULL;
|
||||
SpatialSort _vertexFinder;
|
||||
float posEpsilon;
|
||||
float posEpsilon = 10e-6f;
|
||||
if (shared)
|
||||
{
|
||||
std::vector<std::pair<SpatialSort,float> >* avf;
|
||||
|
||||
@@ -137,7 +137,7 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
|
||||
pTexture->pcData = imageContent;
|
||||
|
||||
auto extension = path.substr(path.find_last_of('.') + 1u);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ToLower<char> );
|
||||
if (extension == "jpeg") {
|
||||
extension = "jpg";
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -44,24 +42,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/** @file Defines a post processing step to search an importer's output
|
||||
for data that is obviously invalid */
|
||||
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_FINDINVALIDDATA_PROCESS
|
||||
|
||||
// internal headers
|
||||
#include "FindInvalidDataProcess.h"
|
||||
#include "ProcessHelper.h"
|
||||
# include "FindInvalidDataProcess.h"
|
||||
# include "ProcessHelper.h"
|
||||
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/qnan.h>
|
||||
# include <assimp/Exceptional.h>
|
||||
# include <assimp/qnan.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
FindInvalidDataProcess::FindInvalidDataProcess()
|
||||
: configEpsilon(0.0)
|
||||
, mIgnoreTexCoods( false ){
|
||||
FindInvalidDataProcess::FindInvalidDataProcess() :
|
||||
configEpsilon(0.0), mIgnoreTexCoods(false) {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
@@ -73,47 +68,47 @@ FindInvalidDataProcess::~FindInvalidDataProcess() {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// 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));
|
||||
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) {
|
||||
if (node->mNumMeshes) {
|
||||
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) {
|
||||
for (unsigned int a = 0; a < node->mNumMeshes; ++a) {
|
||||
|
||||
unsigned int ref = node->mMeshes[a];
|
||||
if (UINT_MAX != (ref = meshMapping[ref])) {
|
||||
if (UINT_MAX != (ref = meshMapping[ref])) {
|
||||
node->mMeshes[out++] = ref;
|
||||
}
|
||||
}
|
||||
// just let the members that are unused, that's much cheaper
|
||||
// than a full array realloc'n'copy party ...
|
||||
if(!(node->mNumMeshes = out)) {
|
||||
|
||||
node->mNumMeshes = out;
|
||||
if (0 == out) {
|
||||
delete[] node->mMeshes;
|
||||
node->mMeshes = NULL;
|
||||
}
|
||||
}
|
||||
// recursively update all children
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||
UpdateMeshReferences(node->mChildren[i],meshMapping);
|
||||
for (unsigned int i = 0; i < node->mNumChildren; ++i) {
|
||||
UpdateMeshReferences(node->mChildren[i], meshMapping);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Executes the post processing step on the given imported data.
|
||||
void FindInvalidDataProcess::Execute( aiScene* pScene) {
|
||||
void FindInvalidDataProcess::Execute(aiScene *pScene) {
|
||||
ASSIMP_LOG_DEBUG("FindInvalidDataProcess begin");
|
||||
|
||||
bool out = false;
|
||||
@@ -121,33 +116,31 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) {
|
||||
unsigned int real = 0;
|
||||
|
||||
// Process meshes
|
||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++) {
|
||||
|
||||
int result;
|
||||
if ((result = ProcessMesh( pScene->mMeshes[a]))) {
|
||||
for (unsigned int a = 0; a < pScene->mNumMeshes; a++) {
|
||||
int result = ProcessMesh(pScene->mMeshes[a]);
|
||||
if (0 == result) {
|
||||
out = true;
|
||||
|
||||
if (2 == result) {
|
||||
// remove this mesh
|
||||
delete pScene->mMeshes[a];
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene->mMeshes[a]);
|
||||
|
||||
meshMapping[a] = UINT_MAX;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (2 == result) {
|
||||
// remove this mesh
|
||||
delete pScene->mMeshes[a];
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene->mMeshes[a]);
|
||||
|
||||
meshMapping[a] = UINT_MAX;
|
||||
continue;
|
||||
}
|
||||
|
||||
pScene->mMeshes[real] = pScene->mMeshes[a];
|
||||
meshMapping[a] = real++;
|
||||
}
|
||||
|
||||
// Process animations
|
||||
for (unsigned int a = 0; a < pScene->mNumAnimations;++a) {
|
||||
ProcessAnimation( pScene->mAnimations[a]);
|
||||
for (unsigned int animIdx = 0; animIdx < pScene->mNumAnimations; ++animIdx) {
|
||||
ProcessAnimation(pScene->mAnimations[animIdx]);
|
||||
}
|
||||
|
||||
|
||||
if (out) {
|
||||
if ( real != pScene->mNumMeshes) {
|
||||
if (out) {
|
||||
if (real != pScene->mNumMeshes) {
|
||||
if (!real) {
|
||||
throw DeadlyImportError("No meshes remaining");
|
||||
}
|
||||
@@ -155,7 +148,7 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) {
|
||||
// we need to remove some meshes.
|
||||
// therefore we'll also need to remove all references
|
||||
// to them from the scenegraph
|
||||
UpdateMeshReferences(pScene->mRootNode,meshMapping);
|
||||
UpdateMeshReferences(pScene->mRootNode, meshMapping);
|
||||
pScene->mNumMeshes = real;
|
||||
}
|
||||
|
||||
@@ -167,35 +160,32 @@ void FindInvalidDataProcess::Execute( aiScene* pScene) {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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 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) {
|
||||
for (unsigned int i = 0; i < size; ++i) {
|
||||
|
||||
if (dirtyMask.size() && dirtyMask[i]) {
|
||||
continue;
|
||||
}
|
||||
++cnt;
|
||||
|
||||
const aiVector3D& v = arr[i];
|
||||
if (is_special_float(v.x) || is_special_float(v.y) || is_special_float(v.z)) {
|
||||
const aiVector3D &v = arr[i];
|
||||
if (is_special_float(v.x) || is_special_float(v.y) || is_special_float(v.z)) {
|
||||
return "INF/NAN was found in a vector component";
|
||||
}
|
||||
if (!mayBeZero && !v.x && !v.y && !v.z ) {
|
||||
if (!mayBeZero && !v.x && !v.y && !v.z) {
|
||||
return "Found zero-length vector";
|
||||
}
|
||||
if (i && v != arr[i-1])b = true;
|
||||
if (i && v != arr[i - 1]) b = true;
|
||||
}
|
||||
if (cnt > 1 && !b && !mayBeIdentical) {
|
||||
return "All vectors are identical";
|
||||
@@ -205,12 +195,11 @@ const char* ValidateArrayContents<aiVector3D>(const aiVector3D* arr, unsigned in
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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) {
|
||||
const char* err = ValidateArrayContents(in,num,dirtyMask,mayBeIdentical,mayBeZero);
|
||||
if (err) {
|
||||
ASSIMP_LOG_ERROR_F( "FindInvalidDataProcess fails on mesh ", name, ": ", err);
|
||||
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) {
|
||||
ASSIMP_LOG_ERROR_F("FindInvalidDataProcess fails on mesh ", name, ": ", err);
|
||||
delete[] in;
|
||||
in = NULL;
|
||||
return true;
|
||||
@@ -220,49 +209,46 @@ bool ProcessArray(T*& in, unsigned int num,const char* name,
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <typename T>
|
||||
AI_FORCE_INLINE bool EpsilonCompare(const T& n, const T& s, ai_real epsilon);
|
||||
AI_FORCE_INLINE bool EpsilonCompare(const T &n, const T &s, ai_real epsilon);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
AI_FORCE_INLINE bool EpsilonCompare(ai_real n, ai_real s, ai_real epsilon) {
|
||||
return std::fabs(n-s)>epsilon;
|
||||
return std::fabs(n - s) > epsilon;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
bool EpsilonCompare<aiVectorKey>(const aiVectorKey& n, const aiVectorKey& s, ai_real epsilon) {
|
||||
return
|
||||
EpsilonCompare(n.mValue.x,s.mValue.x,epsilon) &&
|
||||
EpsilonCompare(n.mValue.y,s.mValue.y,epsilon) &&
|
||||
EpsilonCompare(n.mValue.z,s.mValue.z,epsilon);
|
||||
bool EpsilonCompare<aiVectorKey>(const aiVectorKey &n, const aiVectorKey &s, ai_real epsilon) {
|
||||
return EpsilonCompare(n.mValue.x, s.mValue.x, epsilon) &&
|
||||
EpsilonCompare(n.mValue.y, s.mValue.y, epsilon) &&
|
||||
EpsilonCompare(n.mValue.z, s.mValue.z, epsilon);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <>
|
||||
bool EpsilonCompare<aiQuatKey>(const aiQuatKey& n, const aiQuatKey& s, ai_real epsilon) {
|
||||
return
|
||||
EpsilonCompare(n.mValue.x,s.mValue.x,epsilon) &&
|
||||
EpsilonCompare(n.mValue.y,s.mValue.y,epsilon) &&
|
||||
EpsilonCompare(n.mValue.z,s.mValue.z,epsilon) &&
|
||||
EpsilonCompare(n.mValue.w,s.mValue.w,epsilon);
|
||||
bool EpsilonCompare<aiQuatKey>(const aiQuatKey &n, const aiQuatKey &s, ai_real epsilon) {
|
||||
return EpsilonCompare(n.mValue.x, s.mValue.x, epsilon) &&
|
||||
EpsilonCompare(n.mValue.y, s.mValue.y, epsilon) &&
|
||||
EpsilonCompare(n.mValue.z, s.mValue.z, epsilon) &&
|
||||
EpsilonCompare(n.mValue.w, s.mValue.w, epsilon);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
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 (fabs(epsilon) > 0.f) {
|
||||
for (unsigned int i = 0; i < num-1;++i) {
|
||||
if (!EpsilonCompare(in[i],in[i+1],epsilon)) {
|
||||
for (unsigned int i = 0; i < num - 1; ++i) {
|
||||
if (!EpsilonCompare(in[i], in[i + 1], epsilon)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i = 0; i < num-1;++i) {
|
||||
if (in[i] != in[i+1]) {
|
||||
for (unsigned int i = 0; i < num - 1; ++i) {
|
||||
if (in[i] != in[i + 1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -272,16 +258,16 @@ 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 ) {
|
||||
ProcessAnimationChannel( anim->mChannels[a]);
|
||||
for (unsigned int a = 0; a < anim->mNumChannels; ++a) {
|
||||
ProcessAnimationChannel(anim->mChannels[a]);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim) {
|
||||
ai_assert( nullptr != anim );
|
||||
void FindInvalidDataProcess::ProcessAnimationChannel(aiNodeAnim *anim) {
|
||||
ai_assert(nullptr != anim);
|
||||
if (anim->mNumPositionKeys == 0 && anim->mNumRotationKeys == 0 && anim->mNumScalingKeys == 0) {
|
||||
ai_assert_entry();
|
||||
return;
|
||||
@@ -291,7 +277,7 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim) {
|
||||
// we can remove al keys except one.
|
||||
// POSITIONS
|
||||
int i = 0;
|
||||
if (anim->mNumPositionKeys > 1 && AllIdentical(anim->mPositionKeys,anim->mNumPositionKeys,configEpsilon)) {
|
||||
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
|
||||
@@ -302,7 +288,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
|
||||
@@ -313,7 +299,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
|
||||
@@ -322,22 +308,21 @@ void FindInvalidDataProcess::ProcessAnimationChannel (aiNodeAnim* anim) {
|
||||
anim->mScalingKeys[0] = v;
|
||||
i = 1;
|
||||
}
|
||||
if ( 1 == i ) {
|
||||
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);
|
||||
|
||||
// Ignore elements that are not referenced by vertices.
|
||||
// (they are, for example, caused by the FindDegenerates step)
|
||||
for (unsigned int m = 0; m < pMesh->mNumFaces; ++m) {
|
||||
const aiFace& f = pMesh->mFaces[m];
|
||||
const aiFace &f = pMesh->mFaces[m];
|
||||
|
||||
for (unsigned int i = 0; i < f.mNumIndices; ++i) {
|
||||
dirtyMask[f.mIndices[i]] = false;
|
||||
@@ -373,19 +358,17 @@ int FindInvalidDataProcess::ProcessMesh(aiMesh* pMesh)
|
||||
// they are invalid or not.
|
||||
|
||||
// Normals and tangents are undefined for point and line faces.
|
||||
if (pMesh->mNormals || pMesh->mTangents) {
|
||||
if (pMesh->mNormals || pMesh->mTangents) {
|
||||
|
||||
if (aiPrimitiveType_POINT & pMesh->mPrimitiveTypes ||
|
||||
aiPrimitiveType_LINE & pMesh->mPrimitiveTypes)
|
||||
{
|
||||
aiPrimitiveType_LINE & pMesh->mPrimitiveTypes) {
|
||||
if (aiPrimitiveType_TRIANGLE & pMesh->mPrimitiveTypes ||
|
||||
aiPrimitiveType_POLYGON & pMesh->mPrimitiveTypes)
|
||||
{
|
||||
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) {
|
||||
if (f.mNumIndices < 3) {
|
||||
dirtyMask[f.mIndices[0]] = true;
|
||||
if (f.mNumIndices == 2) {
|
||||
dirtyMask[f.mIndices[1]] = true;
|
||||
@@ -401,19 +384,21 @@ int FindInvalidDataProcess::ProcessMesh(aiMesh* pMesh)
|
||||
}
|
||||
|
||||
// Process mesh normals
|
||||
if (pMesh->mNormals && ProcessArray(pMesh->mNormals,pMesh->mNumVertices,
|
||||
"normals",dirtyMask,true,false))
|
||||
if (pMesh->mNormals && ProcessArray(pMesh->mNormals, pMesh->mNumVertices,
|
||||
"normals", dirtyMask, true, false))
|
||||
ret = true;
|
||||
|
||||
// Process mesh tangents
|
||||
if (pMesh->mTangents && ProcessArray(pMesh->mTangents,pMesh->mNumVertices,"tangents",dirtyMask)) {
|
||||
delete[] pMesh->mBitangents; pMesh->mBitangents = NULL;
|
||||
if (pMesh->mTangents && ProcessArray(pMesh->mTangents, pMesh->mNumVertices, "tangents", dirtyMask)) {
|
||||
delete[] pMesh->mBitangents;
|
||||
pMesh->mBitangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// Process mesh bitangents
|
||||
if (pMesh->mBitangents && ProcessArray(pMesh->mBitangents,pMesh->mNumVertices,"bitangents",dirtyMask)) {
|
||||
delete[] pMesh->mTangents; pMesh->mTangents = NULL;
|
||||
if (pMesh->mBitangents && ProcessArray(pMesh->mBitangents, pMesh->mNumVertices, "bitangents", dirtyMask)) {
|
||||
delete[] pMesh->mTangents;
|
||||
pMesh->mTangents = NULL;
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
@@ -48,14 +47,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "Common/BaseProcess.h"
|
||||
|
||||
#include <assimp/types.h>
|
||||
#include <assimp/anim.h>
|
||||
#include <assimp/types.h>
|
||||
|
||||
struct aiMesh;
|
||||
|
||||
class FindInvalidDataProcessTest;
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
/** The FindInvalidData post-processing step. It searches the mesh data
|
||||
@@ -70,31 +69,31 @@ public:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
bool IsActive( unsigned int pFlags) const;
|
||||
bool IsActive(unsigned int pFlags) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Setup import settings
|
||||
void SetupProperties(const Importer* pImp);
|
||||
void SetupProperties(const Importer *pImp);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Run the step
|
||||
void Execute( aiScene* pScene);
|
||||
void Execute(aiScene *pScene);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Executes the post-processing step on the given mesh
|
||||
* @param pMesh The mesh to process.
|
||||
* @return 0 - nothing, 1 - removed sth, 2 - please delete me */
|
||||
int ProcessMesh( aiMesh* pMesh);
|
||||
int ProcessMesh(aiMesh *pMesh);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Executes the post-processing step on the given animation
|
||||
* @param anim The animation to process. */
|
||||
void ProcessAnimation (aiAnimation* anim);
|
||||
void ProcessAnimation(aiAnimation *anim);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Executes the post-processing step on the given anim channel
|
||||
* @param anim The animation channel to process.*/
|
||||
void ProcessAnimationChannel (aiNodeAnim* anim);
|
||||
void ProcessAnimationChannel(aiNodeAnim *anim);
|
||||
|
||||
private:
|
||||
ai_real configEpsilon;
|
||||
|
||||
@@ -132,11 +132,9 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
|
||||
// need to build a clean list of bones, too
|
||||
for (unsigned int i = 0;i < pcMesh->mNumBones;++i)
|
||||
{
|
||||
for (unsigned int a = 0; a < pcMesh->mBones[i]->mNumWeights;a++)
|
||||
{
|
||||
const aiVertexWeight& w = pcMesh->mBones[i]->mWeights[a];
|
||||
if(pcFace->mIndices[q] == w.mVertexId)
|
||||
{
|
||||
for (unsigned int boneIdx = 0; boneIdx < pcMesh->mBones[i]->mNumWeights; ++boneIdx) {
|
||||
const aiVertexWeight &w = pcMesh->mBones[i]->mWeights[boneIdx];
|
||||
if(pcFace->mIndices[q] == w.mVertexId) {
|
||||
aiVertexWeight wNew;
|
||||
wNew.mVertexId = iIndex;
|
||||
wNew.mWeight = w.mWeight;
|
||||
@@ -157,17 +155,17 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
|
||||
pvBitangents[iIndex] = pcMesh->mBitangents[pcFace->mIndices[q]];
|
||||
}
|
||||
|
||||
unsigned int p = 0;
|
||||
while (pcMesh->HasTextureCoords(p))
|
||||
unsigned int pp = 0;
|
||||
while (pcMesh->HasTextureCoords(pp))
|
||||
{
|
||||
apvTextureCoords[p][iIndex] = pcMesh->mTextureCoords[p][pcFace->mIndices[q]];
|
||||
++p;
|
||||
apvTextureCoords[pp][iIndex] = pcMesh->mTextureCoords[pp][pcFace->mIndices[q]];
|
||||
++pp;
|
||||
}
|
||||
p = 0;
|
||||
while (pcMesh->HasVertexColors(p))
|
||||
pp = 0;
|
||||
while (pcMesh->HasVertexColors(pp))
|
||||
{
|
||||
apvColorSets[p][iIndex] = pcMesh->mColors[p][pcFace->mIndices[q]];
|
||||
++p;
|
||||
apvColorSets[pp][iIndex] = pcMesh->mColors[pp][pcFace->mIndices[q]];
|
||||
++pp;
|
||||
}
|
||||
pcFace->mIndices[q] = iIndex;
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode *nd, std::list<aiNode *> &n
|
||||
|
||||
// copy all mesh references in one array
|
||||
if (out_meshes) {
|
||||
unsigned int *meshes = new unsigned int[out_meshes + join_master->mNumMeshes], *tmp = meshes;
|
||||
unsigned int *meshIdxs = new unsigned int[out_meshes + join_master->mNumMeshes], *tmp = meshIdxs;
|
||||
for (unsigned int n = 0; n < join_master->mNumMeshes; ++n) {
|
||||
*tmp++ = join_master->mMeshes[n];
|
||||
}
|
||||
@@ -217,7 +217,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode *nd, std::list<aiNode *> &n
|
||||
delete join_node; // bye, node
|
||||
}
|
||||
delete[] join_master->mMeshes;
|
||||
join_master->mMeshes = meshes;
|
||||
join_master->mMeshes = meshIdxs;
|
||||
join_master->mNumMeshes += out_meshes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,19 +330,23 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
|
||||
ai_assert(outFaces == out->mFaces + out->mNumFaces);
|
||||
|
||||
// now generate output bones
|
||||
for (unsigned int q = 0; q < mesh->mNumBones;++q)
|
||||
if (!tempBones[q].empty())++out->mNumBones;
|
||||
for (unsigned int q = 0; q < mesh->mNumBones; ++q) {
|
||||
if (!tempBones[q].empty()) {
|
||||
++out->mNumBones;
|
||||
}
|
||||
}
|
||||
|
||||
if (out->mNumBones)
|
||||
{
|
||||
if (out->mNumBones) {
|
||||
out->mBones = new aiBone*[out->mNumBones];
|
||||
for (unsigned int q = 0, real = 0; q < mesh->mNumBones;++q)
|
||||
for (unsigned int q = 0, boneIdx = 0; q < mesh->mNumBones;++q)
|
||||
{
|
||||
TempBoneInfo& in = tempBones[q];
|
||||
if (in.empty())continue;
|
||||
if (in.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
aiBone* srcBone = mesh->mBones[q];
|
||||
aiBone* bone = out->mBones[real] = new aiBone();
|
||||
aiBone *bone = out->mBones[boneIdx] = new aiBone();
|
||||
|
||||
bone->mName = srcBone->mName;
|
||||
bone->mOffsetMatrix = srcBone->mOffsetMatrix;
|
||||
@@ -352,7 +356,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
|
||||
|
||||
::memcpy(bone->mWeights,&in[0],bone->mNumWeights*sizeof(aiVertexWeight));
|
||||
|
||||
++real;
|
||||
++boneIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +368,7 @@ void SortByPTypeProcess::Execute( aiScene* pScene) {
|
||||
delete mesh;
|
||||
|
||||
// avoid invalid pointer
|
||||
pScene->mMeshes[i] = NULL;
|
||||
pScene->mMeshes[i] = nullptr;
|
||||
}
|
||||
|
||||
if (outMeshes.empty())
|
||||
|
||||
@@ -575,8 +575,9 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
|
||||
for (unsigned int k = 0; k < pMesh->mNumBones;++k) {
|
||||
// check whether the bone is existing
|
||||
BoneWeightList* pcWeightList;
|
||||
if ((pcWeightList = (BoneWeightList*)pcMesh->mBones[k])) {
|
||||
aiBone* pcOldBone = pMesh->mBones[k];
|
||||
pcWeightList = (BoneWeightList *)pcMesh->mBones[k];
|
||||
if (nullptr != pcWeightList) {
|
||||
aiBone *pcOldBone = pMesh->mBones[k];
|
||||
aiBone* pcOut( nullptr );
|
||||
*ppCurrent++ = pcOut = new aiBone();
|
||||
pcOut->mName = aiString(pcOldBone->mName);
|
||||
|
||||
@@ -104,7 +104,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
if (info.mRotation)
|
||||
{
|
||||
float out = info.mRotation;
|
||||
if ((rounded = static_cast<int>((info.mRotation / static_cast<float>(AI_MATH_TWO_PI)))))
|
||||
rounded = static_cast<int>((info.mRotation / static_cast<float>(AI_MATH_TWO_PI)));
|
||||
if (rounded)
|
||||
{
|
||||
out -= rounded * static_cast<float>(AI_MATH_PI);
|
||||
ASSIMP_LOG_INFO_F("Texture coordinate rotation ", info.mRotation, " can be simplified to ", out);
|
||||
@@ -124,7 +125,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
* type (e.g. if mirroring is active there IS a difference between
|
||||
* offset 2 and 3)
|
||||
*/
|
||||
if ((rounded = (int)info.mTranslation.x)) {
|
||||
rounded = (int)info.mTranslation.x;
|
||||
if (rounded) {
|
||||
float out = 0.0f;
|
||||
szTemp[0] = 0;
|
||||
if (aiTextureMapMode_Wrap == info.mapU) {
|
||||
@@ -157,7 +159,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
* type (e.g. if mirroring is active there IS a difference between
|
||||
* offset 2 and 3)
|
||||
*/
|
||||
if ((rounded = (int)info.mTranslation.y)) {
|
||||
rounded = (int)info.mTranslation.y;
|
||||
if (rounded) {
|
||||
float out = 0.0f;
|
||||
szTemp[0] = 0;
|
||||
if (aiTextureMapMode_Wrap == info.mapV) {
|
||||
|
||||
@@ -419,7 +419,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
|
||||
num = 0;
|
||||
break;
|
||||
|
||||
curOut -= (max-num); /* undo all previous work */
|
||||
/*curOut -= (max-num); // undo all previous work
|
||||
for (tmp = 0; tmp < max-2; ++tmp) {
|
||||
aiFace& nface = *curOut++;
|
||||
|
||||
@@ -433,7 +433,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
|
||||
|
||||
}
|
||||
num = 0;
|
||||
break;
|
||||
break;*/
|
||||
}
|
||||
|
||||
aiFace& nface = *curOut++;
|
||||
|
||||
@@ -612,7 +612,7 @@ void ValidateDSProcess::SearchForInvalidTextures(const aiMaterial* pMaterial,
|
||||
bool bNoSpecified = true;
|
||||
for (unsigned int i = 0; i < pMaterial->mNumProperties;++i) {
|
||||
aiMaterialProperty* prop = pMaterial->mProperties[i];
|
||||
if (prop->mSemantic != type) {
|
||||
if (static_cast<aiTextureType>(prop->mSemantic) != type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user