diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-10-30 22:42:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-10-30 22:42:11 +0400 |
commit | 44e60266269236234146066ab80aff4fa83722d8 (patch) | |
tree | 36b8ddd342e02c38e6f05d97437b64cc3fdb75a2 /source/blender/blenkernel/intern/constraint.c | |
parent | 082e9b329d154ed2b3aa6ba6d71064261f8204b7 (diff) |
the pivot constraint was translating when the pivot was offset along the rotation axis.
fixed by projecting the pivot along the axis of rotation and subtracting this from the pivot.
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 4d6ef612c83..9629be330d9 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3812,6 +3812,10 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t float pivot[3], vec[3]; float rotMat[3][3]; + + /* pivot correction */ + float axis[3], angle; + float dvec[3]; /* firstly, check if pivoting should take place based on the current rotation */ if (data->rotAxis != PIVOTCON_AXIS_NONE) { @@ -3854,7 +3858,15 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t // TODO: perhaps we might want to include scaling based on the pivot too? copy_m3_m4(rotMat, cob->matrix); normalize_m3(rotMat); - + + + /* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */ + mat3_to_axis_angle(axis, &angle, rotMat); + sub_v3_v3v3(vec, pivot, cob->matrix[3]); + project_v3_v3v3(dvec, vec, axis); + sub_v3_v3(pivot, dvec); + + /* perform the pivoting... */ /* 1. take the vector from owner to the pivot */ sub_v3_v3v3(vec, pivot, cob->matrix[3]); |