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)) ) {
	...
}
This commit is contained in:
Campbell Barton 2008-01-19 15:13:42 +00:00
parent c8841a7f2f
commit 7b6c88473c
7 changed files with 13 additions and 10 deletions

@ -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);

@ -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)

@ -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");

@ -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))

@ -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);

@ -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;
}

@ -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;