Bugfix: Distance DVar doesn't work with new Local Space

Fixed references in UI to the old property, and adapted the backend
code to work for the new options too.
This commit is contained in:
Joshua Leung
2011-06-14 11:01:36 +00:00
parent a4216cb1d4
commit 7272bb643c
2 changed files with 37 additions and 12 deletions

View File

@@ -1153,25 +1153,50 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar)
/* check if object or bone */
if (pchan) {
/* bone */
if ((dtar->flag & DTAR_FLAG_LOCALSPACE) == 0) {
if (dtar->flag & DTAR_FLAG_LOCALSPACE) {
if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) {
float mat[4][4];
/* extract transform just like how the constraints do it! */
copy_m4_m4(mat, pchan->pose_mat);
constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, CONSTRAINT_SPACE_LOCAL);
/* ... and from that, we get our transform */
VECCOPY(tmp_loc, mat[3]);
}
else {
/* transform space (use transform values directly) */
VECCOPY(tmp_loc, pchan->loc);
}
}
else {
/* convert to worldspace */
VECCOPY(tmp_loc, pchan->pose_head);
mul_m4_v3(ob->obmat, tmp_loc);
}
else {
/* local (use transform values directly) */
VECCOPY(tmp_loc, pchan->loc);
}
}
else {
/* object */
if ((dtar->flag & DTAR_FLAG_LOCALSPACE) == 0) {
/* worldspace */
VECCOPY(tmp_loc, ob->obmat[3]);
if (dtar->flag & DTAR_FLAG_LOCALSPACE) {
if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) {
// XXX: this should practically be the same as transform space...
float mat[4][4];
/* extract transform just like how the constraints do it! */
copy_m4_m4(mat, ob->obmat);
constraint_mat_convertspace(ob, NULL, mat, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL);
/* ... and from that, we get our transform */
VECCOPY(tmp_loc, mat[3]);
}
else {
/* transform space (use transform values directly) */
VECCOPY(tmp_loc, ob->loc);
}
}
else {
/* local (use transform values directly) */
VECCOPY(tmp_loc, ob->loc);
/* worldspace */
VECCOPY(tmp_loc, ob->obmat[3]);
}
}

View File

@@ -472,7 +472,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
}
uiItemR(col, &dtar_ptr, "use_local_space_transform", 0, NULL, ICON_NONE);
uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
col= uiLayoutColumn(layout, 1);
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", "Ob/Bone 2:");
@@ -484,7 +484,7 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
}
uiItemR(col, &dtar2_ptr, "use_local_space_transform", 0, NULL, ICON_NONE);
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
}
/* settings for 'transform channel' driver variable type */