Files
blender/release/scripts/startup/bl_ui/properties_object.py
Brecht Van Lommel 17bd5c9d4b Collections and groups unification
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 excluded
  for each. For many workflows one view layer can be used, these are more of an
  advanced feature now.

OUTLINER

* The outliner now has a "View Layer" display mode instead of "Collections",
  which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
  These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
  can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
  text gives different results, we'll unify this later.

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 unreliable 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

* We tried to make performance not worse than before and improve it in some
  cases. The main thing that's still a bit slower is multiple scenes, we have to
  change the layer syncing to only updated affected scenes.
* 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().

VERSIONING

* Compatibility with 2.7 files should be improved due to the new visibility
  controls. Of course users may not want to set up their scenes differently
  now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
  files. There's a few things which are know to be not quite compatible, like
  nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
  #ifdef so it can be removed at the end of the release cycle.

KNOWN ISSUES

* 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, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
  be done later, we'll have to see how important this is as all objects within
  the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.

Differential Revision: https://developer.blender.org/D3383

https://code.blender.org/2018/05/collections-and-groups/
2018-05-18 13:34:24 +02:00

388 lines
12 KiB
Python

# ##### 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, Menu
from rna_prop_ui import PropertyPanel
class ObjectButtonsPanel:
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "object"
class OBJECT_PT_context_object(ObjectButtonsPanel, Panel):
bl_label = ""
bl_options = {'HIDE_HEADER'}
def draw(self, context):
layout = self.layout
space = context.space_data
if space.use_pin_id:
layout.template_ID(space, "pin_id")
else:
row = layout.row()
row.template_ID(context.view_layer.objects, "active", filter='AVAILABLE')
class OBJECT_PT_transform(ObjectButtonsPanel, Panel):
bl_label = "Transform"
def draw(self, context):
layout = self.layout
ob = context.object
row = layout.row()
row.column().prop(ob, "location")
if ob.rotation_mode == 'QUATERNION':
row.column().prop(ob, "rotation_quaternion", text="Rotation")
elif ob.rotation_mode == 'AXIS_ANGLE':
#row.column().label(text="Rotation")
#row.column().prop(pchan, "rotation_angle", text="Angle")
#row.column().prop(pchan, "rotation_axis", text="Axis")
row.column().prop(ob, "rotation_axis_angle", text="Rotation")
else:
row.column().prop(ob, "rotation_euler", text="Rotation")
row.column().prop(ob, "scale")
layout.prop(ob, "rotation_mode")
class OBJECT_PT_delta_transform(ObjectButtonsPanel, Panel):
bl_label = "Delta Transform"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
ob = context.object
row = layout.row()
row.column().prop(ob, "delta_location")
if ob.rotation_mode == 'QUATERNION':
row.column().prop(ob, "delta_rotation_quaternion", text="Rotation")
elif ob.rotation_mode == 'AXIS_ANGLE':
#row.column().label(text="Rotation")
#row.column().prop(pchan, "delta_rotation_angle", text="Angle")
#row.column().prop(pchan, "delta_rotation_axis", text="Axis")
#row.column().prop(ob, "delta_rotation_axis_angle", text="Rotation")
row.column().label(text="Not for Axis-Angle")
else:
row.column().prop(ob, "delta_rotation_euler", text="Delta Rotation")
row.column().prop(ob, "delta_scale")
class OBJECT_PT_transform_locks(ObjectButtonsPanel, Panel):
bl_label = "Transform Locks"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
ob = context.object
split = layout.split(percentage=0.1)
col = split.column(align=True)
col.label(text="")
col.label(text="X:")
col.label(text="Y:")
col.label(text="Z:")
split.column().prop(ob, "lock_location", text="Location")
split.column().prop(ob, "lock_rotation", text="Rotation")
split.column().prop(ob, "lock_scale", text="Scale")
if ob.rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}:
row = layout.row()
row.prop(ob, "lock_rotations_4d", text="Lock Rotation")
sub = row.row()
sub.active = ob.lock_rotations_4d
sub.prop(ob, "lock_rotation_w", text="W")
class OBJECT_PT_relations(ObjectButtonsPanel, Panel):
bl_label = "Relations"
def draw(self, context):
layout = self.layout
ob = context.object
split = layout.split()
col = split.column()
col.prop(ob, "pass_index")
col = split.column()
col.label(text="Parent:")
col.prop(ob, "parent", text="")
sub = col.column()
sub.prop(ob, "parent_type", text="")
parent = ob.parent
if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE':
sub.prop_search(ob, "parent_bone", parent.data, "bones", text="")
sub.active = (parent is not None)
class OBJECT_PT_relations_extras(ObjectButtonsPanel, Panel):
bl_label = "Relations Extras"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
ob = context.object
split = layout.split()
col = split.column()
col.label(text="Tracking Axes:")
col.prop(ob, "track_axis", text="Axis")
col.prop(ob, "up_axis", text="Up Axis")
col = split.column()
col.prop(ob, "use_slow_parent")
row = col.row()
row.active = ((ob.parent is not None) and (ob.use_slow_parent))
row.prop(ob, "slow_parent_offset", text="Offset")
class COLLECTION_MT_specials(Menu):
bl_label = "Collection Specials"
def draw(self, context):
layout = self.layout
layout.operator("object.collection_unlink", icon='X')
layout.operator("object.collection_objects_select")
layout.operator("object.dupli_offset_from_cursor")
class OBJECT_PT_collections(ObjectButtonsPanel, Panel):
bl_label = "Collections"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row(align=True)
if bpy.data.collections:
row.operator("object.collection_link", text="Add to Collection")
else:
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:
# 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
collection_objects = collection.objects
if obj_name in collection.objects and obj in collection_objects[:]:
col = layout.column(align=True)
col.context_pointer_set("collection", collection)
row = col.box().row()
row.prop(collection, "name", text="")
row.operator("object.collection_remove", text="", icon='X', emboss=False)
row.menu("COLLECTION_MT_specials", icon='DOWNARROW_HLT', text="")
row = col.box().row()
row.prop(collection, "dupli_offset", text="")
class OBJECT_PT_display(ObjectButtonsPanel, Panel):
bl_label = "Display"
def draw(self, context):
layout = self.layout
obj = context.object
obj_type = obj.type
is_geometry = (obj_type in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'})
is_wire = (obj_type in {'CAMERA', 'EMPTY'})
is_empty_image = (obj_type == 'EMPTY' and obj.empty_draw_type == 'IMAGE')
is_dupli = (obj.dupli_type != 'NONE')
split = layout.split()
col = split.column()
col.prop(obj, "show_name", text="Name")
col.prop(obj, "show_axis", text="Axis")
# Makes no sense for cameras, armatures, etc.!
# but these settings do apply to dupli instances
if is_geometry or is_dupli:
col.prop(obj, "show_wire", text="Wire")
if obj_type == 'MESH' or is_dupli:
col.prop(obj, "show_all_edges")
col = split.column()
row = col.row()
row.prop(obj, "show_bounds", text="Bounds")
sub = row.row()
sub.active = obj.show_bounds
sub.prop(obj, "draw_bounds_type", text="")
if is_geometry:
col.prop(obj, "show_texture_space", text="Texture Space")
col.prop(obj.display, "show_shadows")
col.prop(obj, "show_x_ray", text="X-Ray")
if obj_type == 'MESH' or is_empty_image:
col.prop(obj, "show_transparent", text="Transparency")
split = layout.split()
col = split.column()
if is_wire:
# wire objects only use the max. draw type for duplis
col.active = is_dupli
col.label(text="Maximum Dupli Draw Type:")
else:
col.label(text="Maximum Draw Type:")
col.prop(obj, "draw_type", text="")
col = split.column()
if is_geometry or is_empty_image:
# Only useful with object having faces/materials...
col.label(text="Object Color:")
col.prop(obj, "color", text="")
col = layout.column()
col.active = bool(is_dupli or obj.particle_systems)
col.label(text="Duplicator Visibility:")
row = col.row(align=True)
row.prop(obj, "show_duplicator_for_viewport", text="Viewport")
row.prop(obj, "show_duplicator_for_render", text="Render")
class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
bl_label = "Duplication"
def draw(self, context):
layout = self.layout
ob = context.object
layout.row().prop(ob, "dupli_type", expand=True)
if ob.dupli_type == 'FRAMES':
split = layout.split()
col = split.column(align=True)
col.prop(ob, "dupli_frames_start", text="Start")
col.prop(ob, "dupli_frames_end", text="End")
col = split.column(align=True)
col.prop(ob, "dupli_frames_on", text="On")
col.prop(ob, "dupli_frames_off", text="Off")
layout.prop(ob, "use_dupli_frames_speed", text="Speed")
elif ob.dupli_type == 'VERTS':
layout.prop(ob, "use_dupli_vertices_rotation", text="Rotation")
elif ob.dupli_type == 'FACES':
row = layout.row()
row.prop(ob, "use_dupli_faces_scale", text="Scale")
sub = row.row()
sub.active = ob.use_dupli_faces_scale
sub.prop(ob, "dupli_faces_scale", text="Inherit Scale")
elif ob.dupli_type == 'COLLECTION':
layout.prop(ob, "dupli_group", text="Collection")
from .properties_animviz import (
MotionPathButtonsPanel,
OnionSkinButtonsPanel,
)
class OBJECT_PT_motion_paths(MotionPathButtonsPanel, Panel):
#bl_label = "Object Motion Paths"
bl_context = "object"
@classmethod
def poll(cls, context):
return (context.object)
def draw(self, context):
# layout = self.layout
ob = context.object
avs = ob.animation_visualization
mpath = ob.motion_path
self.draw_settings(context, avs, mpath)
class OBJECT_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from panel when ready
#bl_label = "Object Onion Skinning"
bl_context = "object"
@classmethod
def poll(cls, context):
return (context.object)
def draw(self, context):
ob = context.object
self.draw_settings(context, ob.animation_visualization)
class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "object"
_property_type = bpy.types.Object
classes = (
OBJECT_PT_context_object,
OBJECT_PT_transform,
OBJECT_PT_delta_transform,
OBJECT_PT_transform_locks,
OBJECT_PT_relations,
OBJECT_PT_relations_extras,
COLLECTION_MT_specials,
OBJECT_PT_collections,
OBJECT_PT_display,
OBJECT_PT_duplication,
OBJECT_PT_motion_paths,
OBJECT_PT_custom_props,
)
if __name__ == "__main__": # only for live edit.
from bpy.utils import register_class
for cls in classes:
register_class(cls)