diff options
author | Ton Roosendaal <ton@blender.org> | 2005-10-25 23:13:04 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-10-25 23:13:04 +0400 |
commit | 8a21421e5414aa3d7f43e9bbde4b805a193639a6 (patch) | |
tree | 572d4bae18b9eb5f47340bc1a1eb05d81a2b2e15 /source | |
parent | 7fc4cf930ce6b8c77730e93c7972ac63773241d8 (diff) |
New; Rotation Constraint allows to only copy X,Y,Z axis rotations.
Note this is based on eulers, so might give the common issues. :)
For most cases it goes fine though, especially with only 1 axis constraint.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 51 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_constraint_types.h | 5 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 12 |
3 files changed, 49 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 82ac349a657..b0dbc49fcf6 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -559,7 +559,7 @@ void *new_constraint_data (short type) { bRotateLikeConstraint *data; data = MEM_callocN(sizeof(bRotateLikeConstraint), "rotlikeConstraint"); - + data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; result = data; } break; @@ -567,8 +567,7 @@ void *new_constraint_data (short type) { bLocateLikeConstraint *data; data = MEM_callocN(sizeof(bLocateLikeConstraint), "loclikeConstraint"); - - data->flag |= LOCLIKE_X|LOCLIKE_Y|LOCLIKE_Z; + data->flag = LOCLIKE_X|LOCLIKE_Y|LOCLIKE_Z; result = data; } break; @@ -1041,25 +1040,41 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype, break; case CONSTRAINT_TYPE_ROTLIKE: { - float tmat[4][4]; - float size[3]; + bRotateLikeConstraint *data; + float tmat[3][3]; + float size[3]; + + data = constraint->data; + + /* old files stuff only... version patch is too much code! */ + if(data->flag==0) data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; - Mat4ToSize(ob->obmat, size); - - Mat4CpyMat4 (tmat, targetmat); - Mat4Ortho(tmat); + Mat4ToSize(ob->obmat, size); + + Mat3CpyMat4 (tmat, targetmat); + Mat3Ortho(tmat); + + if(data->flag != (ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z)) { + float eul[3]; + + Mat3ToEul(tmat, eul); + if(!(data->flag & ROTLIKE_X)) eul[0]= 0.0f; + if(!(data->flag & ROTLIKE_Y)) eul[1]= 0.0f; + if(!(data->flag & ROTLIKE_Z)) eul[2]= 0.0f; + EulToMat3(eul, tmat); + } - ob->obmat[0][0] = tmat[0][0]*size[0]; - ob->obmat[0][1] = tmat[0][1]*size[1]; - ob->obmat[0][2] = tmat[0][2]*size[2]; + ob->obmat[0][0] = tmat[0][0]*size[0]; + ob->obmat[0][1] = tmat[0][1]*size[1]; + ob->obmat[0][2] = tmat[0][2]*size[2]; - ob->obmat[1][0] = tmat[1][0]*size[0]; - ob->obmat[1][1] = tmat[1][1]*size[1]; - ob->obmat[1][2] = tmat[1][2]*size[2]; + ob->obmat[1][0] = tmat[1][0]*size[0]; + ob->obmat[1][1] = tmat[1][1]*size[1]; + ob->obmat[1][2] = tmat[1][2]*size[2]; - ob->obmat[2][0] = tmat[2][0]*size[0]; - ob->obmat[2][1] = tmat[2][1]*size[1]; - ob->obmat[2][2] = tmat[2][2]*size[2]; + ob->obmat[2][0] = tmat[2][0]*size[0]; + ob->obmat[2][1] = tmat[2][1]*size[1]; + ob->obmat[2][2] = tmat[2][2]*size[2]; } break; case CONSTRAINT_TYPE_NULL: diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 3b30613015a..e2cb9a0679d 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -193,6 +193,11 @@ typedef struct bStretchToConstraint{ /* bConstraintChannel.flag */ #define CONSTRAINT_CHANNEL_SELECT 0x01 +/* bRotateLikeConstraint.flag */ +#define ROTLIKE_X 0x01 +#define ROTLIKE_Y 0x02 +#define ROTLIKE_Z 0x04 + /* bLocateLikeConstraint.flag */ #define LOCLIKE_X 0x01 #define LOCLIKE_Y 0x02 diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 786a59d7333..553ad055b72 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -569,7 +569,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s bRotateLikeConstraint *data = con->data; bArmature *arm; - height = 46; + /* also old files stuff... version patch is too much code! */ + if(data->flag==0) data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; + + height = 66; uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, ""); uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", *xco+65, *yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); @@ -585,6 +588,13 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s else strcpy (data->subtarget, ""); uiBlockEndAlign(block); + + /* Draw XYZ toggles */ + uiBlockBeginAlign(block); + but=uiDefButBitI(block, TOG, ROTLIKE_X, B_CONSTRAINT_TEST, "X", *xco+((width/2)-48), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy X component"); + but=uiDefButBitI(block, TOG, ROTLIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component"); + but=uiDefButBitI(block, TOG, ROTLIKE_Z, B_CONSTRAINT_TEST, "Z", *xco+((width/2)+16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Z component"); + uiBlockEndAlign(block); } break; case CONSTRAINT_TYPE_KINEMATIC: |