Fixing stuff without using brains... shouldn't do that too often! :)
This fixes my commit of august 13th, that cleaned up the code for drawing optional buttons for Constraint targets. Now, Bone target buttons are corectly drawn, when a target is Armature. (also bug report #4907)
This commit is contained in:
@@ -531,13 +531,14 @@ void autocomplete_vgroup(char *str, void *arg_v)
|
||||
|
||||
static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, short *xco, short *yco)
|
||||
{
|
||||
Object *ob= OBACT;
|
||||
Object *ob= OBACT, *target;
|
||||
uiBut *but;
|
||||
char typestr[64];
|
||||
short height, width = 265, is_pose;
|
||||
char typestr[64], *subtarget;
|
||||
short height, width = 265, is_armature_target;
|
||||
int curCol, rb_col;
|
||||
|
||||
is_pose= (ob->type==OB_ARMATURE && (ob->flag & OB_POSEMODE));
|
||||
target= get_constraint_target(con, &subtarget);
|
||||
is_armature_target= (target && target->type==OB_ARMATURE);
|
||||
|
||||
/* unless button has own callback, it adds this callback to button */
|
||||
uiBlockSetFunc(block, constraint_active_func, ob, con);
|
||||
@@ -630,7 +631,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose){
|
||||
if (is_armature_target){
|
||||
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -667,7 +668,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -677,7 +678,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
|
||||
/* Draw XYZ toggles */
|
||||
uiBlockBeginAlign(block);
|
||||
if (is_pose)
|
||||
if (is_armature_target)
|
||||
uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-98), *yco-64, 50, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
|
||||
but=uiDefButBitI(block, TOG, LOCLIKE_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, LOCLIKE_Y, B_CONSTRAINT_TEST, "Y", *xco+((width/2)-16), *yco-64, 32, 18, &data->flag, 0, 24, 0, 0, "Copy Y component");
|
||||
@@ -701,7 +702,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -711,7 +712,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
|
||||
/* Draw XYZ toggles */
|
||||
uiBlockBeginAlign(block);
|
||||
if (is_pose)
|
||||
if (is_armature_target)
|
||||
uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+((width/2)-98), *yco-64, 50, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
|
||||
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");
|
||||
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");
|
||||
@@ -732,7 +733,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -763,7 +764,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 19, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,19, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -795,7 +796,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -838,7 +839,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -872,7 +873,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -951,7 +952,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", *xco+120, *yco-24, 135, 18, &data->tar, "Target Object");
|
||||
|
||||
if (is_pose) {
|
||||
if (is_armature_target) {
|
||||
but=uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
|
||||
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
|
||||
}
|
||||
@@ -1027,7 +1028,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
|
||||
|
||||
if (is_pose)
|
||||
if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE))
|
||||
uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Limit locations relative to the bone's rest-position");
|
||||
else if (ob->parent != NULL)
|
||||
uiDefButBitS(block, TOG, LIMIT_NOPARENT, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &data->flag2, 0, 24, 0, 0, "Limit locations relative to parent, not origin/world");
|
||||
@@ -1065,7 +1066,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "max:", *xco+(normButWidth * 2), *yco-72, normButWidth, 18, &(data->zmax), -360, 360, 0.1,0.5,"Highest z value to allow");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
if (is_pose) {
|
||||
if (ob->type == OB_ARMATURE && (ob->flag & OB_POSEMODE)) {
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefBut(block, LABEL, B_CONSTRAINT_TEST,"Co-ordinate Space:",*xco, *yco-100,150,18, NULL, 0.0, 0.0, 0.0, 0.0, "");
|
||||
uiDefButBitS(block, TOG, CONSTRAINT_LOCAL, B_CONSTRAINT_TEST, "Local", *xco+160, *yco-100, 60, 18, &con->flag, 0, 24, 0, 0, "Work on a Pose's local transform");
|
||||
@@ -1362,7 +1363,7 @@ void do_constraintbuts(unsigned short event)
|
||||
|
||||
if(ob->pose) update_pose_constraint_flags(ob->pose);
|
||||
|
||||
if(ob->type==OB_ARMATURE) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
|
||||
if(ob->type==OB_ARMATURE) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA|OB_RECALC_OB);
|
||||
else DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
|
||||
|
||||
allqueue (REDRAWVIEW3D, 0);
|
||||
|
||||
Reference in New Issue
Block a user