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.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user