From 14a3166685b23f481b7feabbfe08bfeed64a5847 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 29 May 2005 09:21:34 +0000 Subject: [PATCH] Push/Pull didn't do Lock Constraint correctly. Fixed. Also added an isLockConstraint function that tells if the current constraint is a locking constraint or not. --- source/blender/include/transform.h | 2 ++ source/blender/src/transform.c | 9 ++++++++- source/blender/src/transform_constraints.c | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/blender/include/transform.h b/source/blender/include/transform.h index cc3dccb6007..7777804dd76 100755 --- a/source/blender/include/transform.h +++ b/source/blender/include/transform.h @@ -275,6 +275,8 @@ void drawConstraint(); //void drawPropCircle(TransInfo *t); void drawPropCircle(); +int isLockConstraint(TransInfo *t); + void initConstraint(TransInfo *t); void startConstraint(TransInfo *t); void stopConstraint(TransInfo *t); diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index e83e55c6bc4..886607e16f2 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -1988,7 +1988,14 @@ int PushPull(TransInfo *t, short mval[2]) VecSubf(vec, t->center, td->center); if (t->con.applyRot && t->con.mode & CON_APPLY) { t->con.applyRot(t, td, axis); - Projf(vec, vec, axis); + if (isLockConstraint(t)) { + float dvec[3]; + Projf(dvec, vec, axis); + VecSubf(vec, vec, dvec); + } + else { + Projf(vec, vec, axis); + } } Normalise(vec); VecMulf(vec, distance); diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c index edb43aeb883..f231813efd8 100755 --- a/source/blender/src/transform_constraints.c +++ b/source/blender/src/transform_constraints.c @@ -739,6 +739,21 @@ void BIF_drawPropCircle() } } +int isLockConstraint(TransInfo *t) { + int mode = t->con.mode; + + if (mode & (CON_AXIS0|CON_AXIS1) == (CON_AXIS0|CON_AXIS1)) + return 1; + + if (mode & (CON_AXIS1|CON_AXIS2) == (CON_AXIS1|CON_AXIS2)) + return 1; + + if (mode & (CON_AXIS0|CON_AXIS2) == (CON_AXIS0|CON_AXIS2)) + return 1; + + return 0; +} + void initConstraint(TransInfo *t) { if (t->con.mode & CON_APPLY) { startConstraint(t);