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 | 544 | totalExtents.addPoint(glm::vec3(0.0f)); |
| 545 | 545 | int numStates = _rig->getJointStateCount(); |
| 546 | 546 | for (int i = 0; i < numStates; i++) { |
| 547 | − // compute the default transform of this joint | |
| 548 | 547 | const JointState& state = _rig->getJointState(i); |
| 549 | 548 | |
| 550 | − // Each joint contributes a sphere at its position | |
| 551 | − glm::vec3 axis(state.getBoneRadius()); | |
| 552 | − glm::vec3 jointPosition = state.getPosition(); | |
| 553 | − totalExtents.addPoint(jointPosition + axis); | |
| 554 | − totalExtents.addPoint(jointPosition - axis); | |
| 549 | + const glm::mat4& jointTransform = state.getTransform(); | |
| 550 | + float scale = extractUniformScale(jointTransform); | |
| 551 | + | |
| 552 | + // Each joint contributes a capsule defined by FBXJoint.shapeInfo. | |
| 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 | 563 | // compute bounding shape parameters |