Merge branch 'master' of https://github.com/assimp/assimp
commit
89320bab46
|
@ -67,6 +67,7 @@ namespace AssxmlExport {
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------
|
||||||
static int ioprintf( IOStream * io, const char *format, ... ) {
|
static int ioprintf( IOStream * io, const char *format, ... ) {
|
||||||
|
using namespace std;
|
||||||
if ( nullptr == io ) {
|
if ( nullptr == io ) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ static int ioprintf( IOStream * io, const char *format, ... ) {
|
||||||
::memset( sz, '\0', Size );
|
::memset( sz, '\0', Size );
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start( va, format );
|
va_start( va, format );
|
||||||
int nSize = std::vsnprintf( sz, Size-1, format, va );
|
int nSize = vsnprintf( sz, Size-1, format, va );
|
||||||
ai_assert( nSize < Size );
|
ai_assert( nSize < Size );
|
||||||
va_end( va );
|
va_end( va );
|
||||||
|
|
||||||
|
|
|
@ -596,11 +596,6 @@ namespace STEP {
|
||||||
LazyObject(DB& db, uint64_t id, uint64_t line, const char* type,const char* args);
|
LazyObject(DB& db, uint64_t id, uint64_t line, const char* type,const char* args);
|
||||||
~LazyObject();
|
~LazyObject();
|
||||||
|
|
||||||
LazyObject( LazyObject const& ) = delete;
|
|
||||||
LazyObject operator=( LazyObject const& ) = delete;
|
|
||||||
LazyObject( LazyObject && ) = delete;
|
|
||||||
LazyObject operator=( LazyObject && ) = delete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Object& operator * () {
|
Object& operator * () {
|
||||||
|
|
|
@ -1211,6 +1211,11 @@ void SceneCombiner::Copy (aiNode** _dest, const aiNode* src)
|
||||||
// and reallocate all arrays
|
// and reallocate all arrays
|
||||||
GetArrayCopy( dest->mMeshes, dest->mNumMeshes );
|
GetArrayCopy( dest->mMeshes, dest->mNumMeshes );
|
||||||
CopyPtrArray( dest->mChildren, src->mChildren,dest->mNumChildren);
|
CopyPtrArray( dest->mChildren, src->mChildren,dest->mNumChildren);
|
||||||
|
|
||||||
|
// need to set the mParent fields to the created aiNode.
|
||||||
|
for( unsigned int i = 0; i < dest->mNumChildren; i ++ ) {
|
||||||
|
dest->mChildren[i]->mParent = dest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -90,7 +90,7 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene)
|
||||||
|
|
||||||
// early out
|
// early out
|
||||||
bool isNecessary = false;
|
bool isNecessary = false;
|
||||||
for( size_t 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;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene)
|
||||||
// build a new array of meshes for the scene
|
// build a new array of meshes for the scene
|
||||||
std::vector<aiMesh*> meshes;
|
std::vector<aiMesh*> meshes;
|
||||||
|
|
||||||
for( size_t a = 0; a < pScene->mNumMeshes; ++a)
|
for( unsigned int a = 0; a < pScene->mNumMeshes; ++a)
|
||||||
{
|
{
|
||||||
aiMesh* srcMesh = pScene->mMeshes[a];
|
aiMesh* srcMesh = pScene->mMeshes[a];
|
||||||
|
|
||||||
|
@ -118,9 +118,9 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene)
|
||||||
if( !newMeshes.empty() )
|
if( !newMeshes.empty() )
|
||||||
{
|
{
|
||||||
// store new meshes and indices of the new meshes
|
// store new meshes and indices of the new meshes
|
||||||
for( size_t b = 0; b < newMeshes.size(); ++b)
|
for( unsigned int b = 0; b < newMeshes.size(); ++b)
|
||||||
{
|
{
|
||||||
mSubMeshIndices[a].push_back( meshes.size());
|
mSubMeshIndices[a].push_back( static_cast<unsigned int>(meshes.size()));
|
||||||
meshes.push_back( newMeshes[b]);
|
meshes.push_back( newMeshes[b]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,13 +130,13 @@ void SplitByBoneCountProcess::Execute( aiScene* pScene)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mesh is kept unchanged - store it's new place in the mesh array
|
// Mesh is kept unchanged - store it's new place in the mesh array
|
||||||
mSubMeshIndices[a].push_back( meshes.size());
|
mSubMeshIndices[a].push_back( static_cast<unsigned int>(meshes.size()));
|
||||||
meshes.push_back( srcMesh);
|
meshes.push_back( srcMesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rebuild the scene's mesh array
|
// rebuild the scene's mesh array
|
||||||
pScene->mNumMeshes = meshes.size();
|
pScene->mNumMeshes = static_cast<unsigned int>(meshes.size());
|
||||||
delete [] pScene->mMeshes;
|
delete [] pScene->mMeshes;
|
||||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];
|
||||||
std::copy( meshes.begin(), meshes.end(), pScene->mMeshes);
|
std::copy( meshes.begin(), meshes.end(), pScene->mMeshes);
|
||||||
|
@ -157,33 +157,33 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
|
|
||||||
// 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
|
||||||
typedef std::pair<size_t, float> BoneWeight;
|
typedef std::pair<unsigned int, float> BoneWeight;
|
||||||
std::vector< std::vector<BoneWeight> > vertexBones( pMesh->mNumVertices);
|
std::vector< std::vector<BoneWeight> > vertexBones( pMesh->mNumVertices);
|
||||||
for( size_t a = 0; a < pMesh->mNumBones; ++a)
|
for( unsigned int a = 0; a < pMesh->mNumBones; ++a)
|
||||||
{
|
{
|
||||||
const aiBone* bone = pMesh->mBones[a];
|
const aiBone* bone = pMesh->mBones[a];
|
||||||
for( size_t 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numFacesHandled = 0;
|
unsigned int numFacesHandled = 0;
|
||||||
std::vector<bool> isFaceHandled( pMesh->mNumFaces, false);
|
std::vector<bool> isFaceHandled( pMesh->mNumFaces, false);
|
||||||
while( numFacesHandled < pMesh->mNumFaces )
|
while( numFacesHandled < pMesh->mNumFaces )
|
||||||
{
|
{
|
||||||
// which bones are used in the current submesh
|
// which bones are used in the current submesh
|
||||||
size_t numBones = 0;
|
unsigned int numBones = 0;
|
||||||
std::vector<bool> isBoneUsed( pMesh->mNumBones, false);
|
std::vector<bool> isBoneUsed( pMesh->mNumBones, false);
|
||||||
// indices of the faces which are going to go into this submesh
|
// indices of the faces which are going to go into this submesh
|
||||||
std::vector<size_t> subMeshFaces;
|
std::vector<unsigned int> subMeshFaces;
|
||||||
subMeshFaces.reserve( pMesh->mNumFaces);
|
subMeshFaces.reserve( pMesh->mNumFaces);
|
||||||
// accumulated vertex count of all the faces in this submesh
|
// accumulated vertex count of all the faces in this submesh
|
||||||
size_t numSubMeshVertices = 0;
|
unsigned int numSubMeshVertices = 0;
|
||||||
// a small local array of new bones for the current face. State of all used bones for that face
|
// a small local array of new bones for the current face. State of all used bones for that face
|
||||||
// can only be updated AFTER the face is completely analysed. Thanks to imre for the fix.
|
// can only be updated AFTER the face is completely analysed. Thanks to imre for the fix.
|
||||||
std::vector<size_t> newBonesAtCurrentFace;
|
std::vector<unsigned int> newBonesAtCurrentFace;
|
||||||
|
|
||||||
// add faces to the new submesh as long as all bones affecting the faces' vertices fit in the limit
|
// add faces to the new submesh as long as all bones affecting the faces' vertices fit in the limit
|
||||||
for( size_t a = 0; a < pMesh->mNumFaces; ++a)
|
for( unsigned int a = 0; a < pMesh->mNumFaces; ++a)
|
||||||
{
|
{
|
||||||
// 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] )
|
||||||
|
@ -191,12 +191,12 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
|
|
||||||
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
|
||||||
for( size_t b = 0; b < face.mNumIndices; ++b )
|
for( unsigned int b = 0; b < face.mNumIndices; ++b )
|
||||||
{
|
{
|
||||||
const std::vector<BoneWeight>& vb = vertexBones[face.mIndices[b]];
|
const std::vector<BoneWeight>& vb = vertexBones[face.mIndices[b]];
|
||||||
for( size_t c = 0; c < vb.size(); ++c)
|
for( unsigned int c = 0; c < vb.size(); ++c)
|
||||||
{
|
{
|
||||||
size_t 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;
|
||||||
|
@ -214,7 +214,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
// mark all new bones as necessary
|
// mark all new bones as necessary
|
||||||
while( !newBonesAtCurrentFace.empty() )
|
while( !newBonesAtCurrentFace.empty() )
|
||||||
{
|
{
|
||||||
size_t 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;
|
||||||
|
@ -242,7 +242,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
|
|
||||||
// create all the arrays for this mesh if the old mesh contained them
|
// create all the arrays for this mesh if the old mesh contained them
|
||||||
newMesh->mNumVertices = numSubMeshVertices;
|
newMesh->mNumVertices = numSubMeshVertices;
|
||||||
newMesh->mNumFaces = 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];
|
||||||
|
@ -251,13 +251,13 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
newMesh->mTangents = new aiVector3D[newMesh->mNumVertices];
|
newMesh->mTangents = new aiVector3D[newMesh->mNumVertices];
|
||||||
newMesh->mBitangents = new aiVector3D[newMesh->mNumVertices];
|
newMesh->mBitangents = new aiVector3D[newMesh->mNumVertices];
|
||||||
}
|
}
|
||||||
for( size_t 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( size_t 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];
|
||||||
|
@ -265,9 +265,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
|
|
||||||
// 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()];
|
||||||
size_t nvi = 0; // next vertex index
|
unsigned int nvi = 0; // next vertex index
|
||||||
std::vector<size_t> previousVertexIndices( numSubMeshVertices, std::numeric_limits<size_t>::max()); // per new vertex: its index in the source mesh
|
std::vector<unsigned int> previousVertexIndices( numSubMeshVertices, std::numeric_limits<unsigned int>::max()); // per new vertex: its index in the source mesh
|
||||||
for( size_t a = 0; a < subMeshFaces.size(); ++a )
|
for( unsigned int a = 0; a < subMeshFaces.size(); ++a )
|
||||||
{
|
{
|
||||||
const aiFace& srcFace = pMesh->mFaces[subMeshFaces[a]];
|
const aiFace& srcFace = pMesh->mFaces[subMeshFaces[a]];
|
||||||
aiFace& dstFace = newMesh->mFaces[a];
|
aiFace& dstFace = newMesh->mFaces[a];
|
||||||
|
@ -275,9 +275,9 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
dstFace.mIndices = new unsigned int[dstFace.mNumIndices];
|
dstFace.mIndices = new unsigned int[dstFace.mNumIndices];
|
||||||
|
|
||||||
// accumulate linearly all the vertices of the source face
|
// accumulate linearly all the vertices of the source face
|
||||||
for( size_t b = 0; b < dstFace.mNumIndices; ++b )
|
for( unsigned int b = 0; b < dstFace.mNumIndices; ++b )
|
||||||
{
|
{
|
||||||
size_t srcIndex = srcFace.mIndices[b];
|
unsigned int srcIndex = srcFace.mIndices[b];
|
||||||
dstFace.mIndices[b] = nvi;
|
dstFace.mIndices[b] = nvi;
|
||||||
previousVertexIndices[nvi] = srcIndex;
|
previousVertexIndices[nvi] = srcIndex;
|
||||||
|
|
||||||
|
@ -289,12 +289,12 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
newMesh->mTangents[nvi] = pMesh->mTangents[srcIndex];
|
newMesh->mTangents[nvi] = pMesh->mTangents[srcIndex];
|
||||||
newMesh->mBitangents[nvi] = pMesh->mBitangents[srcIndex];
|
newMesh->mBitangents[nvi] = pMesh->mBitangents[srcIndex];
|
||||||
}
|
}
|
||||||
for( size_t 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( size_t 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];
|
||||||
|
@ -310,8 +310,8 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
newMesh->mNumBones = 0;
|
newMesh->mNumBones = 0;
|
||||||
newMesh->mBones = new aiBone*[numBones];
|
newMesh->mBones = new aiBone*[numBones];
|
||||||
|
|
||||||
std::vector<size_t> mappedBoneIndex( pMesh->mNumBones, std::numeric_limits<size_t>::max());
|
std::vector<unsigned int> mappedBoneIndex( pMesh->mNumBones, std::numeric_limits<unsigned int>::max());
|
||||||
for( size_t a = 0; a < pMesh->mNumBones; ++a )
|
for( unsigned int a = 0; a < pMesh->mNumBones; ++a )
|
||||||
{
|
{
|
||||||
if( !isBoneUsed[a] )
|
if( !isBoneUsed[a] )
|
||||||
continue;
|
continue;
|
||||||
|
@ -329,21 +329,21 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
ai_assert( newMesh->mNumBones == numBones );
|
ai_assert( newMesh->mNumBones == numBones );
|
||||||
|
|
||||||
// iterate over all new vertices and count which bones affected its old vertex in the source mesh
|
// iterate over all new vertices and count which bones affected its old vertex in the source mesh
|
||||||
for( size_t a = 0; a < numSubMeshVertices; ++a )
|
for( unsigned int a = 0; a < numSubMeshVertices; ++a )
|
||||||
{
|
{
|
||||||
size_t oldIndex = previousVertexIndices[a];
|
unsigned int oldIndex = previousVertexIndices[a];
|
||||||
const std::vector<BoneWeight>& bonesOnThisVertex = vertexBones[oldIndex];
|
const std::vector<BoneWeight>& bonesOnThisVertex = vertexBones[oldIndex];
|
||||||
|
|
||||||
for( size_t b = 0; b < bonesOnThisVertex.size(); ++b )
|
for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b )
|
||||||
{
|
{
|
||||||
size_t newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ];
|
unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ];
|
||||||
if( newBoneIndex != std::numeric_limits<size_t>::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( size_t a = 0; a < newMesh->mNumBones; ++a )
|
for( unsigned int a = 0; a < newMesh->mNumBones; ++a )
|
||||||
{
|
{
|
||||||
aiBone* bone = newMesh->mBones[a];
|
aiBone* bone = newMesh->mBones[a];
|
||||||
ai_assert( bone->mNumWeights > 0 );
|
ai_assert( bone->mNumWeights > 0 );
|
||||||
|
@ -352,18 +352,18 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
||||||
}
|
}
|
||||||
|
|
||||||
// now copy all the bone vertex weights for all the vertices which made it into the new submesh
|
// now copy all the bone vertex weights for all the vertices which made it into the new submesh
|
||||||
for( size_t a = 0; a < numSubMeshVertices; ++a)
|
for( unsigned int a = 0; a < numSubMeshVertices; ++a)
|
||||||
{
|
{
|
||||||
// find the source vertex for it in the source mesh
|
// find the source vertex for it in the source mesh
|
||||||
size_t previousIndex = previousVertexIndices[a];
|
unsigned int previousIndex = previousVertexIndices[a];
|
||||||
// these bones were affecting it
|
// these bones were affecting it
|
||||||
const std::vector<BoneWeight>& bonesOnThisVertex = vertexBones[previousIndex];
|
const std::vector<BoneWeight>& bonesOnThisVertex = vertexBones[previousIndex];
|
||||||
// all of the bones affecting it should be present in the new submesh, or else
|
// all of the bones affecting it should be present in the new submesh, or else
|
||||||
// the face it comprises shouldn't be present
|
// the face it comprises shouldn't be present
|
||||||
for( size_t b = 0; b < bonesOnThisVertex.size(); ++b)
|
for( unsigned int b = 0; b < bonesOnThisVertex.size(); ++b)
|
||||||
{
|
{
|
||||||
size_t newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ];
|
unsigned int newBoneIndex = mappedBoneIndex[ bonesOnThisVertex[b].first ];
|
||||||
ai_assert( newBoneIndex != std::numeric_limits<size_t>::max() );
|
ai_assert( newBoneIndex != std::numeric_limits<unsigned int>::max() );
|
||||||
aiVertexWeight* dstWeight = newMesh->mBones[newBoneIndex]->mWeights + newMesh->mBones[newBoneIndex]->mNumWeights;
|
aiVertexWeight* dstWeight = newMesh->mBones[newBoneIndex]->mWeights + newMesh->mBones[newBoneIndex]->mNumWeights;
|
||||||
newMesh->mBones[newBoneIndex]->mNumWeights++;
|
newMesh->mBones[newBoneIndex]->mNumWeights++;
|
||||||
|
|
||||||
|
@ -383,22 +383,22 @@ void SplitByBoneCountProcess::UpdateNode( aiNode* pNode) const
|
||||||
// rebuild the node's mesh index list
|
// rebuild the node's mesh index list
|
||||||
if( pNode->mNumMeshes > 0 )
|
if( pNode->mNumMeshes > 0 )
|
||||||
{
|
{
|
||||||
std::vector<size_t> newMeshList;
|
std::vector<unsigned int> newMeshList;
|
||||||
for( size_t a = 0; a < pNode->mNumMeshes; ++a)
|
for( unsigned int a = 0; a < pNode->mNumMeshes; ++a)
|
||||||
{
|
{
|
||||||
size_t srcIndex = pNode->mMeshes[a];
|
unsigned int srcIndex = pNode->mMeshes[a];
|
||||||
const std::vector<size_t>& replaceMeshes = mSubMeshIndices[srcIndex];
|
const std::vector<unsigned int>& replaceMeshes = mSubMeshIndices[srcIndex];
|
||||||
newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end());
|
newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pNode->mMeshes;
|
delete pNode->mMeshes;
|
||||||
pNode->mNumMeshes = newMeshList.size();
|
pNode->mNumMeshes = static_cast<unsigned int>(newMeshList.size());
|
||||||
pNode->mMeshes = new unsigned int[pNode->mNumMeshes];
|
pNode->mMeshes = new unsigned int[pNode->mNumMeshes];
|
||||||
std::copy( newMeshList.begin(), newMeshList.end(), pNode->mMeshes);
|
std::copy( newMeshList.begin(), newMeshList.end(), pNode->mMeshes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do that also recursively for all children
|
// do that also recursively for all children
|
||||||
for( size_t a = 0; a < pNode->mNumChildren; ++a )
|
for( unsigned int a = 0; a < pNode->mNumChildren; ++a )
|
||||||
{
|
{
|
||||||
UpdateNode( pNode->mChildren[a]);
|
UpdateNode( pNode->mChildren[a]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public:
|
||||||
size_t mMaxBoneCount;
|
size_t mMaxBoneCount;
|
||||||
|
|
||||||
/// Per mesh index: Array of indices of the new submeshes.
|
/// Per mesh index: Array of indices of the new submeshes.
|
||||||
std::vector< std::vector<size_t> > mSubMeshIndices;
|
std::vector< std::vector<unsigned int> > mSubMeshIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
|
@ -759,6 +759,7 @@ namespace glTF
|
||||||
virtual void WriteObjects(AssetWriter& writer) = 0;
|
virtual void WriteObjects(AssetWriter& writer) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class LazyDict;
|
class LazyDict;
|
||||||
|
|
||||||
|
@ -766,6 +767,7 @@ namespace glTF
|
||||||
template<class T>
|
template<class T>
|
||||||
void WriteLazyDict(LazyDict<T>& d, AssetWriter& w);
|
void WriteLazyDict(LazyDict<T>& d, AssetWriter& w);
|
||||||
|
|
||||||
|
|
||||||
//! Manages lazy loading of the glTF top-level objects, and keeps a reference to them by ID
|
//! Manages lazy loading of the glTF top-level objects, and keeps a reference to them by ID
|
||||||
//! It is the owner the loaded objects, so when it is destroyed it also deletes them
|
//! It is the owner the loaded objects, so when it is destroyed it also deletes them
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
|
@ -305,7 +305,7 @@ namespace glTF {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AssetWriter::AssetWriter(Asset& a)
|
inline AssetWriter::AssetWriter(Asset& a)
|
||||||
: mDoc()
|
: mDoc()
|
||||||
, mAsset(a)
|
, mAsset(a)
|
||||||
, mAl(mDoc.GetAllocator())
|
, mAl(mDoc.GetAllocator())
|
||||||
|
@ -326,7 +326,7 @@ namespace glTF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetWriter::WriteFile(const char* path)
|
inline void AssetWriter::WriteFile(const char* path)
|
||||||
{
|
{
|
||||||
bool isBinary = mAsset.extensionsUsed.KHR_binary_glTF;
|
bool isBinary = mAsset.extensionsUsed.KHR_binary_glTF;
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ namespace glTF {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetWriter::WriteBinaryData(IOStream* outfile, size_t sceneLength)
|
inline void AssetWriter::WriteBinaryData(IOStream* outfile, size_t sceneLength)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// write the body data
|
// write the body data
|
||||||
|
@ -413,7 +413,7 @@ namespace glTF {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AssetWriter::WriteMetadata()
|
inline void AssetWriter::WriteMetadata()
|
||||||
{
|
{
|
||||||
Value asset;
|
Value asset;
|
||||||
asset.SetObject();
|
asset.SetObject();
|
||||||
|
@ -425,7 +425,7 @@ namespace glTF {
|
||||||
mDoc.AddMember("asset", asset, mAl);
|
mDoc.AddMember("asset", asset, mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetWriter::WriteExtensionsUsed()
|
inline void AssetWriter::WriteExtensionsUsed()
|
||||||
{
|
{
|
||||||
Value exts;
|
Value exts;
|
||||||
exts.SetArray();
|
exts.SetArray();
|
||||||
|
|
|
@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||||
|
|
||||||
#include "glTFExporter.h"
|
#include "glTFExporter.h"
|
||||||
|
|
||||||
#include "Exceptional.h"
|
#include "Exceptional.h"
|
||||||
#include "StringComparison.h"
|
#include "StringComparison.h"
|
||||||
#include "ByteSwapper.h"
|
#include "ByteSwapper.h"
|
||||||
|
@ -54,7 +55,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "glTFAssetWriter.h"
|
#include "glTFAssetWriter.h"
|
||||||
|
|
|
@ -53,6 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "MakeVerboseFormat.h"
|
#include "MakeVerboseFormat.h"
|
||||||
|
|
||||||
#include "glTFAsset.h"
|
#include "glTFAsset.h"
|
||||||
|
// This is included here so WriteLazyDict<T>'s definition is found.
|
||||||
|
#include "glTFAssetWriter.h"
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace glTF;
|
using namespace glTF;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue