diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-01-19 18:13:42 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-01-19 18:13:42 +0300 |
commit | 7b6c88473c02d97485970390086395b515be653e (patch) | |
tree | cc3d0ac9f256ac8a46598a2b9ac64ef7ad1c20c3 /source | |
parent | c8841a7f2f0e885335295b3cda34097e117d0edb (diff) |
find_group would only return the first group, this let to the assumption that an object was only in 1 group, made it easy to loop through all groups an object is in.
group = NULL;
while( (group = find_group(base->object, group)) ) {
...
}
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_group.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/depsgraph.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/group.c | 7 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Group.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 2 | ||||
-rw-r--r-- | source/blender/src/editgroup.c | 4 |
7 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index 9038422795d..1c301bb255c 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -45,7 +45,7 @@ void unlink_group(struct Group *group); struct Group *add_group(char *name); void add_to_group(struct Group *group, struct Object *ob); void rem_from_group(struct Group *group, struct Object *ob); -struct Group *find_group(struct Object *ob); +struct Group *find_group(struct Object *ob, struct Group *group); int object_in_group(struct Object *ob, struct Group *group); void group_tag_recalc(struct Group *group); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index a963b877912..e1cecaa7a61 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2064,8 +2064,8 @@ void DAG_object_update_flags(Scene *sce, Object *ob, unsigned int lay) /* object not in scene? then handle group exception. needs to be dagged once too */ if(node==NULL) { - Group *group= find_group(ob); - if(group) { + Group *group= NULL; + while( (group = find_group(ob, group)) ) { GroupObject *go; /* primitive; tag all... this call helps building groups for particles */ for(go= group->gobject.first; go; go= go->next) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 1b345616888..e09f6207642 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1552,7 +1552,7 @@ static pMatrixCache *cache_object_matrices(Object *ob, int start, int end) /* object can be linked in group... stupid exception */ if(NULL==object_in_scene(ob, G.scene)) - group= find_group(ob); + group= find_group(ob, NULL); /* TODO - dont just use the first group! - Campbell */ mcache= mc= MEM_mallocN( (end-start+1)*sizeof(pMatrixCache), "ob matrix cache"); diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 201d93220f9..3a64f8c8c34 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -164,9 +164,12 @@ int object_in_group(Object *ob, Group *group) return 0; } -Group *find_group(Object *ob) +Group *find_group(Object *ob, Group *group) { - Group *group= G.main->group.first; + if (group) + group= group->id.next; + else + group= G.main->group.first; while(group) { if(object_in_group(ob, group)) diff --git a/source/blender/python/api2_2x/Group.c b/source/blender/python/api2_2x/Group.c index 26e5edd0733..b4819a425f3 100644 --- a/source/blender/python/api2_2x/Group.c +++ b/source/blender/python/api2_2x/Group.c @@ -697,7 +697,7 @@ static PyObject *GroupObSeq_unlink( BPy_GroupObSeq * self, BPy_Object *value ) rem_from_group(self->bpygroup->group, blen_ob); - if(find_group(blen_ob)==NULL) { + if(find_group(blen_ob, NULL)==NULL) { blen_ob->flag &= ~OB_FROMGROUP; base= object_in_scene(blen_ob, G.scene); diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index b7be9d7f9bc..0ff1e3dd40d 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -2350,7 +2350,7 @@ static void group_ob_rem(void *gr_v, void *ob_v) Object *ob= OBACT; rem_from_group(gr_v, ob); - if(find_group(ob)==NULL) { + if(find_group(ob, NULL)==NULL) { ob->flag &= ~OB_FROMGROUP; BASACT->flag &= ~OB_FROMGROUP; } diff --git a/source/blender/src/editgroup.c b/source/blender/src/editgroup.c index b17e6efee1b..4dfa339ed15 100644 --- a/source/blender/src/editgroup.c +++ b/source/blender/src/editgroup.c @@ -119,8 +119,8 @@ void rem_selected_from_group(void) for(base=FIRSTBASE; base; base= base->next) { if TESTBASE(base) { - - while( (group = find_group(base->object)) ) { + group = NULL; + while( (group = find_group(base->object, group)) ) { rem_from_group(group, base->object); } base->object->flag &= ~OB_FROMGROUP; |