|
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
|
|
|
|
|
Copyright (c) 2006-2022, assimp team
|
|
Copyright (c) 2006-2022, assimp team
|
|
|
|
|
|
-
|
|
|
|
All rights reserved.
|
|
All rights reserved.
|
|
|
|
|
|
Redistribution and use of this software in source and binary forms,
|
|
Redistribution and use of this software in source and binary forms,
|
|
@@ -166,7 +165,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
|
unsigned int 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<unsigned int> subMeshFaces;
|
|
|
|
|
|
+ IndexArray 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
|
|
unsigned int numSubMeshVertices = 0;
|
|
unsigned int numSubMeshVertices = 0;
|
|
@@ -202,7 +201,7 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
|
for (std::set<unsigned int>::iterator it = newBonesAtCurrentFace.begin(); it != newBonesAtCurrentFace.end(); ++it) {
|
|
for (std::set<unsigned int>::iterator it = newBonesAtCurrentFace.begin(); it != newBonesAtCurrentFace.end(); ++it) {
|
|
if (!isBoneUsed[*it]) {
|
|
if (!isBoneUsed[*it]) {
|
|
isBoneUsed[*it] = true;
|
|
isBoneUsed[*it] = true;
|
|
- numBones++;
|
|
|
|
|
|
+ ++numBones;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -212,18 +211,17 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
|
|
|
|
|
// remember that this face is handled
|
|
// remember that this face is handled
|
|
isFaceHandled[a] = true;
|
|
isFaceHandled[a] = true;
|
|
- numFacesHandled++;
|
|
|
|
|
|
+ ++numFacesHandled;
|
|
}
|
|
}
|
|
|
|
|
|
// 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.emplace_back( newMesh);
|
|
|
|
|
|
// 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;
|
|
@@ -251,7 +249,7 @@ 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()];
|
|
unsigned int nvi = 0; // next vertex index
|
|
unsigned int nvi = 0; // next vertex index
|
|
- std::vector<unsigned int> previousVertexIndices( numSubMeshVertices, std::numeric_limits<unsigned int>::max()); // per new vertex: its index in the source mesh
|
|
|
|
|
|
+ IndexArray previousVertexIndices( numSubMeshVertices, std::numeric_limits<unsigned int>::max()); // per new vertex: its index in the source mesh
|
|
for( unsigned int 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];
|
|
@@ -399,10 +397,10 @@ void SplitByBoneCountProcess::SplitMesh( const aiMesh* pMesh, std::vector<aiMesh
|
|
void SplitByBoneCountProcess::UpdateNode( aiNode* pNode) const {
|
|
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<unsigned int> newMeshList;
|
|
|
|
|
|
+ IndexArray newMeshList;
|
|
for( unsigned int a = 0; a < pNode->mNumMeshes; ++a) {
|
|
for( unsigned int a = 0; a < pNode->mNumMeshes; ++a) {
|
|
unsigned int srcIndex = pNode->mMeshes[a];
|
|
unsigned int srcIndex = pNode->mMeshes[a];
|
|
- const std::vector<unsigned int>& replaceMeshes = mSubMeshIndices[srcIndex];
|
|
|
|
|
|
+ const IndexArray& replaceMeshes = mSubMeshIndices[srcIndex];
|
|
newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end());
|
|
newMeshList.insert( newMeshList.end(), replaceMeshes.begin(), replaceMeshes.end());
|
|
}
|
|
}
|
|
|
|
|