History

fix avatar bounding capsule calculations

Andrew Meadows committed 11 years ago

Commit 281e4f21 parent 90fe54e6 files · +99 −109Browse files

Showing the changes to interface/src/avatar/SkeletonModel.cpp (1 of 6 files). Show all

Unified · Split

interface/src/avatar/SkeletonModel.cpp+12−6
@@ -544,14 +544,20 @@ void SkeletonModel::computeBoundingShape() { · 543 unmodified lines
544544 totalExtents.addPoint(glm::vec3(0.0f));
545545 int numStates = _rig->getJointStateCount();
546546 for (int i = 0; i < numStates; i++) {
547− // compute the default transform of this joint
548547 const JointState& state = _rig->getJointState(i);
549548
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+ }
555561 }
556562
557563 // compute bounding shape parameters

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t