forked from bartvdbraak/blender
feature request from peach, remove selected objects from 1 group.
Also made rem_from_group return if it removed the object which save some looping. Added a node in the blender help message that background mode dosnt load the .B.blend file as a bug was reported recently because of this.
This commit is contained in:
parent
7e7f5628c3
commit
a9518afc67
@ -44,7 +44,7 @@ void free_group(struct Group *group);
|
||||
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);
|
||||
int rem_from_group(struct Group *group, struct Object *ob);
|
||||
struct Group *find_group(struct Object *ob, struct Group *group);
|
||||
int object_in_group(struct Object *ob, struct Group *group);
|
||||
int group_is_animated(struct Object *parent, struct Group *group);
|
||||
|
@ -134,11 +134,11 @@ void add_to_group(Group *group, Object *ob)
|
||||
}
|
||||
|
||||
/* also used for ob==NULL */
|
||||
void rem_from_group(Group *group, Object *ob)
|
||||
int rem_from_group(Group *group, Object *ob)
|
||||
{
|
||||
GroupObject *go, *gon;
|
||||
|
||||
if(group==NULL) return;
|
||||
int removed = 0;
|
||||
if(group==NULL) return 0;
|
||||
|
||||
go= group->gobject.first;
|
||||
while(go) {
|
||||
@ -146,9 +146,12 @@ void rem_from_group(Group *group, Object *ob)
|
||||
if(go->ob==ob) {
|
||||
BLI_remlink(&group->gobject, go);
|
||||
free_group_object(go);
|
||||
removed = 1;
|
||||
/* should break here since an object being in a group twice cant happen? */
|
||||
}
|
||||
go= gon;
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
int object_in_group(Object *ob, Group *group)
|
||||
|
@ -2492,8 +2492,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)==NULL) {
|
||||
if(rem_from_group(gr_v, ob) && find_group(ob, NULL)==NULL) {
|
||||
ob->flag &= ~OB_FROMGROUP;
|
||||
BASACT->flag &= ~OB_FROMGROUP;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ void add_selected_to_act_ob_groups(void)
|
||||
}
|
||||
|
||||
|
||||
void rem_selected_from_group(void)
|
||||
void rem_selected_from_all_groups(void)
|
||||
{
|
||||
Base *base;
|
||||
Group *group;
|
||||
@ -134,6 +134,77 @@ void rem_selected_from_group(void)
|
||||
BIF_undo_push("Remove from Group");
|
||||
}
|
||||
|
||||
|
||||
void rem_selected_from_group(void)
|
||||
{
|
||||
char menutext[30+(22*22)], *menupt;
|
||||
int i=0;
|
||||
short ret;
|
||||
Group *group= NULL;
|
||||
Object *ob;
|
||||
Base *base;
|
||||
Group *group_array[24] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
/* UnSet Tags for Objects and Groups */
|
||||
for(group= G.main->group.first; group; group= group->id.next) {
|
||||
if(group->id.lib==NULL) {
|
||||
group->id.flag &= ~LIB_DOIT;
|
||||
}
|
||||
}
|
||||
for(ob=G.main->object.first; ob; ob= ob->id.next) {
|
||||
ob->id.flag &= ~LIB_DOIT;
|
||||
}
|
||||
|
||||
/* Not tag selected objects */
|
||||
for(base=FIRSTBASE; base; base= base->next) {
|
||||
if TESTBASELIB(base) {
|
||||
base->object->id.flag |= LIB_DOIT;
|
||||
}
|
||||
}
|
||||
|
||||
menupt = menutext;
|
||||
/* Build a list of groups that contain selected objects */
|
||||
for(group= G.main->group.first; group && i<24; group= group->id.next) {
|
||||
if(group->id.lib==NULL) {
|
||||
GroupObject *go;
|
||||
for(go= group->gobject.first; go; go= go->next) {
|
||||
if(go->ob->id.flag & LIB_DOIT) {
|
||||
group_array[i] = group;
|
||||
menupt += sprintf(menupt, "|%s", group->id.name+2);
|
||||
i++;
|
||||
break; /* Only want to know if this group should go in the list*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* do we have any groups? */
|
||||
if (group_array[0] == NULL) {
|
||||
error("Object selection contains no groups");
|
||||
} else {
|
||||
ret = pupmenu(menutext);
|
||||
if (ret==-1) {
|
||||
return;
|
||||
} else {
|
||||
group = group_array[ret-1];
|
||||
for(base=FIRSTBASE; base; base= base->next) {
|
||||
if TESTBASELIB(base) {
|
||||
/* if we are removed and are not in any group, set our flag */
|
||||
if(rem_from_group(group, base->object) && find_group(base->object, NULL)==NULL) {
|
||||
base->object->flag &= ~OB_FROMGROUP;
|
||||
base->flag &= ~OB_FROMGROUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
allqueue(REDRAWBUTSOBJECT, 0);
|
||||
DAG_scene_sort(G.scene);
|
||||
BIF_undo_push("Remove from Group");
|
||||
}
|
||||
|
||||
void group_operation_with_menu(void)
|
||||
{
|
||||
Group *group= NULL;
|
||||
@ -145,7 +216,7 @@ void group_operation_with_menu(void)
|
||||
break;
|
||||
|
||||
if(group)
|
||||
mode= pupmenu("Groups %t|Add to Existing Group %x3|Add to Active Objects Groups %x4|Add to New Group %x1|Remove from All Groups %x2");
|
||||
mode= pupmenu("Groups %t|Add to Existing Group %x3|Add to Active Objects Groups %x4|Add to New Group %x1|Remove from Group %x5|Remove from All Groups %x2");
|
||||
else
|
||||
mode= pupmenu("Groups %t|Add to New Group %x1|Remove from All Groups %x2");
|
||||
|
||||
@ -181,6 +252,7 @@ void group_operation(int mode)
|
||||
|
||||
if(mode==4) add_selected_to_act_ob_groups();
|
||||
else if(mode==1 || mode==3) add_selected_to_group(group);
|
||||
else if(mode==2) rem_selected_from_group();
|
||||
else if(mode==2) rem_selected_from_all_groups();
|
||||
else if(mode==5) rem_selected_from_group();
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ static void print_help(void)
|
||||
printf (" ...may not render to /tmp because loading the blend file overwrites the output path that was set\n");
|
||||
printf (" \"blender -b test.blend -o /tmp -f 1\" works as expected.\n");
|
||||
printf ("\nRender options:\n");
|
||||
printf (" -b <file>\tRender <file> in background\n");
|
||||
printf (" -b <file>\tRender <file> in background (doesn't load the user defaults .B.blend file)\n");
|
||||
printf (" -a render frames from start to end (inclusive), only works when used after -b\n");
|
||||
printf (" -S <name>\tSet scene <name>\n");
|
||||
printf (" -f <frame>\tRender frame <frame> and save it\n");
|
||||
|
Loading…
Reference in New Issue
Block a user