[Bf-blender-cvs] [e289dc2a281] temp-unified-collections: Collections and groups unification

Brecht Van Lommel noreply at git.blender.org
Fri May 11 17:28:53 CEST 2018


Commit: e289dc2a281370d47529d7f01f6845759ac656ff
Author: Brecht Van Lommel
Date:   Mon Apr 30 15:57:22 2018 +0200
Branches: temp-unified-collections
https://developer.blender.org/rBe289dc2a281370d47529d7f01f6845759ac656ff

Collections and groups unification

NOTE that this branch still has known bugs and TODO comments, it's not
ready to merge or save files with. I'm publishing it now for review of
the overall design.

OVERVIEW

* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
  which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
  and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is used
  for each. For many workflows one view layer can be used, these are more of
  an advanced feature now.

OUTLINER

* The related outliner categories were reorganized to be:
** Collections: display collections and their objects
** Objects: display all objects in the scene with parenting hierarchy
** View Layer: edit which collections are used in the view layer
* In the collections category we can switch between showing collections in
  the scene, unlinked collections not linked in any scene, and all in the file.
* The outliner right click menus for collections and objects were reorganized.

GROUP OPERATORS

* The G-key group operators in the 3D viewport were left mostly as is, they
  need to be modified still to fit better.
* Same for the groups panel in the object properties, this needs to be updated
  still.

LINKING AND OVERRIDES

* Collections can now be linked into the scene without creating an instance,
  with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
  but this is rather tedious and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
  into collections with overrides directly in the scene.

PERFORMANCE

* I tried to make performance not worse than before and improve it in some
  cases. There are still quite some quadratic time operations in object
  add / delete which would require much deeper changes to fix.
* Collections keep a list of their parent collections for faster incremental
  updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
  lookups internally and in API functions like visible_get().

TRICKY IMPLEMENTATION BITS

* I didn't yet rename all files to preserve git history a bit better, probably
  this is best done as a second commit after merging.
* Renaming collections to groups involved some DNA/RNA trickery to preserve
  backwards compatibility, in the DNA the struct is still "Group".

* Version patching of 2.7 skips all the 2.8 collection patching and immediately
  convertions to the new data structures.
* Version patching tries to keep 2.8 files works more or less, but some data is
  lost. Keeping it all would be quite complicated. This needs more testing,
  especially on Hero files.

* Collections are not reference counted just like groups weren't, they must be
  explicitly deleted by the user.
* Object ownership is similar to what it was before, in that collection used
  in a scene increment the object user counts but collections not used in any
  scene do not.
* This involves some tagging each collection as being in a scene or not and
  keeping that synchronized on changes.

* View layers each have a tree of layer collections which mirror the scene
  collection tree (including linked collections). This require relatively
  complicated synchronization as collections can change in linked files.

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

M	release/scripts/modules/bl_previews_utils/bl_previews_render.py
M	release/scripts/modules/bpy_types.py
D	release/scripts/startup/bl_ui/properties_collection.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_outliner.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/alembic/intern/alembic_capi.cc
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/BKE_collision.h
M	source/blender/blenkernel/BKE_context.h
M	source/blender/blenkernel/BKE_effect.h
M	source/blender/blenkernel/BKE_freestyle.h
D	source/blender/blenkernel/BKE_group.h
M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/BKE_main.h
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/blender_copybuffer.c
M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/collision.c
M	source/blender/blenkernel/intern/context.c
M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/blenkernel/intern/freestyle.c
D	source/blender/blenkernel/intern/group.c
M	source/blender/blenkernel/intern/icons.c
M	source/blender/blenkernel/intern/idcode.c
M	source/blender/blenkernel/intern/layer.c
M	source/blender/blenkernel/intern/library.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/library_remap.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/softbody.c
M	source/blender/blenloader/BLO_readfile.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_260.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_legacy.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/blentranslation/BLT_translation.h
M	source/blender/collada/DocumentImporter.cpp
M	source/blender/collada/SceneExporter.cpp
M	source/blender/collada/collada_utils.cpp
M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
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/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_intern.h
M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/engines/eevee/eevee_private.h
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/include/ED_fileselect.h
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_edit.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_relations.c
M	source/blender/editors/object/object_select.c
M	source/blender/editors/physics/rigidbody_constraint.c
M	source/blender/editors/physics/rigidbody_object.c
M	source/blender/editors/render/render_preview.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/editors/space_file/fsmenu.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_info/info_stats.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_edit.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_ops.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_tools.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/outliner_utils.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_ops.c
M	source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M	source/blender/gpu/intern/gpu_material.c
M	source/blender/makesdna/DNA_action_types.h
M	source/blender/makesdna/DNA_cloth_types.h
M	source/blender/makesdna/DNA_dynamicpaint_types.h
M	source/blender/makesdna/DNA_effect_types.h
M	source/blender/makesdna/DNA_freestyle_types.h
M	source/blender/makesdna/DNA_group_types.h
M	source/blender/makesdna/DNA_layer_types.h
M	source/blender/makesdna/DNA_lightprobe_types.h
M	source/blender/makesdna/DNA_object_force_types.h
M	source/blender/makesdna/DNA_object_types.h
M	source/blender/makesdna/DNA_outliner_types.h
M	source/blender/makesdna/DNA_particle_types.h
M	source/blender/makesdna/DNA_rigidbody_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesdna/intern/dna_genfile.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_ID.c
M	source/blender/makesrna/intern/rna_context.c
M	source/blender/makesrna/intern/rna_dynamicpaint.c
M	source/blender/makesrna/intern/rna_group.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_layer.c
M	source/blender/makesrna/intern/rna_lightprobe.c
M	source/blender/makesrna/intern/rna_main.c
M	source/blender/makesrna/intern/rna_main_api.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_object_force.c
M	source/blender/makesrna/intern/rna_particle.c
M	source/blender/makesrna/intern/rna_rigidbody.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_smoke.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/python/intern/bpy_library_load.c
M	source/blender/render/intern/source/pipeline.c
M	source/blender/windowmanager/intern/wm_files_link.c
M	source/blender/windowmanager/intern/wm_operators.c

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

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 32266e972bb..4bd6d99006e 100644
--- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py
+++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
@@ -399,7 +399,7 @@ def do_previews(do_objects, do_groups, do_scenes, do_data_intern):
                 ob.hide_render = is_rendered
 
     if do_groups:
