[Bf-blender-cvs] [d29a0b3f1ed] temp-unified-collections: Collections: more work on unification with groups

Brecht Van Lommel noreply at git.blender.org
Tue May 15 19:30:32 CEST 2018


Commit: d29a0b3f1eddfaaf879d6799f580fba430816bd6
Author: Brecht Van Lommel
Date:   Mon May 14 22:09:24 2018 +0200
Branches: temp-unified-collections
https://developer.blender.org/rBd29a0b3f1eddfaaf879d6799f580fba430816bd6

Collections: more work on unification with groups

* Removes the special exceptions for group reference counting. Unlinked
  collections now get a faker user. The weak point here is that unlinked
  collections retain their objects even if they are removed from the scene.
  For some cases that's good, for tag-like collections that's not ideal.
  We can investigate how that make those cases work better later.

* Depsgraph view layer evaluation was fixed to work with copy-on-write, and
  the code was simplified in the process.

* Various bugfixes related to static overrides, linking and outliner.

===================================================================

M	doc/python_api/examples/bpy.ops.2.py
M	release/scripts/modules/bl_previews_utils/bl_previews_render.py
M	release/scripts/modules/bpy_types.py
M	release/scripts/startup/bl_ui/properties_object.py
M	release/scripts/startup/bl_ui/space_dopesheet.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/layer.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/library_remap.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
M	source/blender/depsgraph/intern/builder/deg_builder_nodes_view_layer.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_group.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c
M	source/blender/editors/object/object_select.c
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/makesdna/DNA_group_types.h
M	source/blender/makesdna/DNA_layer_types.h
M	source/blender/makesrna/intern/rna_action.c

===================================================================

