fix issue: 3482: invalid gltf2 properties

pull/3636/head
ywang 2021-02-02 13:19:57 -08:00
parent 8d4b816dfe
commit 793bd44cee
2 changed files with 8 additions and 8 deletions

View File

@ -571,7 +571,6 @@ namespace glTF2 {
inline void Write(Value& obj, Node& n, AssetWriter& w)
{
if (n.matrix.isPresent) {
Value val;
obj.AddMember("matrix", MakeValue(val, n.matrix.value, w.mAl).Move(), w.mAl);
@ -597,14 +596,13 @@ namespace glTF2 {
obj.AddMember("mesh", n.meshes[0]->index, w.mAl);
}
AddRefsVector(obj, "skeletons", n.skeletons, w.mAl);
if (n.skin) {
obj.AddMember("skin", n.skin->index, w.mAl);
}
if (!n.jointName.empty()) {
obj.AddMember("jointName", n.jointName, w.mAl);
//gltf2 spec does not support "skeletons" under node
if(n.skeletons.size()) {
AddRefsVector(obj, "skeletons", n.skeletons, w.mAl);
}
}

View File

@ -1095,6 +1095,7 @@ void glTF2Exporter::ExportMeshes()
//----------------------------------------
// Finish the skin
// Create the Accessor for skinRef->inverseBindMatrices
bool bAddCustomizedProperty = this->mProperties->HasPropertyBool("GLTF2_CUSTOMIZE_PROPERTY");
if (createSkin) {
mat4* invBindMatrixData = new mat4[inverseBindMatricesData.size()];
for ( unsigned int idx_joint = 0; idx_joint < inverseBindMatricesData.size(); ++idx_joint) {
@ -1110,7 +1111,7 @@ void glTF2Exporter::ExportMeshes()
// Identity Matrix =====> skinRef->bindShapeMatrix
// Temporary. Hard-coded identity matrix here
skinRef->bindShapeMatrix.isPresent = true;
skinRef->bindShapeMatrix.isPresent = bAddCustomizedProperty;
IdentityMatrix4(skinRef->bindShapeMatrix.value);
// Find nodes that contain a mesh with bones and add "skeletons" and "skin" attributes to those nodes.
@ -1131,6 +1132,7 @@ void glTF2Exporter::ExportMeshes()
std::string meshID = mesh->id;
FindMeshNode(rootNode, meshNode, meshID);
Ref<Node> rootJoint = FindSkeletonRootJoint(skinRef);
if(bAddCustomizedProperty)
meshNode->skeletons.push_back(rootJoint);
meshNode->skin = skinRef;
}