Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_object.py
| Show All 16 Lines | |||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| from bl_ui.properties_animviz import ( | from bl_ui.properties_animviz import ( | ||||
| MotionPathButtonsPanel, | MotionPathButtonsPanel, | ||||
| MotionPathButtonsPanel_display, | MotionPathButtonsPanel_display, | ||||
| ) | ) | ||||
| import bpy | import bpy | ||||
| from bpy.types import Panel, Menu | from bpy.types import Panel, Menu, UIList | ||||
| from rna_prop_ui import PropertyPanel | from rna_prop_ui import PropertyPanel | ||||
| class ObjectButtonsPanel: | class ObjectButtonsPanel: | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "object" | bl_context = "object" | ||||
| ▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| ob = context.object | ob = context.object | ||||
| avs = ob.animation_visualization | avs = ob.animation_visualization | ||||
| mpath = ob.motion_path | mpath = ob.motion_path | ||||
| self.draw_settings(context, avs, mpath) | self.draw_settings(context, avs, mpath) | ||||
| class OBJECT_UL_bake_passes(UIList): | |||||
| def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): | |||||
| layer = item | |||||
| if self.layout_type in {'DEFAULT', 'COMPACT'}: | |||||
| layout.prop(layer, "name", text="", icon_value=icon, emboss=False) | |||||
| layout.prop(layer, "enable", text="", index=index) | |||||
| elif self.layout_type == 'GRID': | |||||
| layout.alignment = 'CENTER' | |||||
| layout.label("", icon_value=icon) | |||||
| class OBJECT_PT_bake_passes(ObjectButtonsPanel, Panel): | |||||
| bl_label = "Baking" | |||||
| bl_context = "object" | |||||
| bl_options = {'DEFAULT_CLOSED'} | |||||
| # Engines that support baking add themselves to COMPAT_ENGINES. | |||||
| COMPAT_ENGINES = {'BLENDER_RENDER'} | |||||
| @classmethod | |||||
| def poll(cls, context): | |||||
| return context.engine in cls.COMPAT_ENGINES | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| rd = context.scene.render | |||||
| row = layout.row() | |||||
| has_enabled_passes = len([bp for bp in context.object.bake_passes if bp.enable]) > 0 | |||||
| row.active = rd.use_bake_multires or has_enabled_passes | |||||
| row.operator("object.bake", icon='RENDER_STILL') | |||||
| layout.prop(rd, "use_bake_multires") | |||||
| if rd.use_bake_multires: | |||||
| layout.prop(rd, "bake_type") | |||||
| else: | |||||
| ob = context.object | |||||
| row = layout.row() | |||||
| col = row.column() | |||||
| col.template_list("OBJECT_UL_bake_passes", "", ob, "bake_passes", ob.bake_passes, "active_index", rows=2) | |||||
| col = row.column() | |||||
| sub = col.column(align=True) | |||||
| sub.operator("object.bake_pass_add", icon='ADD', text="") | |||||
| sub.operator("object.bake_pass_remove", icon='REMOVE', text="") | |||||
| bp = context.object.bake_passes.active | |||||
| if bp: | |||||
| col = layout.column(align=True) | |||||
| # TODO: How to align this properly? | |||||
| class OBJECT_PT_bake_input(ObjectButtonsPanel, Panel): | |||||
| bl_label = "Input" | |||||
| bl_context = "object" | |||||
| bl_parent_id = "OBJECT_PT_bake_passes" | |||||
| @classmethod | |||||
| def poll(cls, context): | |||||
| scene = context.scene | |||||
| rd = scene.render | |||||
| bp = context.object.bake_passes.active | |||||
| return bp and not rd.use_bake_multires | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| layout.use_property_split = True | |||||
| layout.use_property_decorate = False # No animation. | |||||
| ob = context.object | |||||
| bp = ob.bake_passes.active | |||||
| col = layout.column(align=True) | |||||
| col.prop_search(bp, "uv_layer", ob.data, "uv_layers", icon='GROUP_UVS') | |||||
| col.prop(bp, "material", text="Filter Material") | |||||
| col.prop(bp, "bake_from_collection", text="From Collection") | |||||
| col = layout.column(align=True) | |||||
| col.active = bp.bake_from_collection is not None | |||||
| col.prop(bp, "use_cage", text="Use Cage") | |||||
| if bp.use_cage: | |||||
| col.prop(bp, "cage_extrusion", text="Extrusion") | |||||
| col.prop(bp, "cage_object", text="Cage Object") | |||||
| else: | |||||
| col.prop(bp, "cage_extrusion", text="Ray Distance") | |||||
| class OBJECT_PT_bake_output(ObjectButtonsPanel, Panel): | |||||
| bl_label = "Output" | |||||
| bl_context = "object" | |||||
| bl_parent_id = "OBJECT_PT_bake_passes" | |||||
| @classmethod | |||||
| def poll(cls, context): | |||||
| scene = context.scene | |||||
| rd = scene.render | |||||
| bp = context.object.bake_passes.active | |||||
| return rd.use_bake_multires or bp | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| layout.use_property_split = True | |||||
| layout.use_property_decorate = False # No animation. | |||||
| scene = context.scene | |||||
| rd = scene.render | |||||
| if rd.use_bake_multires: | |||||
| layout.prop(rd, "bake_margin") | |||||
| layout.prop(rd, "use_bake_clear", text="Clear Image") | |||||
| if rd.bake_type == 'DISPLACEMENT': | |||||
| layout.prop(rd, "use_bake_lores_mesh") | |||||
| else: | |||||
| bp = context.object.bake_passes.active | |||||
| layout.template_ID(bp, "image", new="IMAGE_OT_new") | |||||
| layout.prop(bp, "margin") | |||||
| layout.prop(bp, "use_clear", text="Clear Image") | |||||
| class OBJECT_PT_motion_paths_display(MotionPathButtonsPanel_display, Panel): | class OBJECT_PT_motion_paths_display(MotionPathButtonsPanel_display, Panel): | ||||
| #bl_label = "Object Motion Paths" | #bl_label = "Object Motion Paths" | ||||
| bl_context = "object" | bl_context = "object" | ||||
| bl_parent_id = "OBJECT_PT_motion_paths" | bl_parent_id = "OBJECT_PT_motion_paths" | ||||
| bl_options = {'DEFAULT_CLOSED'} | bl_options = {'DEFAULT_CLOSED'} | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | classes = ( | ||||
| OBJECT_PT_instancing, | OBJECT_PT_instancing, | ||||
| OBJECT_PT_instancing_size, | OBJECT_PT_instancing_size, | ||||
| OBJECT_PT_motion_paths, | OBJECT_PT_motion_paths, | ||||
| OBJECT_PT_motion_paths_display, | OBJECT_PT_motion_paths_display, | ||||
| OBJECT_PT_display, | OBJECT_PT_display, | ||||
| OBJECT_PT_display_bounds, | OBJECT_PT_display_bounds, | ||||
| OBJECT_PT_visibility, | OBJECT_PT_visibility, | ||||
| OBJECT_PT_custom_props, | OBJECT_PT_custom_props, | ||||
| OBJECT_UL_bake_passes, | |||||
| OBJECT_PT_bake_passes, | |||||
| OBJECT_PT_bake_output, | |||||
| OBJECT_PT_bake_input, | |||||
| ) | ) | ||||
| if __name__ == "__main__": # only for live edit. | if __name__ == "__main__": # only for live edit. | ||||
| from bpy.utils import register_class | from bpy.utils import register_class | ||||
| for cls in classes: | for cls in classes: | ||||
| register_class(cls) | register_class(cls) | ||||