Feature: Utilizes removeEmptyBones flag for Collada
parent
67fe6643c3
commit
1b53f41787
|
@ -59,6 +59,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
|
@ -102,6 +104,7 @@ ColladaLoader::ColladaLoader() :
|
||||||
mTextures(),
|
mTextures(),
|
||||||
mAnims(),
|
mAnims(),
|
||||||
noSkeletonMesh(false),
|
noSkeletonMesh(false),
|
||||||
|
removeEmptyBones(false),
|
||||||
ignoreUpDirection(false),
|
ignoreUpDirection(false),
|
||||||
useColladaName(false),
|
useColladaName(false),
|
||||||
mNodeNameCounter(0) {
|
mNodeNameCounter(0) {
|
||||||
|
@ -130,6 +133,7 @@ bool ColladaLoader::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void ColladaLoader::SetupProperties(const Importer *pImp) {
|
void ColladaLoader::SetupProperties(const Importer *pImp) {
|
||||||
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES, 0) != 0;
|
noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES, 0) != 0;
|
||||||
|
removeEmptyBones = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES, true) != 0;
|
||||||
ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION, 0) != 0;
|
ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION, 0) != 0;
|
||||||
useColladaName = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES, 0) != 0;
|
useColladaName = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES, 0) != 0;
|
||||||
}
|
}
|
||||||
|
@ -798,9 +802,11 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
|
||||||
// count the number of bones which influence vertices of the current submesh
|
// count the number of bones which influence vertices of the current submesh
|
||||||
size_t numRemainingBones = 0;
|
size_t numRemainingBones = 0;
|
||||||
for (const auto & dstBone : dstBones) {
|
for (const auto & dstBone : dstBones) {
|
||||||
if (!dstBone.empty()) {
|
if (dstBone.empty() && removeEmptyBones) {
|
||||||
++numRemainingBones;
|
continue;
|
||||||
}
|
}
|
||||||
|
++numRemainingBones;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create bone array and copy bone weights one by one
|
// create bone array and copy bone weights one by one
|
||||||
|
@ -809,7 +815,7 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
|
||||||
size_t boneCount = 0;
|
size_t boneCount = 0;
|
||||||
for (size_t a = 0; a < numBones; ++a) {
|
for (size_t a = 0; a < numBones; ++a) {
|
||||||
// omit bones without weights
|
// omit bones without weights
|
||||||
if (dstBones[a].empty()) {
|
if (dstBones[a].empty() && removeEmptyBones) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,6 +834,7 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
|
||||||
bone->mOffsetMatrix.c2 = ReadFloat(jointMatrixAcc, jointMatrices, a, 9);
|
bone->mOffsetMatrix.c2 = ReadFloat(jointMatrixAcc, jointMatrices, a, 9);
|
||||||
bone->mOffsetMatrix.c3 = ReadFloat(jointMatrixAcc, jointMatrices, a, 10);
|
bone->mOffsetMatrix.c3 = ReadFloat(jointMatrixAcc, jointMatrices, a, 10);
|
||||||
bone->mOffsetMatrix.c4 = ReadFloat(jointMatrixAcc, jointMatrices, a, 11);
|
bone->mOffsetMatrix.c4 = ReadFloat(jointMatrixAcc, jointMatrices, a, 11);
|
||||||
|
|
||||||
bone->mNumWeights = static_cast<unsigned int>(dstBones[a].size());
|
bone->mNumWeights = static_cast<unsigned int>(dstBones[a].size());
|
||||||
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
||||||
std::copy(dstBones[a].begin(), dstBones[a].end(), bone->mWeights);
|
std::copy(dstBones[a].begin(), dstBones[a].end(), bone->mWeights);
|
||||||
|
@ -1826,3 +1833,4 @@ std::string ColladaLoader::FindNameForNode(const Node *pNode) {
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_DAE_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_DAE_IMPORTER
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue