History

modelToWorld rotation not in cluster matrices

Andrew Meadows committed 9 years ago

Commit 44699fc1 parent 0b574e13 files · +17 −26Browse files

Showing the changes to libraries/render-utils/src/Model.cpp (1 of 3 files). Show all

Unified · Split

libraries/render-utils/src/Model.cpp+4−6
@@ -245,7 +245,7 @@ void Model::updateRenderItems() { · 244 unmodified lines
245 245
246 // update the model transform and bounding box for this render item.246 // update the model transform and bounding box for this render item.
247 const Model::MeshState& state = data._model->_meshStates.at(data._meshIndex);247 const Model::MeshState& state = data._model->_meshStates.at(data._meshIndex);
248 data.updateTransformForSkinnedMesh(modelTransform, modelMeshOffset, state.clusterMatrices);248 data.updateTransformForSkinnedMesh(modelTransform, state.clusterMatrices);
249 }249 }
250 }250 }
251 });251 });
@@ -1167,7 +1167,6 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient · 915 unmodified lines
1167 glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));1167 glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
1168 auto cauterizeMatrix = _rig->getJointTransform(geometry.neckJointIndex) * zeroScale;1168 auto cauterizeMatrix = _rig->getJointTransform(geometry.neckJointIndex) * zeroScale;
1169 1169
1170 glm::mat4 modelToWorld = glm::mat4_cast(modelOrientation);
1171 for (int i = 0; i < _meshStates.size(); i++) {1170 for (int i = 0; i < _meshStates.size(); i++) {
1172 MeshState& state = _meshStates[i];1171 MeshState& state = _meshStates[i];
1173 const FBXMesh& mesh = geometry.meshes.at(i);1172 const FBXMesh& mesh = geometry.meshes.at(i);
@@ -1176,11 +1175,10 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient · 2 unmodified lines
1176 auto jointMatrix = _rig->getJointTransform(cluster.jointIndex);1175 auto jointMatrix = _rig->getJointTransform(cluster.jointIndex);
1177#if GLM_ARCH & GLM_ARCH_SSE21176#if GLM_ARCH & GLM_ARCH_SSE2
1178 glm::mat4 temp, out, inverseBindMatrix = cluster.inverseBindMatrix;1177 glm::mat4 temp, out, inverseBindMatrix = cluster.inverseBindMatrix;
1179 glm_mat4_mul((glm_vec4*)&modelToWorld, (glm_vec4*)&jointMatrix, (glm_vec4*)&temp);
1180 glm_mat4_mul((glm_vec4*)&temp, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out);1178 glm_mat4_mul((glm_vec4*)&temp, (glm_vec4*)&inverseBindMatrix, (glm_vec4*)&out);
1181 state.clusterMatrices[j] = out;1179 state.clusterMatrices[j] = out;
1182#else 1180#else
1183 state.clusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;1181 state.clusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix;
1184#endif1182#endif
1185 1183
1186 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.1184 // as an optimization, don't build cautrizedClusterMatrices if the boneSet is empty.
@@ -1188,7 +1186,7 @@ void Model::updateClusterMatrices(glm::vec3 modelPosition, glm::quat modelOrient · 1 unmodified line
1188 if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) {1186 if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) {
1189 jointMatrix = cauterizeMatrix;1187 jointMatrix = cauterizeMatrix;
1190 }1188 }
1191 state.cauterizedClusterMatrices[j] = modelToWorld * jointMatrix * cluster.inverseBindMatrix;1189 state.cauterizedClusterMatrices[j] = jointMatrix * cluster.inverseBindMatrix;
1192 }1190 }
1193 }1191 }
1194 1192