[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47536] trunk/blender/source/blender/ editors/space_outliner/outliner_tools.c: group outliner option to instance selected groups in the scene.
Campbell Barton
ideasman42 at gmail.com
Wed Jun 6 21:20:40 CEST 2012
Revision: 47536
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47536
Author: campbellbarton
Date: 2012-06-06 19:20:39 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
group outliner option to instance selected groups in the scene.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_outliner/outliner_tools.c
Modified: trunk/blender/source/blender/editors/space_outliner/outliner_tools.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_tools.c 2012-06-06 19:11:06 UTC (rev 47535)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_tools.c 2012-06-06 19:20:39 UTC (rev 47536)
@@ -385,6 +385,18 @@
}
}
+static void group_instance_cb(bContext *C, Scene *scene, TreeElement *UNUSED(te),
+ TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+{
+ Group *group = (Group *)tselem->id;
+
+ Object *ob = ED_object_add_type(C, OB_EMPTY, scene->cursor, NULL, FALSE, scene->layact);
+ rename_id(&ob->id, group->id.name + 2);
+ ob->dup_group = group;
+ ob->transflag |= OB_DUPLIGROUP;
+ id_lib_extern(&group->id);
+}
+
void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb,
void (*operation_cb)(bContext *C, Scene *scene, TreeElement *,
TreeStoreElem *, TreeStoreElem *))
@@ -636,13 +648,14 @@
/* **************************************** */
static EnumPropertyItem prop_group_op_types[] = {
- {1, "UNLINK", 0, "Unlink", ""},
- {2, "LOCAL", 0, "Make Local", ""},
- {3, "LINK", 0, "Link Group Objects to Scene", ""},
- {4, "TOGVIS", 0, "Toggle Visible", ""},
- {5, "TOGSEL", 0, "Toggle Selectable", ""},
- {6, "TOGREN", 0, "Toggle Renderable", ""},
- {7, "RENAME", 0, "Rename", ""},
+ {0, "UNLINK", 0, "Unlink Group", ""},
+ {1, "LOCAL", 0, "Make Local Group", ""},
+ {2, "LINK", 0, "Link Group Objects to Scene", ""},
+ {3, "INSTANCE", 0, "Instance Group in Scene", ""},
+ {4, "TOGVIS", 0, "Toggle Visible Group", ""},
+ {5, "TOGSEL", 0, "Toggle Selectable", ""},
+ {6, "TOGREN", 0, "Toggle Renderable", ""},
+ {7, "RENAME", 0, "Rename", ""},
{0, NULL, 0, NULL, NULL}
};
@@ -651,45 +664,36 @@
Scene *scene = CTX_data_scene(C);
SpaceOops *soops = CTX_wm_space_outliner(C);
int event;
- const char *str = NULL;
/* check for invalid states */
if (soops == NULL)
return OPERATOR_CANCELLED;
event = RNA_enum_get(op->ptr, "type");
+
+ switch (event) {
+ case 0: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); break;
+ case 1: outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); break;
+ case 2: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); break;
+ case 3: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_instance_cb); break;
+ case 4: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); break;
+ case 5: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); break;
+ case 6: outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); break;
+ case 7: outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); break;
+ default:
+ BLI_assert(0);
+ return OPERATOR_CANCELLED;
+ }
- if (event == 1) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb);
- str = "Unlink group";
+
+ if (event == 3) { /* instance */
+ Main *bmain = CTX_data_main(C);
+
+ /* works without this except if you try render right after, see: 22027 */
+ DAG_scene_sort(bmain, scene);
}
- else if (event == 2) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb);
- str = "Localized Data";
- }
- else if (event == 3) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb);
- str = "Link Group Objects to Scene";
- }
- else if (event == 4) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb);
- str = "Toggle Visibility";
- }
- else if (event == 5) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb);
- str = "Toggle Selectability";
- }
- else if (event == 6) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb);
- str = "Toggle Renderability";
- }
- else if (event == 7) {
- outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb);
- str = "Rename";
- }
-
- ED_undo_push(C, str);
+ ED_undo_push(C, prop_group_op_types[event].name);
WM_event_add_notifier(C, NC_GROUP, NULL);
return OPERATOR_FINISHED;
More information about the Bf-blender-cvs
mailing list