Fix failed assimp validation for glTF2 sample animations
parent
d7eae5bb13
commit
bb9e3c3593
|
@ -826,7 +826,15 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
|||
aiBone* bone = new aiBone();
|
||||
|
||||
Ref<Node> joint = node.skin->jointNames[i];
|
||||
if (!joint->name.empty()) {
|
||||
bone->mName = joint->name;
|
||||
} else {
|
||||
// Assimp expects each bone to have a unique name.
|
||||
static const std::string kDefaultName = "bone_";
|
||||
char postfix[10] = {0};
|
||||
ASSIMP_itoa10(postfix, i);
|
||||
bone->mName = (kDefaultName + postfix);
|
||||
}
|
||||
GetNodeTransform(bone->mOffsetMatrix, *joint);
|
||||
|
||||
std::vector<aiVertexWeight>& weights = weighting[i];
|
||||
|
@ -835,6 +843,12 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
|
|||
if (bone->mNumWeights > 0) {
|
||||
bone->mWeights = new aiVertexWeight[bone->mNumWeights];
|
||||
memcpy(bone->mWeights, weights.data(), bone->mNumWeights * sizeof(aiVertexWeight));
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue