diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-03-13 19:15:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-03-13 19:15:59 +0300 |
commit | ed31a7c6bb7e6fcccef1b1f0514281db635d2a72 (patch) | |
tree | f7992ee6f69bbd286599ac851fd29ef23bacdc6f | |
parent | 5ae20c6eaf82118ff725a5fb167e80f2c871c42b (diff) |
[ #6214 ] Select object of the same group.
rewritten to find the groups that an object is apart of only once (less listbase searching).
with the limitation of 24 maximum in the menu.
-rw-r--r-- | source/blender/src/space.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 83aa27728fd..37142b8d9ba 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -692,13 +692,55 @@ static void select_parent(void) /* Makes parent active and de-selected OBACT */ } } + +#define GROUP_MENU_MAX 24 static void select_same_group(Object *ob) /* Select objects in the same group as the active */ { Base *base; - Group *group= find_group(ob); - if (!group || !ob) + Group *group, *ob_groups[GROUP_MENU_MAX]; + char str[10 + (24*GROUP_MENU_MAX)]; + char *p = str; + int group_count=0, menu, i; + + if (!ob) + return; + + for ( group=G.main->group.first; + group && group_count < GROUP_MENU_MAX; + group=group->id.next + ) { + if (object_in_group (ob, group)) { + ob_groups[group_count] = group; + group_count++; + } + } + + if (!group_count) + return; + + else if (group_count == 1) { + group = ob_groups[0]; + for (base= FIRSTBASE; base; base= base->next) { + if (!(base->flag & SELECT) && object_in_group(base->object, group)) { + base->flag |= SELECT; + base->object->flag |= SELECT; + } + } + return; + } + + /* build the menu. */ + p += sprintf(str, "Groups%%t"); + for (i=0; i<group_count; i++) { + group = ob_groups[i]; + p += sprintf (p, "|%s%%x%i", group->id.name+2, i); + } + + menu = pupmenu (str); + if (menu == -1) return; + group = ob_groups[menu]; for (base= FIRSTBASE; base; base= base->next) { if (!(base->flag & SELECT) && object_in_group(base->object, group)) { base->flag |= SELECT; |