Showing the changes to libraries/render-utils/src/Model.cpp (1 of 6 files). Show all
Unified · Split
| @@ -275,7 +275,17 @@ void Model::updateRenderItems() { · 274 unmodified lines | ||
| 275 | 275 | data.updateClusterBuffer(clusterMatrices); |
| 276 | 276 | Transform renderTransform = modelTransform; |
| 277 | 277 | if (clusterMatrices.size() == 1) { |
| 278 | +#ifdef SKIN_MATRIX | |
| 279 | + SKIN_ASSERT(false); | |
| 278 | 280 | renderTransform = modelTransform.worldTransform(Transform(clusterMatrices[0])); |
| 281 | +#endif | |
| 282 | +#ifdef SKIN_COMP | |
| 283 | + glm::vec3 scale(clusterMatrices[0][0]); | |
| 284 | + glm::quat rot(clusterMatrices[0][1].w, clusterMatrices[0][1].x, clusterMatrices[0][1].y, clusterMatrices[0][1].z); | |
| 285 | + glm::vec3 trans(clusterMatrices[0][2]); | |
| 286 | + glm::mat4 m = createMatFromScaleQuatAndPos(scale, rot, trans); | |
| 287 | + renderTransform = modelTransform.worldTransform(Transform(m)); | |
| 288 | +#endif | |
| 279 | 289 | } |
| 280 | 290 | data.updateTransformForSkinnedMesh(renderTransform, modelTransform); |
| 281 | 291 | |
| @@ -1178,15 +1188,14 @@ void Model::updateClusterMatrices() { · 896 unmodified lines | ||
| 1178 | 1188 | for (int j = 0; j < mesh.clusters.size(); j++) { |
| 1179 | 1189 | const FBXCluster& cluster = mesh.clusters.at(j); |
| 1180 | 1190 | |
| 1181 | − // AJT: TODO REMOVE | |
| 1182 | − /* | |
| 1191 | + // AJT: TODO FIXME | |
| 1192 | +#ifdef SKIN_MATRIX | |
| 1193 | + SKIN_ASSERT(false); | |
| 1183 | 1194 | auto jointMatrix = _rig.getJointTransform(cluster.jointIndex); |
| 1184 | 1195 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]); |
| 1185 | − */ | |
| 1196 | +#endif | |
| 1197 | +#ifdef SKIN_COMP | |
| 1186 | 1198 | AnimPose jointPose = _rig.getJointPose(cluster.jointIndex); |
| 1187 | − | |
| 1188 | − // AJT: TODO: store inverseBindMatrix as an animpose | |
| 1189 | − // AJT: TODO: optimize AnimPose::operator* | |
| 1190 | 1199 | AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix); |
| 1191 | 1200 | |
| 1192 | 1201 | // pack scale rotation and translation into a mat4. |
| @@ -1194,15 +1203,15 @@ void Model::updateClusterMatrices() { · 1 unmodified line | ||
| 1194 | 1203 | state.clusterMatrices[j][0].y = result.scale().y; |
| 1195 | 1204 | state.clusterMatrices[j][0].z = result.scale().z; |
| 1196 | 1205 | |
| 1197 | − DualQuaternion dq(result.rot(), result.trans()); | |
| 1198 | − state.clusterMatrices[j][1].x = dq.real().x; | |
| 1199 | − state.clusterMatrices[j][1].y = dq.real().y; | |
| 1200 | − state.clusterMatrices[j][1].z = dq.real().z; | |
| 1201 | − state.clusterMatrices[j][1].w = dq.real().w; | |
| 1202 | − state.clusterMatrices[j][2].x = dq.imag().x; | |
| 1203 | − state.clusterMatrices[j][2].y = dq.imag().y; | |
| 1204 | − state.clusterMatrices[j][2].z = dq.imag().z; | |
| 1205 | − state.clusterMatrices[j][2].w = dq.imag().w; | |
| 1206 | + state.clusterMatrices[j][1].x = result.rot().x; | |
| 1207 | + state.clusterMatrices[j][1].y = result.rot().y; | |
| 1208 | + state.clusterMatrices[j][1].z = result.rot().z; | |
| 1209 | + state.clusterMatrices[j][1].w = result.rot().w; | |
| 1210 | + | |
| 1211 | + state.clusterMatrices[j][2].x = result.trans().x; | |
| 1212 | + state.clusterMatrices[j][2].y = result.trans().y; | |
| 1213 | + state.clusterMatrices[j][2].z = result.trans().z; | |
| 1214 | +#endif | |
| 1206 | 1215 | } |
| 1207 | 1216 | } |
| 1208 | 1217 | |