diff --git a/doc/python_api/examples/bpy.ops.2.py b/doc/python_api/examples/bpy.ops.2.py
index dd88c73d5e9..5f98c8a6656 100644
--- a/doc/python_api/examples/bpy.ops.2.py
+++ b/doc/python_api/examples/bpy.ops.2.py
@@ -20,6 +20,6 @@ The execution context is one of:
 'EXEC_SCREEN')
 """
 
-# group add popup
+# collection add popup
 import bpy
-bpy.ops.object.group_instance_add('INVOKE_DEFAULT')
+bpy.ops.object.collection_instance_add('INVOKE_DEFAULT')
diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
index 4bd6d99006e..b4ea2cbd7d2 100644
--- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py
+++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
@@ -414,7 +414,7 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern):
             scene = bpy.data.scenes[render_context.scene, None]
             bpy.context.screen.scene = scene
 
-            bpy.ops.object.group_instance_add(group=grp.name)
+            bpy.ops.object.collection_instance_add(group=grp.name)
             grp_ob = next((ob for ob in scene.objects if ob.dupli_group and ob.dupli_group.name == grp.name))
             grp_obname = grp_ob.name
             scene.update()
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 0274937613d..c33f0e26d9f 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -96,12 +96,12 @@ class Texture(bpy_types.ID):
                      )
 
 
-class Group(bpy_types.ID):
+class Collection(bpy_types.ID):
     __slots__ = ()
 
     @property
-    def users_dupli_group(self):
-        """The dupli group this group is used in"""
+    def users_dupli_collection(self):
+        """The collection instance objects this collection is used in"""
         import bpy
         return tuple(obj for obj in bpy.data.objects
                      if self == obj.dupli_group)
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index db84e7cbbf7..251f32a37e4 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -179,8 +179,8 @@ class COLLECTION_MT_specials(Menu):
     def draw(self, context):
         layout = self.layout
 
-        layout.operator("object.group_unlink", icon='X')
-        layout.operator("object.grouped_select")
+        layout.operator("object.collection_unlink", icon='X')
+        layout.operator("object.collection_objects_select")
         layout.operator("object.dupli_offset_from_cursor")
 
 
@@ -195,14 +195,13 @@ class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
 
         row = layout.row(align=True)
         if bpy.data.collections:
-            row.operator("object.group_link", text="Add to Collection")
+            row.operator("object.collection_link", text="Add to Collection")
         else:
-            row.operator("object.group_add", text="Add to Collection")
-        row.operator("object.group_add", text="", icon='ZOOMIN')
+            row.operator("object.collection_add", text="Add to Collection")
+        row.operator("object.collection_add", text="", icon='ZOOMIN')
 
         obj_name = obj.name
         for collection in bpy.data.collections:
-			# TODO: this is even slower now that all objects are in collections
             # XXX this is slow and stupid!, we need 2 checks, one thats fast
             # and another that we can be sure its not a name collision
             # from linked library data
@@ -210,11 +209,11 @@ class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
             if obj_name in collection.objects and obj in collection_objects[:]:
                 col = layout.column(align=True)
 
-                col.context_pointer_set("group", collection)
+                col.context_pointer_set("collection", collection)
 
                 row = col.box().row()
                 row.prop(collection, "name", text="")
-                row.operator("object.group_remove", text="", icon='X', emboss=False)
+                row.operator("object.collection_remove", text="", icon='X', emboss=False)
                 row.menu("COLLECTION_MT_specials", icon='DOWNARROW_HLT', text="")
 
                 row = col.box().row()
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index c91a549fc9b..c4b867ab647 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -43,9 +43,9 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False):
     if not genericFiltersOnly:
         if bpy.data.collections:
             row = layout.row(align=True)
-            row.prop(dopesheet, "show_only_group_objects", text="")
-            if dopesheet.show_only_group_objects:
-                row.prop(dopesheet, "filter_group", text="")
+            row.prop(dopesheet, "show_only_collection_objects", text="")
+            if dopesheet.show_only_collection_objects:
+                row.prop(dopesheet, "filter_collection", text="")
 
     if not is_nla:
         row = layout.row(align=True)
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 0c36d70ce3c..93019dc3686 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1337,11 +1337,11 @@ class INFO_MT_add(Menu):
 
         if len(bpy.data.collections) > 10:
             layout.operator_context = 'INVOKE_REGION_WIN'
-            layout.operator("object.group_instance_add", text="Collection Instance...", icon='OUTLINER_OB_GROUP_INSTANCE')
+            layout.operator("object.collection_instance_add", text="Collection Instance...", icon='OUTLINER_OB_GROUP_INSTANCE')
         else:
             layout.operator_menu_enum(
-                "object.group_instance_add",
-                "group",
+                "object.collection_instance_add",
+                "collection",
                 text="Collection Instance",
                 icon='OUTLINER_OB_GROUP_INSTANCE',
             )
@@ -1407,7 +1407,7 @@ class VIEW3D_MT_object(Menu):
         layout.separator()
 
         layout.menu("VIEW3D_MT_object_parent")
-        layout.menu("VIEW3D_MT_object_group")
+        layout.menu("VIEW3D_MT_object_collection")
         layout.menu("VIEW3D_MT_snap")
 
         layout.separator()
@@ -1714,21 +1714,21 @@ class VIEW3D_MT_object_track(Menu):
         layout.operator_enum("object.track_clear", "type")
 
 
-class VIEW3D_MT_object_group(Menu):
-    bl_label = "Group"
+class VIEW3D_MT_object_collection(Menu):
+    bl_label = "Collection"
 
     def draw(self, context):
         layout = self.layout
 
-        layout.operator("group.create")
-        # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
-        layout.operator("group.objects_remove")
-        layout.operator("group.objects_remove_all")
+        layout.operator("collection.create")
+        # layout.operator_menu_enum("collection.objects_remove", "collection")  # BUGGY
+        layout.operator("collection.objects_remove")
+        layout.operator("collection.objects_remove_all")
 
         layout.separator()
 
-        layout.operator("group.objects_add_active")
-        layout.operator("group.objects_remove_active")
+        layout.operator("collection.objects_add_active")
+        layout.operator("collection.objects_remove_active")
 
 
 class VIEW3D_MT_object_constraints(Menu):
@@ -3971,7 +3971,7 @@ classes = (
     VIEW3D_MT_object_apply,
     VIEW3D_MT_object_parent,
     VIEW3D_MT_object_track,
-    VIEW3D_MT_object_group,
+    VIEW3D_MT_object_collection,
     VIEW3D_MT_object_constraints,
     VIEW3D_MT_object_quick_effects,
     VIEW3D_MT_make_single_user,
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index f04d468c8a1..a08b3dbc315 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -87,6 +87,7 @@ void BKE_collections_child_remove_nulls(struct Main *bmain, struct Collection *o
 
 /* Dependencies. */
 
+bool BKE_collection_is_in_scene(struct Collection *collection);
 void BKE_collections_after_lib_link(struct Main *bmain);
 bool BKE_collection_object_cyclic_check(struct Main *bmain, struct Object *object, struct Collection *collection);
 bool BKE_collection_is_animated(struct Collection *collection, struct Object *parent);
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 041efc90f23..026ab783753 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -57,16 +57,15 @@
 
 /******************************** Prototypes ********************************/
 
-static bool collection_child_add(Collection *parent, Collection *collection);
+static bool collection_child_add(Collection *parent, Collection *collection, int flag, const bool add_us);
 static bool collection_child_remove(Collection *parent, Collection *collection);
-static bool collection_object_add(Collection *collection, Object *ob, int flag);
+static bool collection_object_add(Collection *collection, Object *ob, int flag, const bool add_us);
 static bool collection_object_remove(Main *bmain, Collection *collection, Object *ob, const bool free_us);
 
 static CollectionChild *collection_find_child(Collection *parent, Collection *collection);
 static CollectionParent *collection_find_parent(Collection *child, Collection *collection);
 
 static bool collection_find_child_recursive(Collection *parent, Collection *collection);
-static void collection_sync_in_scene_recursive(Collection *collection);
 
 /***************************** Add Collection *******************************/
 
@@ -86,13 +85,12 @@ static Collection *collection_add(Main *bmain, Collection *collection_parent, co
 	/* Create new collection. */
 	Collection *collection = BKE_libblock_alloc(bmain, ID_GR, name, 0);
 
-	/* Collections are not reference counted. */
+	/* We increase collection user count wh

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list