-        for grp in ids_nolib(bpy.data.groups):
+        for grp in ids_nolib(bpy.data.collections):
             if grp.name in groups_ignored:
                 continue
             # Here too, we do want to keep linked objects members of local group...
@@ -471,7 +471,7 @@ def do_clear_previews(do_objects, do_groups, do_scenes, do_data_intern):
             ob.preview.image_size = (0, 0)
 
     if do_groups:
-        for grp in ids_nolib(bpy.data.groups):
+        for grp in ids_nolib(bpy.data.collections):
             grp.preview.image_size = (0, 0)
 
     if do_scenes:
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 324bb43d890..0274937613d 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -60,7 +60,7 @@ class Library(bpy_types.ID):
         # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE,
         # we could make this an attribute in rna.
         attr_links = ("actions", "armatures", "brushes", "cameras",
-                      "curves", "grease_pencil", "groups", "images",
+                      "curves", "grease_pencil", "collections", "images",
                       "lamps", "lattices", "materials", "metaballs",
                       "meshes", "node_groups", "objects", "scenes",
                       "sounds", "speakers", "textures", "texts",
@@ -119,9 +119,9 @@ class Object(bpy_types.ID):
 
     @property
     def users_group(self):
-        """The groups this object is in"""
+        """The collections this object is in"""
         import bpy
-        return tuple(group for group in bpy.data.groups
+        return tuple(group for group in bpy.data.collections
                      if self in group.objects[:])
 
     @property
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
deleted file mode 100644
index 0721ad19f2d..00000000000
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# ##### BEGIN GPL LICENSE BLOCK #####
-#
-#  This program is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ##### END GPL LICENSE BLOCK #####
-
-# <pep8 compliant>
-import bpy
-from bpy.types import Panel
-
-
-class CollectionButtonsPanel:
-    bl_space_type = 'PROPERTIES'
-    bl_region_type = 'WINDOW'
-    bl_context = "collection"
-
-
-def get_collection_from_context(context):
-    active_object = context.active_object
-
-    if active_object and active_object.dupli_group and context.space_data.collection_context == 'GROUP':
-        group = active_object.dupli_group
-        return group.view_layer.collections.active
-    else:
-        return context.layer_collection
-
-
-class COLLECTION_PT_context_collection(CollectionButtonsPanel, Panel):
-    bl_label = ""
-    bl_options = {'HIDE_HEADER'}
-
-    def draw(self, context):
-        layout = self.layout
-        space = context.space_data
-        active_object = context.active_object
-
-        if active_object and active_object.dupli_group:
-            split = layout.split(percentage=0.2)
-            split.row().prop(space, "collection_context", expand=True)
-            layout = split
-
-        collection = get_collection_from_context(context)
-        name = collection.name
-        if name == 'Master Collection':
-            layout.label(text=name, icon='COLLAPSEMENU')
-        else:
-            layout.prop(collection, "name", text="", icon='COLLAPSEMENU')
-
-
-classes = (
-    COLLECTION_PT_context_collection,
-)
-
-if __name__ == "__main__":  # only for live edit.
-    from bpy.utils import register_class
-    for cls in classes:
-        register_class(cls)
diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
index 95193b68945..db84e7cbbf7 100644
--- a/release/scripts/startup/bl_ui/properties_object.py
+++ b/release/scripts/startup/bl_ui/properties_object.py
@@ -173,8 +173,8 @@ class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
         row.prop(ob, "slow_parent_offset", text="Offset")
 
 
-class GROUP_MT_specials(Menu):
-    bl_label = "Group Specials"
+class COLLECTION_MT_specials(Menu):
+    bl_label = "Collection Specials"
 
     def draw(self, context):
         layout = self.layout
@@ -184,8 +184,9 @@ class GROUP_MT_specials(Menu):
         layout.operator("object.dupli_offset_from_cursor")
 
 
-class OBJECT_PT_groups(ObjectButtonsPanel, Panel):
-    bl_label = "Groups"
+class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
+    bl_label = "Collections"
+    bl_options = {'DEFAULT_CLOSED'}
 
     def draw(self, context):
         layout = self.layout
@@ -193,30 +194,31 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel):
         obj = context.object
 
         row = layout.row(align=True)
-        if bpy.data.groups:
-            row.operator("object.group_link", text="Add to Group")
+        if bpy.data.collections:
+            row.operator("object.group_link", text="Add to Collection")
         else:
-            row.operator("object.group_add", text="Add to Group")
+            row.operator("object.group_add", text="Add to Collection")
         row.operator("object.group_add", text="", icon='ZOOMIN')
 
         obj_name = obj.name
-        for group in bpy.data.groups:
+        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
-            group_objects = group.objects
-            if obj_name in group.objects and obj in group_objects[:]:
+            collection_objects = collection.objects
+            if obj_name in collection.objects and obj in collection_objects[:]:
                 col = layout.column(align=True)
 
-                col.context_pointer_set("group", group)
+                col.context_pointer_set("group", collection)
 
                 row = col.box().row()
-                row.prop(group, "name", text="")
+                row.prop(collection, "name", text="")
                 row.operator("object.group_remove", text="", icon='X', emboss=False)
-                row.menu("GROUP_MT_specials", icon='DOWNARROW_HLT', text="")
+                row.menu("COLLECTION_MT_specials", icon='DOWNARROW_HLT', text="")
 
                 row = col.box().row()
-                row.prop(group, "dupli_offset", text="")
+                row.prop(collection, "dupli_offset", text="")
 
 
 class OBJECT_PT_display(ObjectButtonsPanel, Panel):
@@ -372,8 +374,8 @@ classes = (
     OBJECT_PT_transform_locks,
     OBJECT_PT_relations,
     OBJECT_PT_relations_extras,
-    GROUP_MT_specials,
-    OBJECT_PT_groups,
+    COLLECTION_MT_specials,
+    OBJECT_PT_collections,
     OBJECT_PT_display,
     OBJECT_PT_duplication,
     OBJECT_PT_motion_paths,
diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index 1b8582ba8f2..c91a549fc9b 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -41,7 +41,7 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False):
         row.prop(dopesheet, "show_only_errors", text="")
 
     if not genericFiltersOnly:
-        if bpy.data.groups:
+        if bpy.data.collections:
             row = layout.row(align=True)
             row.prop(dopesheet, "show_only_group_objects", text="")
             if dopesheet.show_only_group_objects:
diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 6441f70b4d8..3c20d92106e 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -31,16 +31,23 @@ class OUTLINER_HT_header(Header):
         display_mode = space.display_mode
         scene = context.scene
         ks = context.scene.keying_sets.active
-        support_filters = display_mode in {'COLLECTIONS', 'VIEW_LAYER'}
 
         row = layout.row(align=True)
         row.template_header()
 
         layout.prop(space, "display_mode", text="")
 
+        row = layout.row()
+        if display_mode in {'OBJECTS', 'COLLECTIONS'}:
+            row.popover(space_type='OUTLINER',
+                        region_type='HEADER',
+                        panel_type="OUTLINER_PT_filter",
+                        text="",
+                        icon='FILTER')
+
         OUTLINER_MT_editor_menus.draw_collapsible(context, layout)
 
-        if space.display_mode == 'DATABLOCKS':
+        if display_mode == 'DATABLOCKS':
             layout.separator()
 
             row = layout.row(align=True)
@@ -65,14 +72,6 @@ class OUTLINER_HT_header(Header):
             row.prop(space, "use_filter_complete", text="")
             row.prop(space, "use_filter_case_sensitive", text="")
 
-        row = layout.row()
-        if support_filters:
-            row.popover(space_type='OUTLINER

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list