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/blenkernel/intern/deform.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/blenkernel/intern/deform.c')
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index aa6220e88bc..9356ba14071 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -113,14 +113,31 @@ bDeformGroup *get_named_vertexgroup (Object *ob, char *name) return NULL; } -int get_defgroup_num (Object *ob, bDeformGroup *dg) +int get_named_vertexgroup_num (Object *ob, char *name) +{ + /* Return the location of the named deform group within the list of + * deform groups. This function is a combination of get_defgroup_num and + * get_named_vertexgroup. The other two could be called instead, but that + * require looping over the vertexgroups twice. + */ + bDeformGroup *curdef; + int def_nr; + + for (curdef=ob->defbase.first, def_nr=0; curdef; curdef=curdef->next, def_nr++) { + if (!strcmp(curdef->name, name)) + return def_nr; + } + + return -1; +} + +int get_defgroup_num (Object *ob, bDeformGroup *dg) { /* Fetch the location of this deform group * within the linked list of deform groups. * (this number is stored in the deform * weights of the deform verts to link them - * to this deform group) deform deform - * deform blah blah deform + * to this deform group). */ bDeformGroup *eg; @@ -129,8 +146,7 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) eg = ob->defbase.first; def_nr = 0; - /* loop through all deform groups - */ + /* loop through all deform groups */ while (eg != NULL) { /* if the current deform group is |