Showing the changes to libraries/render-utils/src/CauterizedModel.cpp (1 of 5 files). Show all
Unified · Split
| @@ -113,12 +113,7 @@ void CauterizedModel::updateClusterMatrices() { · 112 unmodified lines | |||
| 113 | for (int i = 0; i < (int)_meshStates.size(); i++) { | 113 | for (int i = 0; i < (int)_meshStates.size(); i++) { |
| 114 | Model::MeshState& state = _meshStates[i]; | 114 | Model::MeshState& state = _meshStates[i]; |
| 115 | const FBXMesh& mesh = geometry.meshes.at(i); | 115 | const FBXMesh& mesh = geometry.meshes.at(i); |
| 116 | #if defined(SKIN_DQ) | ||
| 117 | // HACK: FOR DQ go thru reverse order! | ||
| 118 | for (int j = mesh.clusters.size() - 1; j >= 0; j--) { | ||
| 119 | #else | ||
| 120 | for (int j = 0; j < mesh.clusters.size(); j++) { | 116 | for (int j = 0; j < mesh.clusters.size(); j++) { |
| 121 | #endif | ||
| 122 | const FBXCluster& cluster = mesh.clusters.at(j); | 117 | const FBXCluster& cluster = mesh.clusters.at(j); |
| 123 | 118 | ||
| 124 | auto jointMatrix = _rig.getJointTransform(cluster.jointIndex); | 119 | auto jointMatrix = _rig.getJointTransform(cluster.jointIndex); |
| @@ -132,25 +127,6 @@ void CauterizedModel::updateClusterMatrices() { · 7 unmodified lines | |||
| 132 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, m); | 127 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, m); |
| 133 | AnimPose p(m); | 128 | AnimPose p(m); |
| 134 | state.clusterTransforms[j] = Model::TransformDualQuaternion(m); | 129 | state.clusterTransforms[j] = Model::TransformDualQuaternion(m); |
| 135 | |||
| 136 | // AJT: HACK n^2!!!! fix me, find parent clusterTransform. | ||
| 137 | int parentIndex = _rig.getJointParentIndex(cluster.jointIndex); | ||
| 138 | int parentClusterIndex = -1; | ||
| 139 | // scan for parent! | ||
| 140 | for (int ii = mesh.clusters.size() - 1; ii > j; ii--) { | ||
| 141 | if (mesh.clusters[ii].jointIndex == parentIndex) { | ||
| 142 | parentClusterIndex = ii; | ||
| 143 | break; | ||
| 144 | } | ||
| 145 | } | ||
| 146 | |||
| 147 | // ensure that we have the same polarity as our parent! | ||
| 148 | if (parentClusterIndex >= 0) { | ||
| 149 | //if (state.clusterTransforms[parentClusterIndex]._dq.dot(state.clusterTransforms[j]._dq) < 0.0f) { | ||
| 150 | if (glm::dot(state.clusterTransforms[parentClusterIndex]._dq.real(), state.clusterTransforms[j]._dq.real()) < 0.0f) { | ||
| 151 | state.clusterTransforms[j]._dq = -state.clusterTransforms[j]._dq; | ||
| 152 | } | ||
| 153 | } | ||
| 154 | #else | 130 | #else |
| 155 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterTransforms[j]); | 131 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterTransforms[j]); |
| 156 | #endif | 132 | #endif |
| @@ -171,12 +147,7 @@ void CauterizedModel::updateClusterMatrices() { · 14 unmodified lines | |||
| 171 | Model::MeshState& state = _cauterizeMeshStates[i]; | 147 | Model::MeshState& state = _cauterizeMeshStates[i]; |
| 172 | const FBXMesh& mesh = geometry.meshes.at(i); | 148 | const FBXMesh& mesh = geometry.meshes.at(i); |
| 173 | 149 | ||
| 174 | #if defined(SKIN_DQ) | 150 | for (int j = 0; j < mesh.clusters.size(); j++) { |
| 175 | // HACK: FOR DQ go thru reverse order! | ||
| 176 | for (int j = mesh.clusters.size() - 1; j >= 0; j--) { | ||
| 177 | #else | ||
| 178 | for (int j = 0; j < mesh.clusters.size(); j++) { | ||
| 179 | #endif | ||
| 180 | const FBXCluster& cluster = mesh.clusters.at(j); | 151 | const FBXCluster& cluster = mesh.clusters.at(j); |
| 181 | 152 | ||
| 182 | auto jointMatrix = _rig.getJointTransform(cluster.jointIndex); | 153 | auto jointMatrix = _rig.getJointTransform(cluster.jointIndex); |
| @@ -194,25 +165,6 @@ void CauterizedModel::updateClusterMatrices() { · 11 unmodified lines | |||
| 194 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, m); | 165 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, m); |
| 195 | AnimPose p(m); | 166 | AnimPose p(m); |
| 196 | state.clusterTransforms[j] = Model::TransformDualQuaternion(m); | 167 | state.clusterTransforms[j] = Model::TransformDualQuaternion(m); |
| 197 | |||
| 198 | // AJT: HACK n^2!!!! fix me, find parent clusterTransform. | ||
| 199 | int parentIndex = _rig.getJointParentIndex(cluster.jointIndex); | ||
| 200 | int parentClusterIndex = -1; | ||
| 201 | // scan for parent! | ||
| 202 | for (int ii = mesh.clusters.size() - 1; ii > j; ii--) { | ||
| 203 | if (mesh.clusters[ii].jointIndex == parentIndex) { | ||
| 204 | parentClusterIndex = ii; | ||
| 205 | break; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | // ensure that we have the same polarity as our parent! | ||
| 210 | if (parentClusterIndex >= 0) { | ||
| 211 | //if (state.clusterTransforms[parentClusterIndex]._dq.dot(state.clusterTransforms[j]._dq) < 0.0f) { | ||
| 212 | if (glm::dot(state.clusterTransforms[parentClusterIndex]._dq.real(), state.clusterTransforms[j]._dq.real()) < 0.0f) { | ||
| 213 | state.clusterTransforms[j]._dq = -state.clusterTransforms[j]._dq; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | #else | 168 | #else |
| 217 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterTransforms[j]); | 169 | glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterTransforms[j]); |
| 218 | #endif | 170 | #endif |