Merge branch 'master' into raise-cmake-minimum-version-to-3.0

pull/3033/head
Kim Kulling 2020-03-02 20:44:07 +01:00 committed by GitHub
commit a254690ba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 154 additions and 120 deletions

View File

@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@/ exec_prefix=@CMAKE_INSTALL_PREFIX@/
libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@ libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@
includedir=@CMAKE_INSTALL_PREFIX@/../include/@ASSIMP_INCLUDE_INSTALL_DIR@ includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@
Name: @CMAKE_PROJECT_NAME@ Name: @CMAKE_PROJECT_NAME@
Description: Import various well-known 3D model formats in an uniform manner. Description: Import various well-known 3D model formats in an uniform manner.

View File

@ -252,6 +252,8 @@ MACRO(ADD_ASSIMP_IMPORTER name)
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
if (NOT ASSIMP_NO_EXPORT)
# if this variable is set to TRUE, the user can manually disable exporters by setting # if this variable is set to TRUE, the user can manually disable exporters by setting
# ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter # ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter
# if this variable is set to FALSE, the user can manually enable exporters by setting # if this variable is set to FALSE, the user can manually enable exporters by setting
@ -282,6 +284,8 @@ MACRO(ADD_ASSIMP_EXPORTER name)
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
endif()
SET(ASSIMP_LOADER_SRCS "") SET(ASSIMP_LOADER_SRCS "")
SET(ASSIMP_IMPORTERS_ENABLED "") # list of enabled importers SET(ASSIMP_IMPORTERS_ENABLED "") # list of enabled importers
SET(ASSIMP_IMPORTERS_DISABLED "") # disabled importers list (used to print) SET(ASSIMP_IMPORTERS_DISABLED "") # disabled importers list (used to print)
@ -307,11 +311,6 @@ ADD_ASSIMP_IMPORTER( 3DS
3DS/3DSLoader.h 3DS/3DSLoader.h
) )
ADD_ASSIMP_EXPORTER( 3DS
3DS/3DSExporter.h
3DS/3DSExporter.cpp
)
ADD_ASSIMP_IMPORTER( AC ADD_ASSIMP_IMPORTER( AC
AC/ACLoader.cpp AC/ACLoader.cpp
AC/ACLoader.h AC/ACLoader.h
@ -329,20 +328,6 @@ ADD_ASSIMP_IMPORTER( ASSBIN
Assbin/AssbinLoader.cpp Assbin/AssbinLoader.cpp
) )
ADD_ASSIMP_EXPORTER( ASSBIN
Assbin/AssbinExporter.h
Assbin/AssbinExporter.cpp
Assbin/AssbinFileWriter.h
Assbin/AssbinFileWriter.cpp
)
ADD_ASSIMP_EXPORTER( ASSXML
Assxml/AssxmlExporter.h
Assxml/AssxmlExporter.cpp
Assxml/AssxmlFileWriter.h
Assxml/AssxmlFileWriter.cpp
)
ADD_ASSIMP_IMPORTER( B3D ADD_ASSIMP_IMPORTER( B3D
B3D/B3DImporter.cpp B3D/B3DImporter.cpp
B3D/B3DImporter.h B3D/B3DImporter.h
@ -362,11 +347,6 @@ ADD_ASSIMP_IMPORTER( COLLADA
Collada/ColladaParser.h Collada/ColladaParser.h
) )
ADD_ASSIMP_EXPORTER( COLLADA
Collada/ColladaExporter.h
Collada/ColladaExporter.cpp
)
ADD_ASSIMP_IMPORTER( DXF ADD_ASSIMP_IMPORTER( DXF
DXF/DXFLoader.cpp DXF/DXFLoader.cpp
DXF/DXFLoader.h DXF/DXFLoader.h
@ -423,11 +403,6 @@ ADD_ASSIMP_IMPORTER( M3D
M3D/m3d.h M3D/m3d.h
) )
ADD_ASSIMP_EXPORTER( M3D
M3D/M3DExporter.h
M3D/M3DExporter.cpp
)
ADD_ASSIMP_IMPORTER( MD2 ADD_ASSIMP_IMPORTER( MD2
MD2/MD2FileData.h MD2/MD2FileData.h
MD2/MD2Loader.cpp MD2/MD2Loader.cpp
@ -505,11 +480,6 @@ ADD_ASSIMP_IMPORTER( OBJ
Obj/ObjTools.h Obj/ObjTools.h
) )
ADD_ASSIMP_EXPORTER( OBJ
Obj/ObjExporter.h
Obj/ObjExporter.cpp
)
ADD_ASSIMP_IMPORTER( OGRE ADD_ASSIMP_IMPORTER( OGRE
Ogre/OgreImporter.h Ogre/OgreImporter.h
Ogre/OgreStructs.h Ogre/OgreStructs.h
@ -529,11 +499,6 @@ ADD_ASSIMP_IMPORTER( OPENGEX
OpenGEX/OpenGEXStructs.h OpenGEX/OpenGEXStructs.h
) )
ADD_ASSIMP_EXPORTER( OPENGEX
OpenGEX/OpenGEXExporter.cpp
OpenGEX/OpenGEXExporter.h
)
ADD_ASSIMP_IMPORTER( PLY ADD_ASSIMP_IMPORTER( PLY
Ply/PlyLoader.cpp Ply/PlyLoader.cpp
Ply/PlyLoader.h Ply/PlyLoader.h
@ -541,11 +506,6 @@ ADD_ASSIMP_IMPORTER( PLY
Ply/PlyParser.h Ply/PlyParser.h
) )
ADD_ASSIMP_EXPORTER( PLY
Ply/PlyExporter.cpp
Ply/PlyExporter.h
)
ADD_ASSIMP_IMPORTER( MS3D ADD_ASSIMP_IMPORTER( MS3D
MS3D/MS3DLoader.cpp MS3D/MS3DLoader.cpp
MS3D/MS3DLoader.h MS3D/MS3DLoader.h
@ -635,14 +595,86 @@ ADD_ASSIMP_IMPORTER( FBX
FBX/FBXCommon.h FBX/FBXCommon.h
) )
if (NOT ASSIMP_NO_EXPORT)
ADD_ASSIMP_EXPORTER( OBJ
Obj/ObjExporter.h
Obj/ObjExporter.cpp)
ADD_ASSIMP_EXPORTER( OPENGEX
OpenGEX/OpenGEXExporter.cpp
OpenGEX/OpenGEXExporter.h)
ADD_ASSIMP_EXPORTER( PLY
Ply/PlyExporter.cpp
Ply/PlyExporter.h)
ADD_ASSIMP_EXPORTER( 3DS
3DS/3DSExporter.h
3DS/3DSExporter.cpp)
ADD_ASSIMP_EXPORTER( ASSBIN
Assbin/AssbinExporter.h
Assbin/AssbinExporter.cpp
Assbin/AssbinFileWriter.h
Assbin/AssbinFileWriter.cpp)
ADD_ASSIMP_EXPORTER( ASSXML
Assxml/AssxmlExporter.h
Assxml/AssxmlExporter.cpp
Assxml/AssxmlFileWriter.h
Assxml/AssxmlFileWriter.cpp)
ADD_ASSIMP_EXPORTER(M3D
M3D/M3DExporter.h
M3D/M3DExporter.cpp)
ADD_ASSIMP_EXPORTER(COLLADA
Collada/ColladaExporter.h
Collada/ColladaExporter.cpp)
ADD_ASSIMP_EXPORTER( FBX ADD_ASSIMP_EXPORTER( FBX
FBX/FBXExporter.h FBX/FBXExporter.h
FBX/FBXExporter.cpp FBX/FBXExporter.cpp
FBX/FBXExportNode.h FBX/FBXExportNode.h
FBX/FBXExportNode.cpp FBX/FBXExportNode.cpp
FBX/FBXExportProperty.h FBX/FBXExportProperty.h
FBX/FBXExportProperty.cpp FBX/FBXExportProperty.cpp)
)
ADD_ASSIMP_EXPORTER( STL
STL/STLExporter.h
STL/STLExporter.cpp)
ADD_ASSIMP_EXPORTER( X
X/XFileExporter.h
X/XFileExporter.cpp)
ADD_ASSIMP_EXPORTER( X3D
X3D/X3DExporter.cpp
X3D/X3DExporter.hpp)
ADD_ASSIMP_EXPORTER( GLTF
glTF/glTFExporter.h
glTF/glTFExporter.cpp
glTF2/glTF2Exporter.h
glTF2/glTF2Exporter.cpp)
ADD_ASSIMP_EXPORTER( 3MF
3MF/D3MFExporter.h
3MF/D3MFExporter.cpp)
ADD_ASSIMP_EXPORTER( ASSJSON
Assjson/cencode.c
Assjson/cencode.h
Assjson/json_exporter.cpp
Assjson/mesh_splitter.cpp
Assjson/mesh_splitter.h)
ADD_ASSIMP_EXPORTER( STEP
Step/StepExporter.h
Step/StepExporter.cpp)
endif()
SET( PostProcessing_SRCS SET( PostProcessing_SRCS
PostProcessing/CalcTangentsProcess.cpp PostProcessing/CalcTangentsProcess.cpp
@ -744,11 +776,6 @@ ADD_ASSIMP_IMPORTER( STL
STL/STLLoader.h STL/STLLoader.h
) )
ADD_ASSIMP_EXPORTER( STL
STL/STLExporter.h
STL/STLExporter.cpp
)
ADD_ASSIMP_IMPORTER( TERRAGEN ADD_ASSIMP_IMPORTER( TERRAGEN
Terragen/TerragenLoader.cpp Terragen/TerragenLoader.cpp
Terragen/TerragenLoader.h Terragen/TerragenLoader.h
@ -767,11 +794,6 @@ ADD_ASSIMP_IMPORTER( X
X/XFileParser.h X/XFileParser.h
) )
ADD_ASSIMP_EXPORTER( X
X/XFileExporter.h
X/XFileExporter.cpp
)
ADD_ASSIMP_IMPORTER( X3D ADD_ASSIMP_IMPORTER( X3D
X3D/X3DImporter.cpp X3D/X3DImporter.cpp
X3D/X3DImporter.hpp X3D/X3DImporter.hpp
@ -792,11 +814,6 @@ ADD_ASSIMP_IMPORTER( X3D
X3D/X3DVocabulary.cpp X3D/X3DVocabulary.cpp
) )
ADD_ASSIMP_EXPORTER( X3D
X3D/X3DExporter.cpp
X3D/X3DExporter.hpp
)
ADD_ASSIMP_IMPORTER( GLTF ADD_ASSIMP_IMPORTER( GLTF
glTF/glTFCommon.h glTF/glTFCommon.h
glTF/glTFCommon.cpp glTF/glTFCommon.cpp
@ -814,13 +831,6 @@ ADD_ASSIMP_IMPORTER( GLTF
glTF2/glTF2Importer.h glTF2/glTF2Importer.h
) )
ADD_ASSIMP_EXPORTER( GLTF
glTF/glTFExporter.h
glTF/glTFExporter.cpp
glTF2/glTF2Exporter.h
glTF2/glTF2Exporter.cpp
)
ADD_ASSIMP_IMPORTER( 3MF ADD_ASSIMP_IMPORTER( 3MF
3MF/D3MFImporter.h 3MF/D3MFImporter.h
3MF/D3MFImporter.cpp 3MF/D3MFImporter.cpp
@ -829,11 +839,6 @@ ADD_ASSIMP_IMPORTER( 3MF
3MF/3MFXmlTags.h 3MF/3MFXmlTags.h
) )
ADD_ASSIMP_EXPORTER( 3MF
3MF/D3MFExporter.h
3MF/D3MFExporter.cpp
)
ADD_ASSIMP_IMPORTER( MMD ADD_ASSIMP_IMPORTER( MMD
MMD/MMDCpp14.h MMD/MMDCpp14.h
MMD/MMDImporter.cpp MMD/MMDImporter.cpp
@ -844,14 +849,6 @@ ADD_ASSIMP_IMPORTER( MMD
MMD/MMDVmdParser.h MMD/MMDVmdParser.h
) )
ADD_ASSIMP_EXPORTER( ASSJSON
Assjson/cencode.c
Assjson/cencode.h
Assjson/json_exporter.cpp
Assjson/mesh_splitter.cpp
Assjson/mesh_splitter.h
)
# Workaround for issue #2406 - force problematic large file to be optimized to prevent string table overflow error # Workaround for issue #2406 - force problematic large file to be optimized to prevent string table overflow error
# Used -Os instead of -O2 as previous issues had mentioned, since -Os is roughly speaking -O2, excluding any # Used -Os instead of -O2 as previous issues had mentioned, since -Os is roughly speaking -O2, excluding any
# optimizations that take up extra space. Given that the issue is a string table overflowing, -Os seemed appropriate # optimizations that take up extra space. Given that the issue is a string table overflowing, -Os seemed appropriate
@ -874,11 +871,6 @@ ADD_ASSIMP_IMPORTER( STEP
Importer/StepFile/StepReaderGen.h Importer/StepFile/StepReaderGen.h
) )
ADD_ASSIMP_EXPORTER( STEP
Step/StepExporter.h
Step/StepExporter.cpp
)
if ((NOT ASSIMP_NO_EXPORT) OR (NOT ASSIMP_EXPORTERS_ENABLED STREQUAL "")) if ((NOT ASSIMP_NO_EXPORT) OR (NOT ASSIMP_EXPORTERS_ENABLED STREQUAL ""))
SET( Exporter_SRCS SET( Exporter_SRCS
Common/Exporter.cpp Common/Exporter.cpp
@ -1088,8 +1080,10 @@ ENDIF()
MESSAGE(STATUS "Enabled importer formats:${ASSIMP_IMPORTERS_ENABLED}") MESSAGE(STATUS "Enabled importer formats:${ASSIMP_IMPORTERS_ENABLED}")
MESSAGE(STATUS "Disabled importer formats:${ASSIMP_IMPORTERS_DISABLED}") MESSAGE(STATUS "Disabled importer formats:${ASSIMP_IMPORTERS_DISABLED}")
if (NOT ASSIMP_NO_EXPORT)
MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}") MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}")
MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}") MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}")
endif()
SOURCE_GROUP( include\\assimp FILES ${PUBLIC_HEADERS} ) SOURCE_GROUP( include\\assimp FILES ${PUBLIC_HEADERS} )

View File

@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <limits> #include <limits>
#include <assimp/TinyFormatter.h> #include <assimp/TinyFormatter.h>
#include <assimp/Exceptional.h>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
@ -94,7 +95,10 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene)
bool isNecessary = false; bool isNecessary = false;
for( unsigned int a = 0; a < pScene->mNumMeshes; ++a) for( unsigned int a = 0; a < pScene->mNumMeshes; ++a)
if( pScene->mMeshes[a]->mNumBones > mMaxBoneCount ) if( pScene->mMeshes[a]->mNumBones > mMaxBoneCount )
{
isNecessary = true; isNecessary = true;
break;
}
if( !isNecessary ) if( !isNecessary )
{ {
@ -155,7 +159,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
{ {
// skip if not necessary // skip if not necessary
if( pMesh->mNumBones <= mMaxBoneCount ) if( pMesh->mNumBones <= mMaxBoneCount )
{
return; return;
}
// necessary optimisation: build a list of all affecting bones for each vertex // necessary optimisation: build a list of all affecting bones for each vertex
// TODO: (thom) maybe add a custom allocator here to avoid allocating tens of thousands of small arrays // TODO: (thom) maybe add a custom allocator here to avoid allocating tens of thousands of small arrays
@ -165,8 +171,10 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
{ {
const aiBone* bone = pMesh->mBones[a]; const aiBone* bone = pMesh->mBones[a];
for( unsigned int b = 0; b < bone->mNumWeights; ++b) for( unsigned int b = 0; b < bone->mNumWeights; ++b)
{
vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight)); vertexBones[ bone->mWeights[b].mVertexId ].push_back( BoneWeight( a, bone->mWeights[b].mWeight));
} }
}
unsigned int numFacesHandled = 0; unsigned int numFacesHandled = 0;
std::vector<bool> isFaceHandled( pMesh->mNumFaces, false); std::vector<bool> isFaceHandled( pMesh->mNumFaces, false);
@ -189,7 +197,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
{ {
// skip if the face is already stored in a submesh // skip if the face is already stored in a submesh
if( isFaceHandled[a] ) if( isFaceHandled[a] )
{
continue; continue;
}
const aiFace& face = pMesh->mFaces[a]; const aiFace& face = pMesh->mFaces[a];
// check every vertex if its bones would still fit into the current submesh // check every vertex if its bones would still fit into the current submesh
@ -201,17 +211,27 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
unsigned int boneIndex = vb[c].first; unsigned int boneIndex = vb[c].first;
// if the bone is already used in this submesh, it's ok // if the bone is already used in this submesh, it's ok
if( isBoneUsed[boneIndex] ) if( isBoneUsed[boneIndex] )
{
continue; continue;
}
// if it's not used, yet, we would need to add it. Store its bone index // if it's not used, yet, we would need to add it. Store its bone index
if( std::find( newBonesAtCurrentFace.begin(), newBonesAtCurrentFace.end(), boneIndex) == newBonesAtCurrentFace.end() ) if( std::find( newBonesAtCurrentFace.begin(), newBonesAtCurrentFace.end(), boneIndex) == newBonesAtCurrentFace.end() )
{
newBonesAtCurrentFace.push_back( boneIndex); newBonesAtCurrentFace.push_back( boneIndex);
} }
} }
}
if (newBonesAtCurrentFace.size() > mMaxBoneCount)
{
throw DeadlyImportError("SplitByBoneCountProcess: Single face requires more bones than specified max bone count!");
}
// leave out the face if the new bones required for this face don't fit the bone count limit anymore // leave out the face if the new bones required for this face don't fit the bone count limit anymore
if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount ) if( numBones + newBonesAtCurrentFace.size() > mMaxBoneCount )
{
continue; continue;
}
// mark all new bones as necessary // mark all new bones as necessary
while( !newBonesAtCurrentFace.empty() ) while( !newBonesAtCurrentFace.empty() )
@ -219,7 +239,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
unsigned int newIndex = newBonesAtCurrentFace.back(); unsigned int newIndex = newBonesAtCurrentFace.back();
newBonesAtCurrentFace.pop_back(); // this also avoids the deallocation which comes with a clear() newBonesAtCurrentFace.pop_back(); // this also avoids the deallocation which comes with a clear()
if( isBoneUsed[newIndex] ) if( isBoneUsed[newIndex] )
{
continue; continue;
}
isBoneUsed[newIndex] = true; isBoneUsed[newIndex] = true;
numBones++; numBones++;
@ -237,7 +259,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
// create a new mesh to hold this subset of the source mesh // create a new mesh to hold this subset of the source mesh
aiMesh* newMesh = new aiMesh; aiMesh* newMesh = new aiMesh;
if( pMesh->mName.length > 0 ) if( pMesh->mName.length > 0 )
{
newMesh->mName.Set( format() << pMesh->mName.data << "_sub" << poNewMeshes.size()); newMesh->mName.Set( format() << pMesh->mName.data << "_sub" << poNewMeshes.size());
}
newMesh->mMaterialIndex = pMesh->mMaterialIndex; newMesh->mMaterialIndex = pMesh->mMaterialIndex;
newMesh->mPrimitiveTypes = pMesh->mPrimitiveTypes; newMesh->mPrimitiveTypes = pMesh->mPrimitiveTypes;
poNewMeshes.push_back( newMesh); poNewMeshes.push_back( newMesh);
@ -247,7 +271,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
newMesh->mNumFaces = static_cast<unsigned int>(subMeshFaces.size()); newMesh->mNumFaces = static_cast<unsigned int>(subMeshFaces.size());
newMesh->mVertices = new aiVector3D[newMesh->mNumVertices]; newMesh->mVertices = new aiVector3D[newMesh->mNumVertices];
if( pMesh->HasNormals() ) if( pMesh->HasNormals() )
{
newMesh->mNormals = new aiVector3D[newMesh->mNumVertices]; newMesh->mNormals = new aiVector3D[newMesh->mNumVertices];
}
if( pMesh->HasTangentsAndBitangents() ) if( pMesh->HasTangentsAndBitangents() )
{ {
newMesh->mTangents = new aiVector3D[newMesh->mNumVertices]; newMesh->mTangents = new aiVector3D[newMesh->mNumVertices];
@ -256,14 +282,18 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a ) for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a )
{ {
if( pMesh->HasTextureCoords( a) ) if( pMesh->HasTextureCoords( a) )
{
newMesh->mTextureCoords[a] = new aiVector3D[newMesh->mNumVertices]; newMesh->mTextureCoords[a] = new aiVector3D[newMesh->mNumVertices];
}
newMesh->mNumUVComponents[a] = pMesh->mNumUVComponents[a]; newMesh->mNumUVComponents[a] = pMesh->mNumUVComponents[a];
} }
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a ) for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a )
{ {
if( pMesh->HasVertexColors( a) ) if( pMesh->HasVertexColors( a) )
{
newMesh->mColors[a] = new aiColor4D[newMesh->mNumVertices]; newMesh->mColors[a] = new aiColor4D[newMesh->mNumVertices];
} }
}
// and copy over the data, generating faces with linear indices along the way // and copy over the data, generating faces with linear indices along the way
newMesh->mFaces = new aiFace[subMeshFaces.size()]; newMesh->mFaces = new aiFace[subMeshFaces.size()];
@ -285,7 +315,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
newMesh->mVertices[nvi] = pMesh->mVertices[srcIndex]; newMesh->mVertices[nvi] = pMesh->mVertices[srcIndex];
if( pMesh->HasNormals() ) if( pMesh->HasNormals() )
{
newMesh->mNormals[nvi] = pMesh->mNormals[srcIndex]; newMesh->mNormals[nvi] = pMesh->mNormals[srcIndex];
}
if( pMesh->HasTangentsAndBitangents() ) if( pMesh->HasTangentsAndBitangents() )
{ {
newMesh->mTangents[nvi] = pMesh->mTangents[srcIndex]; newMesh->mTangents[nvi] = pMesh->mTangents[srcIndex];
@ -294,13 +326,17 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c ) for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++c )
{ {
if( pMesh->HasTextureCoords( c) ) if( pMesh->HasTextureCoords( c) )
{
newMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex]; newMesh->mTextureCoords[c][nvi] = pMesh->mTextureCoords[c][srcIndex];
} }
}
for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c ) for( unsigned int c = 0; c < AI_MAX_NUMBER_OF_COLOR_SETS; ++c )
{ {
if( pMesh->HasVertexColors( c) ) if( pMesh->HasVertexColors( c) )
{
newMesh->mColors[c][nvi] = pMesh->mColors[c][srcIndex]; newMesh->mColors[c][nvi] = pMesh->mColors[c][srcIndex];
} }
}
nvi++; nvi++;
} }
@ -316,7 +352,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
for( unsigned int a = 0; a < pMesh->mNumBones; ++a ) for( unsigned int a = 0; a < pMesh->mNumBones; ++a )
{ {
if( !isBoneUsed[a] ) if( !isBoneUsed[a] )
{
continue; continue;
}
// create the new bone // create the new bone
const aiBone* srcBone = pMesh->mBones[a]; const aiBone* srcBone = pMesh->mBones[a];
@ -340,9 +378,11 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
{ {
unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ]; unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ];
if( newBoneIndex != std::numeric_limits<unsigned int>::max() ) if( newBoneIndex != std::numeric_limits<unsigned int>::max() )
{
newMesh->mBones[newBoneIndex]->mNumWeights++; newMesh->mBones[newBoneIndex]->mNumWeights++;
} }
} }
}
// allocate all bone weight arrays accordingly // allocate all bone weight arrays accordingly
for( unsigned int a = 0; a < newMesh->mNumBones; ++a ) for( unsigned int a = 0; a < newMesh->mNumBones; ++a )