diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-08-17 15:23:48 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-08-17 15:23:48 +0400 |
commit | 400d77bbe29ddecaaa4530146f07435877f9a6aa (patch) | |
tree | dfb746811c78f111784679e2b1895669939f0a6b /source/blender/src/buttons_object.c | |
parent | 4d884c0fbfd8c7588f6e082adc8925a8df44be24 (diff) |
== 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)
Diffstat (limited to 'source/blender/src/buttons_object.c')
-rw-r--r-- | source/blender/src/buttons_object.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index e59d39c41f5..684d4ceca51 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -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, ""); } |