From c1a7b8b7a10428e6d50119fb51ef2c0c8efd3309 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Fri, 22 Apr 2005 01:14:15 +0000 Subject: [PATCH] Local axis constraints for pose mode. Added Camera rotation fix (was off centered because it used persinv instead of viewinv. Now rotation center is always center screen in camera mode. (Still need to fix the helpline not showing) Numinput constraint function was no good, didn't check if a constraint was even on... Fixed. Rotation was missing constraint text in header print. Fixed. --- source/blender/src/transform.c | 4 +- source/blender/src/transform_constraints.c | 58 +++++++++++----------- source/blender/src/transform_conversions.c | 3 ++ source/blender/src/transform_generics.c | 9 ++-- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 4e86877f0c1..25011e2f4b4 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -1000,7 +1000,9 @@ int Resize(TransInfo *t, short mval[2]) float obsizemat[3][3]; // Reorient the size mat to fit the oriented object. Mat3MulMat3(obsizemat, tmat, td->axismtx); + //printmatrix3("obsizemat", obsizemat); Mat3ToSize(obsizemat, fsize); + //printvecf("fsize", fsize); } else { Mat3ToSize(tmat, fsize); @@ -1374,7 +1376,7 @@ int Rotation(TransInfo *t, short mval[2]) final *= (float)(M_PI / 180.0); } else { - sprintf(str, "Rot: %.2f %s", 180.0*final/M_PI, t->proptext); + sprintf(str, "Rot: %.2f%s %s", 180.0*final/M_PI, t->con.text, t->proptext); } VecRotToMat3(axis, final * td->factor, mat); diff --git a/source/blender/src/transform_constraints.c b/source/blender/src/transform_constraints.c index 9e3104f9b72..6908e6c8f96 100755 --- a/source/blender/src/transform_constraints.c +++ b/source/blender/src/transform_constraints.c @@ -114,36 +114,38 @@ void getConstraintMatrix(TransInfo *t); void constraintNumInput(TransInfo *t, float vec[3]) { int mode = t->con.mode; - float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f; + if (mode & CON_APPLY) { + float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f; - if (getConstraintSpaceDimension(t) == 2) { - if (mode & (CON_AXIS0|CON_AXIS1)) { - vec[2] = nval; + if (getConstraintSpaceDimension(t) == 2) { + if (mode & (CON_AXIS0|CON_AXIS1)) { + vec[2] = nval; + } + else if (mode & (CON_AXIS1|CON_AXIS2)) { + vec[2] = vec[1]; + vec[1] = vec[0]; + vec[0] = nval; + } + else if (mode & (CON_AXIS0|CON_AXIS2)) { + vec[2] = vec[1]; + vec[1] = nval; + } } - else if (mode & (CON_AXIS1|CON_AXIS2)) { - vec[2] = vec[1]; - vec[1] = vec[0]; - vec[0] = nval; - } - else if (mode & (CON_AXIS0|CON_AXIS2)) { - vec[2] = vec[1]; - vec[1] = nval; - } - } - else if (getConstraintSpaceDimension(t) == 1) { - if (mode & CON_AXIS0) { - vec[1] = nval; - vec[2] = nval; - } - else if (mode & CON_AXIS1) { - vec[1] = vec[0]; - vec[0] = nval; - vec[2] = nval; - } - else if (mode & CON_AXIS2) { - vec[2] = vec[0]; - vec[0] = nval; - vec[1] = nval; + else if (getConstraintSpaceDimension(t) == 1) { + if (mode & CON_AXIS0) { + vec[1] = nval; + vec[2] = nval; + } + else if (mode & CON_AXIS1) { + vec[1] = vec[0]; + vec[0] = nval; + vec[2] = nval; + } + else if (mode & CON_AXIS2) { + vec[2] = vec[0]; + vec[0] = nval; + vec[1] = nval; + } } } } diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index eea30fd0974..d95c84330b4 100755 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -432,6 +432,9 @@ static void add_pose_transdata(TransInfo *t, ListBase *lb, Object *ob, TransData Mat3CpyMat4 (td->mtx, parmat); Mat3Inv (td->smtx, td->mtx); + + Mat3CpyMat3(td->axismtx, td->mtx); + Mat3Ortho(td->axismtx); (*tdp)++; deeper= 0; diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index d1e1dfd224f..d303bb03e62 100755 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -697,13 +697,14 @@ void calculateCenter(TransInfo *t) if(t->flag & T_OBJECT) { if( G.vd->camera==OBACT && G.vd->persp>1) { float axis[3]; - VECCOPY(axis, G.vd->persinv[2]); + /* persinv is nasty, use viewinv instead, always right */ + VECCOPY(axis, G.vd->viewinv[2]); Normalise(axis); /* 6.0 = 6 grid units */ - axis[0]= t->center[0]+ 6.0f*axis[0]; - axis[1]= t->center[1]+ 6.0f*axis[1]; - axis[2]= t->center[2]+ 6.0f*axis[2]; + axis[0]= t->center[0]- 6.0f*axis[0]; + axis[1]= t->center[1]- 6.0f*axis[1]; + axis[2]= t->center[2]- 6.0f*axis[2]; project_short_noclip(axis, t->center2d);