Fix distance constraint lengths

This commit is contained in:
Andrew Meadows 2014-06-19 11:46:09 -07:00
parent 2453e9c36a
commit fbafcb6fd8
3 changed files with 5 additions and 3 deletions

View file

@ -657,9 +657,9 @@ void SkeletonModel::computeBoundingShape(const FBXGeometry& geometry) {
// compute the default transforms and slam the ragdoll positions accordingly
// (which puts the shapes where we want them)
transforms[0] = glm::scale(_scale);
_ragdollPoints[0]._position = glm::vec3(0.0f);
_ragdollPoints[0]._lastPosition = glm::vec3(0.0f);
transforms[0] = _jointStates[0].getTransform();
_ragdollPoints[0]._position = extractTranslation(transforms[0]);
_ragdollPoints[0]._lastPosition = _ragdollPoints[0]._position;
for (int i = 1; i < numJoints; i++) {
const FBXJoint& joint = geometry.joints.at(i);
int parentIndex = joint.parentIndex;

View file

@ -174,6 +174,7 @@ QVector<JointState> Model::createJointStates(const FBXGeometry& geometry) {
int parentIndex = joint.parentIndex;
if (parentIndex == -1) {
_rootIndex = i;
// NOTE: in practice geometry.offset has a non-unity scale (rather than a translation)
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
state.computeTransform(parentTransform);
} else {

View file

@ -57,6 +57,7 @@ public:
DistanceConstraint(const DistanceConstraint& other);
float enforce();
void setDistance(float distance);
float getDistance() const { return _distance; }
private:
float _distance;
VerletPoint* _points[2];