Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 6 files). Show all
Unified · Split
| @@ -544,14 +544,20 @@ void SkeletonModel::computeBoundingShape() { · 543 unmodified lines | |||
| 544 | totalExtents.addPoint(glm::vec3(0.0f)); | 544 | totalExtents.addPoint(glm::vec3(0.0f)); |
| 545 | int numStates = _rig->getJointStateCount(); | 545 | int numStates = _rig->getJointStateCount(); |
| 546 | for (int i = 0; i < numStates; i++) { | 546 | for (int i = 0; i < numStates; i++) { |
| 547 | // compute the default transform of this joint | ||
| 548 | const JointState& state = _rig->getJointState(i); | 547 | const JointState& state = _rig->getJointState(i); |
| 549 | 548 | ||
| 550 | // Each joint contributes a sphere at its position | 549 | const glm::mat4& jointTransform = state.getTransform(); |
| 551 | glm::vec3 axis(state.getBoneRadius()); | 550 | float scale = extractUniformScale(jointTransform); |
| 552 | glm::vec3 jointPosition = state.getPosition(); | 551 | |
| 553 | totalExtents.addPoint(jointPosition + axis); | 552 | // Each joint contributes a capsule defined by FBXJoint.shapeInfo. |
| 554 | totalExtents.addPoint(jointPosition - axis); | 553 | // For totalExtents we use the capsule endpoints expanded by the radius. |
| 554 | const FBXJointShapeInfo& shapeInfo = geometry.joints.at(i).shapeInfo; | ||
| 555 | for (int j = 0; j < shapeInfo.points.size(); ++j) { | ||
| 556 | glm::vec3 transformedPoint = extractTranslation(jointTransform * glm::translate(shapeInfo.points[j])); | ||
| 557 | vec3 radius(scale * shapeInfo.radius); | ||
| 558 | totalExtents.addPoint(transformedPoint + radius); | ||
| 559 | totalExtents.addPoint(transformedPoint - radius); | ||
| 560 | } | ||
| 555 | } | 561 | } |
| 556 | 562 | ||
| 557 | // compute bounding shape parameters | 563 | // compute bounding shape parameters |