Merge branch 'master' into sample-simpleopengl-minor-improvements
commit
673a1dcea5
|
@ -252,15 +252,17 @@ MACRO(ADD_ASSIMP_IMPORTER name)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDMACRO()
|
ENDMACRO()
|
||||||
|
|
||||||
# if this variable is set to TRUE, the user can manually disable exporters by setting
|
if (NOT ASSIMP_NO_EXPORT)
|
||||||
# ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter
|
|
||||||
# if this variable is set to FALSE, the user can manually enable exporters by setting
|
|
||||||
# ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter
|
|
||||||
OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE)
|
|
||||||
|
|
||||||
# macro to add the CMake Option ADD_ASSIMP_IMPORTER_<name> which enables compile of loader
|
# if this variable is set to TRUE, the user can manually disable exporters by setting
|
||||||
# this way selective loaders can be compiled (reduces filesize + compile time)
|
# ASSIMP_BUILD_XXX_EXPORTER to FALSE for each exporter
|
||||||
MACRO(ADD_ASSIMP_EXPORTER name)
|
# if this variable is set to FALSE, the user can manually enable exporters by setting
|
||||||
|
# ASSIMP_BUILD_XXX_EXPORTER to TRUE for each exporter
|
||||||
|
OPTION(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT "default value of all ASSIMP_BUILD_XXX_EXPORTER values" TRUE)
|
||||||
|
|
||||||
|
# macro to add the CMake Option ADD_ASSIMP_IMPORTER_<name> which enables compile of loader
|
||||||
|
# this way selective loaders can be compiled (reduces filesize + compile time)
|
||||||
|
MACRO(ADD_ASSIMP_EXPORTER name)
|
||||||
IF (ASSIMP_NO_EXPORT)
|
IF (ASSIMP_NO_EXPORT)
|
||||||
set(ASSIMP_EXPORTER_ENABLED FALSE)
|
set(ASSIMP_EXPORTER_ENABLED FALSE)
|
||||||
ELSEIF (ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT)
|
ELSEIF (ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT)
|
||||||
|
@ -280,7 +282,9 @@ MACRO(ADD_ASSIMP_EXPORTER name)
|
||||||
SET(ASSIMP_EXPORTERS_DISABLED "${ASSIMP_EXPORTERS_DISABLED} ${name}")
|
SET(ASSIMP_EXPORTERS_DISABLED "${ASSIMP_EXPORTERS_DISABLED} ${name}")
|
||||||
add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER)
|
add_definitions(-DASSIMP_BUILD_NO_${name}_EXPORTER)
|
||||||
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
|
||||||
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
||||||
ADD_ASSIMP_EXPORTER( FBX
|
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
|
||||||
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}")
|
||||||
|
|
||||||
MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}")
|
if (NOT ASSIMP_NO_EXPORT)
|
||||||
MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}")
|
MESSAGE(STATUS "Enabled exporter formats:${ASSIMP_EXPORTERS_ENABLED}")
|
||||||
|
MESSAGE(STATUS "Disabled exporter formats:${ASSIMP_EXPORTERS_DISABLED}")
|
||||||
|
endif()
|
||||||
|
|
||||||
SOURCE_GROUP( include\\assimp FILES ${PUBLIC_HEADERS} )
|
SOURCE_GROUP( include\\assimp FILES ${PUBLIC_HEADERS} )
|
||||||
|
|
||||||
|
|
|
@ -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 )
|
||||||
|
|
|
@ -111,8 +111,9 @@ const aiImporterDesc *glTF2Importer::GetInfo() const {
|
||||||
bool glTF2Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const {
|
bool glTF2Importer::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const {
|
||||||
const std::string &extension = GetExtension(pFile);
|
const std::string &extension = GetExtension(pFile);
|
||||||
|
|
||||||
if (extension != "gltf" && extension != "glb")
|
if (extension != "gltf" && extension != "glb") {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (pIOHandler) {
|
if (pIOHandler) {
|
||||||
glTF2::Asset asset(pIOHandler);
|
glTF2::Asset asset(pIOHandler);
|
||||||
|
@ -323,10 +324,11 @@ static inline bool CheckValidFacesIndices(aiFace *faces, unsigned nFaces, unsign
|
||||||
for (unsigned i = 0; i < nFaces; ++i) {
|
for (unsigned i = 0; i < nFaces; ++i) {
|
||||||
for (unsigned j = 0; j < faces[i].mNumIndices; ++j) {
|
for (unsigned j = 0; j < faces[i].mNumIndices; ++j) {
|
||||||
unsigned idx = faces[i].mIndices[j];
|
unsigned idx = faces[i].mIndices[j];
|
||||||
if (idx >= nVerts)
|
if (idx >= nVerts) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // ASSIMP_BUILD_DEBUG
|
#endif // ASSIMP_BUILD_DEBUG
|
||||||
|
@ -861,7 +863,19 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
if (node.skin) {
|
if (node.skin) {
|
||||||
for (int primitiveNo = 0; primitiveNo < count; ++primitiveNo) {
|
for (int primitiveNo = 0; primitiveNo < count; ++primitiveNo) {
|
||||||
aiMesh *mesh = pScene->mMeshes[meshOffsets[mesh_idx] + primitiveNo];
|
aiMesh *mesh = pScene->mMeshes[meshOffsets[mesh_idx] + primitiveNo];
|
||||||
mesh->mNumBones = static_cast<unsigned int>(node.skin->jointNames.size());
|
unsigned int numBones =static_cast<unsigned int>(node.skin->jointNames.size());
|
||||||
|
|
||||||
|
std::vector<std::vector<aiVertexWeight>> weighting(numBones);
|
||||||
|
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
||||||
|
|
||||||
|
unsigned int realNumBones = 0;
|
||||||
|
for (uint32_t i = 0; i < numBones; ++i) {
|
||||||
|
if (weighting[i].size() > 0) {
|
||||||
|
realNumBones++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh->mNumBones = static_cast<unsigned int>(realNumBones);
|
||||||
mesh->mBones = new aiBone *[mesh->mNumBones];
|
mesh->mBones = new aiBone *[mesh->mNumBones];
|
||||||
|
|
||||||
// GLTF and Assimp choose to store bone weights differently.
|
// GLTF and Assimp choose to store bone weights differently.
|
||||||
|
@ -873,13 +887,14 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
// both because it's somewhat slow and because, for many applications,
|
// both because it's somewhat slow and because, for many applications,
|
||||||
// we then need to reconvert the data back into the vertex-to-bone
|
// we then need to reconvert the data back into the vertex-to-bone
|
||||||
// mapping which makes things doubly-slow.
|
// mapping which makes things doubly-slow.
|
||||||
std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
|
|
||||||
BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
|
|
||||||
|
|
||||||
mat4 *pbindMatrices = nullptr;
|
mat4 *pbindMatrices = nullptr;
|
||||||
node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
|
node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
|
int cb = 0;
|
||||||
|
for (uint32_t i = 0; i < numBones; ++i) {
|
||||||
|
const std::vector<aiVertexWeight> &weights = weighting[i];
|
||||||
|
if (weights.size() > 0) {
|
||||||
aiBone *bone = new aiBone();
|
aiBone *bone = new aiBone();
|
||||||
|
|
||||||
Ref<Node> joint = node.skin->jointNames[i];
|
Ref<Node> joint = node.skin->jointNames[i];
|
||||||
|
@ -893,23 +908,12 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
bone->mName = (kDefaultName + postfix);
|
bone->mName = (kDefaultName + postfix);
|
||||||
}
|
}
|
||||||
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
||||||
|
|
||||||
CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
|
CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
|
||||||
|
|
||||||
std::vector<aiVertexWeight> &weights = weighting[i];
|
|
||||||
|
|
||||||
bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
bone->mNumWeights = static_cast<uint32_t>(weights.size());
|
||||||
if (bone->mNumWeights > 0) {
|
|
||||||
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
||||||
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
||||||
} else {
|
mesh->mBones[cb++] = bone;
|
||||||
// Assimp expects all bones to have at least 1 weight.
|
|
||||||
bone->mWeights = new aiVertexWeight[1];
|
|
||||||
bone->mNumWeights = 1;
|
|
||||||
bone->mWeights->mVertexId = 0;
|
|
||||||
bone->mWeights->mWeight = 0.f;
|
|
||||||
}
|
}
|
||||||
mesh->mBones[i] = bone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pbindMatrices) {
|
if (pbindMatrices) {
|
||||||
|
@ -1232,9 +1236,10 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
||||||
|
|
||||||
int numEmbeddedTexs = 0;
|
int numEmbeddedTexs = 0;
|
||||||
for (size_t i = 0; i < r.images.Size(); ++i) {
|
for (size_t i = 0; i < r.images.Size(); ++i) {
|
||||||
if (r.images[i].HasData())
|
if (r.images[i].HasData()) {
|
||||||
numEmbeddedTexs += 1;
|
numEmbeddedTexs += 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (numEmbeddedTexs == 0)
|
if (numEmbeddedTexs == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -1244,7 +1249,9 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
||||||
// Add the embedded textures
|
// Add the embedded textures
|
||||||
for (size_t i = 0; i < r.images.Size(); ++i) {
|
for (size_t i = 0; i < r.images.Size(); ++i) {
|
||||||
Image &img = r.images[i];
|
Image &img = r.images[i];
|
||||||
if (!img.HasData()) continue;
|
if (!img.HasData()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int idx = mScene->mNumTextures++;
|
int idx = mScene->mNumTextures++;
|
||||||
embeddedTexIdxs[i] = idx;
|
embeddedTexIdxs[i] = idx;
|
||||||
|
|
Loading…
Reference in New Issue