Render Layers and Collections (merge from render-layers)
Design Documents ---------------- * https://wiki.blender.org/index.php/Dev:2.8/Source/Layers * https://wiki.blender.org/index.php/Dev:2.8/Source/DataDesignRevised User Commit Log --------------- * New Layer and Collection system to replace render layers and viewport layers. * A layer is a set of collections of objects (and their drawing options) required for specific tasks. * A collection is a set of objects, equivalent of the old layers in Blender. A collection can be shared across multiple layers. * All Scenes have a master collection that all other collections are children of. * New collection "context" tab (in Properties Editor) * New temporary viewport "collections" panel to control per-collection visibility Missing User Features --------------------- * Collection "Filter" Option to add objects based on their names * Collection Manager operators The existing buttons are placeholders * Collection Manager drawing The editor main region is empty * Collection Override * Per-Collection engine settings This will come as a separate commit, as part of the clay-engine branch Dev Commit Log -------------- * New DNA file (DNA_layer_types.h) with the new structs We are replacing Base by a new extended Base while keeping it backward compatible with some legacy settings (i.e., lay, flag_legacy). Renamed all Base to BaseLegacy to make it clear the areas of code that still need to be converted Note: manual changes were required on - deg_builder_nodes.h, rna_object.c, KX_Light.cpp * Unittesting for main syncronization requirements - read, write, add/copy/remove objects, copy scene, collection link/unlinking, context) * New Editor: Collection Manager Based on patch by Julian Eisel This is extracted from the layer-manager branch. With the following changes: - Renamed references of layer manager to collections manager - I doesn't include the editors/space_collections/ draw and util files - The drawing code itself will be implemented separately by Julian * Base / Object: A little note about them. Original Blender code would try to keep them in sync through the code, juggling flags back and forth. This will now be handled by Depsgraph, keeping Object and Bases more separated throughout the non-rendering code. Scene.base is being cleared in doversion, and the old viewport drawing code was poorly converted to use the new bases while the new viewport code doesn't get merged and replace the old one. Python API Changes ------------------ ``` - scene.layers + # no longer exists - scene.objects + scene.scene_layers.active.objects - scene.objects.active + scene.render_layers.active.objects.active - bpy.context.scene.objects.link() + bpy.context.scene_collection.objects.link() - bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None) + bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None) - bpy.context.object.select + bpy.context.object.select = True + bpy.context.object.select = False + bpy.context.object.select_get() + bpy.context.object.select_set(action='SELECT') + bpy.context.object.select_set(action='DESELECT') -AddObjectHelper.layers + # no longer exists ```
This commit is contained in:
@@ -103,9 +103,9 @@ def add_object_align_init(context, operator):
|
||||
return location * rotation
|
||||
|
||||
|
||||
def object_data_add(context, obdata, operator=None, use_active_layer=True, name=None):
|
||||
def object_data_add(context, obdata, operator=None, name=None):
|
||||
"""
|
||||
Add an object using the view context and preference to to initialize the
|
||||
Add an object using the view context and preference to initialize the
|
||||
location, rotation and layer.
|
||||
|
||||
:arg context: The context to use.
|
||||
@@ -117,52 +117,24 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
|
||||
:arg name: Optional name
|
||||
:type name: string
|
||||
:return: the newly created object in the scene.
|
||||
:rtype: :class:`bpy.types.ObjectBase`
|
||||
:rtype: :class:`bpy.types.Object`
|
||||
"""
|
||||
scene = context.scene
|
||||
layer = context.render_layer
|
||||
scene_collection = context.scene_collection
|
||||
|
||||
# ugh, could be made nicer
|
||||
for ob in scene.objects:
|
||||
ob.select = False
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
||||
if name is None:
|
||||
name = "Object" if obdata is None else obdata.name
|
||||
|
||||
obj_new = bpy.data.objects.new(name, obdata)
|
||||
|
||||
base = scene.objects.link(obj_new)
|
||||
base.select = True
|
||||
|
||||
v3d = None
|
||||
if context.space_data and context.space_data.type == 'VIEW_3D':
|
||||
v3d = context.space_data
|
||||
|
||||
if v3d and v3d.local_view:
|
||||
base.layers_from_view(context.space_data)
|
||||
|
||||
if operator is not None and any(operator.layers):
|
||||
base.layers = operator.layers
|
||||
else:
|
||||
if use_active_layer:
|
||||
if v3d and v3d.local_view:
|
||||
base.layers[scene.active_layer] = True
|
||||
else:
|
||||
if v3d and not v3d.lock_camera_and_layers:
|
||||
base.layers = [True if i == v3d.active_layer
|
||||
else False for i in range(len(v3d.layers))]
|
||||
else:
|
||||
base.layers = [True if i == scene.active_layer
|
||||
else False for i in range(len(scene.layers))]
|
||||
else:
|
||||
if v3d:
|
||||
base.layers_from_view(context.space_data)
|
||||
|
||||
if operator is not None:
|
||||
operator.layers = base.layers
|
||||
scene_collection.objects.link(obj_new)
|
||||
obj_new.select_set(action='SELECT')
|
||||
|
||||
obj_new.matrix_world = add_object_align_init(context, operator)
|
||||
|
||||
obj_act = scene.objects.active
|
||||
obj_act = layer.objects.active
|
||||
|
||||
# XXX
|
||||
# caused because entering edit-mode does not add a empty undo slot!
|
||||
@@ -174,8 +146,8 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
|
||||
_obdata = bpy.data.meshes.new(name)
|
||||
obj_act = bpy.data.objects.new(_obdata.name, _obdata)
|
||||
obj_act.matrix_world = obj_new.matrix_world
|
||||
scene.objects.link(obj_act)
|
||||
scene.objects.active = obj_act
|
||||
scene_collection.objects.link(obj_act)
|
||||
layer.objects.active = obj_act
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
# need empty undo step
|
||||
bpy.ops.ed.undo_push(message="Enter Editmode")
|
||||
@@ -185,7 +157,7 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
|
||||
bpy.ops.mesh.select_all(action='DESELECT')
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
|
||||
obj_act.select = True
|
||||
obj_act.select_set(action='SELECT')
|
||||
scene.update() # apply location
|
||||
# scene.objects.active = obj_new
|
||||
|
||||
@@ -200,16 +172,14 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
|
||||
bpy.ops.object.join() # join into the active.
|
||||
if obdata:
|
||||
bpy.data.meshes.remove(obdata)
|
||||
# base is freed, set to active object
|
||||
base = scene.object_bases.active
|
||||
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
else:
|
||||
scene.objects.active = obj_new
|
||||
layer.objects.active = obj_new
|
||||
if context.user_preferences.edit.use_enter_edit_mode:
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
|
||||
return base
|
||||
return obj_new
|
||||
|
||||
|
||||
class AddObjectHelper:
|
||||
@@ -230,12 +200,6 @@ class AddObjectHelper:
|
||||
name="Rotation",
|
||||
subtype='EULER',
|
||||
)
|
||||
layers = BoolVectorProperty(
|
||||
name="Layers",
|
||||
size=20,
|
||||
subtype='LAYER',
|
||||
options={'HIDDEN', 'SKIP_SAVE'},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(self, context):
|
||||
|
Reference in New Issue
Block a user