It makes more sense for joint.globalTransform to have the hfmModel.offset applied

This commit is contained in:
sabrina-shanman 2019-10-29 17:25:38 -07:00
parent 28e3fd4bc4
commit 3c078eeef6
3 changed files with 5 additions and 5 deletions

View file

@ -1362,8 +1362,8 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
joint.localTransform = glm::translate(joint.translation) * joint.preTransform * glm::mat4_cast(combinedRotation) * joint.postTransform;
if (joint.parentIndex == -1) {
joint.transform = hfmModel.offset * joint.localTransform;
joint.globalTransform = joint.localTransform;
joint.transform = joint.localTransform;
joint.globalTransform = hfmModel.offset * joint.localTransform;
joint.inverseDefaultRotation = glm::inverse(combinedRotation);
joint.distanceToParent = 0.0f;
} else {

View file

@ -1015,7 +1015,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::VariantHash&
joint.transform = parentJoint.transform * joint.transform;
joint.globalTransform = joint.globalTransform * parentJoint.globalTransform;
} else {
joint.transform = hfmModel.offset * joint.transform;
joint.transform = joint.transform;
joint.globalTransform = hfmModel.offset * joint.globalTransform;
}

View file

@ -43,13 +43,13 @@ void calculateExtentsForShape(hfm::Shape& shape, const std::vector<hfm::Mesh>& m
const auto& mesh = meshes[shape.mesh];
const auto& meshPart = mesh.parts[shape.meshPart];
glm::mat4 globalTransform = joints[shape.joint].globalTransform;
glm::mat4 transform = joints[shape.joint].transform;
forEachIndex(meshPart, [&](int32_t idx){
if (mesh.vertices.size() <= idx) {
return;
}
const glm::vec3& vertex = mesh.vertices[idx];
const glm::vec3 transformedVertex = glm::vec3(globalTransform * glm::vec4(vertex, 1.0f));
const glm::vec3 transformedVertex = glm::vec3(transform * glm::vec4(vertex, 1.0f));
shapeExtents.addPoint(transformedVertex);
});