== Constraints - Geometry Targets ==

It is now possible to use the geometry of Meshes and/or Lattices as the target of a constraint. All you need to do, is to create a new Vertex-Group and assign all the points that you wish to use as the target, then type that name into the VG: field for the relevant constraints.

One of the cases where this is beneficial is when you need to copy the location of a vertex. Now you don't need to make extra vertex-parents for that.

Additional Notes:
* The code takes the average of the locations of the nominated vertices, and puts that in world-space for constraint solving (and regular space-conversion stuff).
* Currently, rotation and scaling of points is not taken into account. The rotation/scaling used is from the object's matrix. Hopefully, this will only be a temporary problem (will be fixed soon)
This commit is contained in:
2007-08-17 11:23:48 +00:00
parent 4d884c0fbf
commit 400d77bbe2
4 changed files with 205 additions and 17 deletions

View File

@@ -540,12 +540,13 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
uiBut *but;
char typestr[64], *subtarget;
short height, width = 265;
short is_armature_target, is_armature_owner;
short is_armature_target, is_geom_target, is_armature_owner;
int rb_col;
target= get_constraint_target(con, &subtarget);
is_armature_target= (target && target->type==OB_ARMATURE);
is_armature_owner= ((ob->type == OB_ARMATURE) && (ob->flag & OB_POSEMODE));
is_geom_target= (target && (ELEM(target->type, OB_MESH, OB_LATTICE)) );
/* unless button has own callback, it adds this callback to button */
uiBlockSetFunc(block, constraint_active_func, ob, con);
@@ -639,6 +640,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -737,6 +742,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone to use as Parent");
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -791,6 +800,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -834,6 +847,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -872,6 +889,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -908,6 +929,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -944,6 +969,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -998,6 +1027,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -1035,6 +1068,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -1116,6 +1153,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
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);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy (data->subtarget, "");
}
@@ -1403,6 +1444,10 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", *xco+120, *yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone to use as Parent");
uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
}
else if (is_geom_target) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", *xco+120, *yco-66,150,18, &data->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)data->tar);
}
else {
strcpy(data->subtarget, "");
}