find_group would only return the first group, this let to the assumption that an...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 19 Jan 2008 15:13:42 +0000 (15:13 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 19 Jan 2008 15:13:42 +0000 (15:13 +0000)
group = NULL;
while( (group = find_group(base->object, group)) ) {
...
}

source/blender/blenkernel/BKE_group.h
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/group.c
source/blender/python/api2_2x/Group.c
source/blender/src/buttons_object.c
source/blender/src/editgroup.c

index 9038422795d35d8a9d525f3d032e1da85aae3dad..1c301bb255c5ad9559dc12dc3bb349a3eb584998 100644 (file)
@@ -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);
index a963b877912e0de2d48477c3ab923a5ae3086898..e1cecaa7a61068eea5a8753669b1d06da9b92ed1 100644 (file)
@@ -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)
index 1b345616888cf00241867b9e0745e94506931976..e09f6207642796af9b7ecbba451981742af6466f 100644 (file)
@@ -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");
        
index 201d93220f9b27fe27656ea72e9d58f6197609c3..3a64f8c8c347ff110a16869ff775d008a3ec6407 100644 (file)
@@ -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))
index 26e5edd07330af75a6558ac97db6f19cf5697f51..b4819a425f33bbeffd0515f7055a0d205b1981bb 100644 (file)
@@ -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);
index b7be9d7f9bcdf909d166be768dba936c7dcbd3ef..0ff1e3dd40d98c62754f37d0849d677e11a32a9e 100644 (file)
@@ -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;
        }
index b17e6efee1b242a5bc76620ed55d07b52a767b44..4dfa339ed1570981c4b5569ab67b3e3c97d54519 100644 (file)
@@ -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;