diff options
-rw-r--r-- | source/blender/blenkernel/BKE_deform.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 71 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 12 | ||||
-rw-r--r-- | source/blender/include/BIF_editdeform.h | 1 | ||||
-rw-r--r-- | source/blender/src/buttons_editing.c | 1 | ||||
-rw-r--r-- | source/blender/src/editdeform.c | 54 | ||||
-rw-r--r-- | source/blender/src/outliner.c | 1 |
7 files changed, 79 insertions, 66 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 5888975feb6..de0dddabfd3 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -43,9 +43,10 @@ struct ListBase; struct bDeformGroup; void copy_defgroups (struct ListBase *lb1, struct ListBase *lb2); -struct bDeformGroup* copy_defgroup (struct bDeformGroup *ingroup); +struct bDeformGroup *copy_defgroup (struct bDeformGroup *ingroup); struct bDeformGroup *get_named_vertexgroup (Object *ob, char *name); -int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); +int get_defgroup_num (struct Object *ob, struct bDeformGroup *dg); +void unique_vertexgroup_name (struct bDeformGroup *dg, struct Object *ob); #endif diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 2b44a10e913..aa6220e88bc 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -69,7 +69,7 @@ #endif -void copy_defgroups(ListBase *outbase, ListBase *inbase) +void copy_defgroups (ListBase *outbase, ListBase *inbase) { bDeformGroup *defgroup, *defgroupn; @@ -81,7 +81,7 @@ void copy_defgroups(ListBase *outbase, ListBase *inbase) } } -bDeformGroup* copy_defgroup (bDeformGroup *ingroup) +bDeformGroup *copy_defgroup (bDeformGroup *ingroup) { bDeformGroup *outgroup; @@ -98,22 +98,22 @@ bDeformGroup* copy_defgroup (bDeformGroup *ingroup) return outgroup; } -bDeformGroup *get_named_vertexgroup(Object *ob, char *name) +bDeformGroup *get_named_vertexgroup (Object *ob, char *name) { /* return a pointer to the deform group with this name * or return NULL otherwise. */ bDeformGroup *curdef; - for (curdef = ob->defbase.first; curdef; curdef=curdef->next){ - if (!strcmp(curdef->name, name)){ + for (curdef = ob->defbase.first; curdef; curdef=curdef->next) { + if (!strcmp(curdef->name, name)) { return curdef; } } return NULL; } -int get_defgroup_num (Object *ob, bDeformGroup *dg) +int get_defgroup_num (Object *ob, bDeformGroup *dg) { /* Fetch the location of this deform group * within the linked list of deform groups. @@ -123,7 +123,7 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) * deform blah blah deform */ - bDeformGroup *eg; + bDeformGroup *eg; int def_nr; eg = ob->defbase.first; @@ -131,13 +131,13 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) /* loop through all deform groups */ - while (eg != NULL){ + while (eg != NULL) { /* if the current deform group is * the one we are after, return * def_nr */ - if (eg == dg){ + if (eg == dg) { break; } ++def_nr; @@ -154,3 +154,56 @@ int get_defgroup_num (Object *ob, bDeformGroup *dg) } +void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) +{ + bDeformGroup *curdef; + int number; + int exists = 0; + char tempname[64]; + char *dot; + + if (!ob) + return; + + /* See if we are given an empty string */ + if (dg->name[0] == '\0') { + /* give it default name first */ + strcpy (dg->name, "Group"); + } + + /* See if we even need to do this */ + for (curdef = ob->defbase.first; curdef; curdef=curdef->next) { + if (dg!=curdef) { + if (!strcmp(curdef->name, dg->name)) { + exists = 1; + break; + } + } + } + + if (!exists) + return; + + /* Strip off the suffix */ + dot=strchr(dg->name, '.'); + if (dot) + *dot=0; + + for (number = 1; number <=999; number++) { + sprintf (tempname, "%s.%03d", dg->name, number); + + exists = 0; + for (curdef=ob->defbase.first; curdef; curdef=curdef->next) { + if (dg!=curdef) { + if (!strcmp (curdef->name, tempname)) { + exists = 1; + break; + } + } + } + if (!exists) { + BLI_strncpy (dg->name, tempname, 32); + return; + } + } +} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 7e6f246be7a..70f8422968c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6369,11 +6369,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } if(main->versionfile <= 243) { + Object *ob= main->object.first; Camera *cam = main->camera.first; for(; cam; cam= cam->id.next) { cam->angle= 360.0f * atan(16.0f/cam->lens) / M_PI; } + + for(; ob; ob= ob->id.next) { + bDeformGroup *curdef; + + for(curdef= ob->defbase.first; curdef; curdef=curdef->next) { + /* replace an empty-string name with unique name */ + if (curdef->name[0] == '\0') { + unique_vertexgroup_name(curdef, ob); + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/include/BIF_editdeform.h b/source/blender/include/BIF_editdeform.h index 4788f1f6837..69f03652887 100644 --- a/source/blender/include/BIF_editdeform.h +++ b/source/blender/include/BIF_editdeform.h @@ -43,7 +43,6 @@ struct MDeformVert; struct MDeformWeight; struct bDeformGroup; -void unique_vertexgroup_name (struct bDeformGroup *dg, struct Object *ob); struct bDeformGroup *add_defgroup_name (struct Object *ob, char *name); void add_defgroup (struct Object *ob); void del_defgroup_in_object_mode ( Object *ob ); diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index ec9a0020685..a64f461b0a0 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -80,6 +80,7 @@ #include "BKE_curve.h" #include "BKE_customdata.h" #include "BKE_colortools.h" +#include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_key.h" diff --git a/source/blender/src/editdeform.c b/source/blender/src/editdeform.c index 29324c28bf0..305d01a8aea 100644 --- a/source/blender/src/editdeform.c +++ b/source/blender/src/editdeform.c @@ -772,60 +772,6 @@ void remove_verts_defgroup (int allverts) } } -void unique_vertexgroup_name (bDeformGroup *dg, Object *ob) -{ - bDeformGroup *curdef; - int number; - int exists = 0; - char tempname[64]; - char *dot; - - if (!ob) - return; - - /* See if we are given an empty string */ - if (dg->name[0] == '\0') { - /* give it default name first */ - strcpy (dg->name, "Group"); - } - - /* See if we even need to do this */ - for (curdef = ob->defbase.first; curdef; curdef=curdef->next){ - if (dg!=curdef){ - if (!strcmp(curdef->name, dg->name)){ - exists = 1; - break; - } - } - } - - if (!exists) - return; - - /* Strip off the suffix */ - dot=strchr(dg->name, '.'); - if (dot) - *dot=0; - - for (number = 1; number <=999; number++){ - sprintf (tempname, "%s.%03d", dg->name, number); - - exists = 0; - for (curdef=ob->defbase.first; curdef; curdef=curdef->next){ - if (dg!=curdef){ - if (!strcmp (curdef->name, tempname)){ - exists = 1; - break; - } - } - } - if (!exists){ - BLI_strncpy (dg->name, tempname, 32); - return; - } - } -} - void vertexgroup_select_by_name(Object *ob, char *name) { bDeformGroup *curdef; diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index e29275e40d0..97d862383bd 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -59,6 +59,7 @@ #include "BLI_blenlib.h" #include "BKE_constraint.h" +#include "BKE_deform.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_group.h" |