2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2022-06-28 10:49:51 +10:00
|
|
|
|
|
|
|
|
from bpy.types import (
|
|
|
|
|
Collection,
|
|
|
|
|
Menu,
|
|
|
|
|
Panel,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from rna_prop_ui import PropertyPanel
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class CollectionButtonsPanel:
|
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
|
bl_context = "collection"
|
|
|
|
|
|
2021-06-28 15:46:26 +08:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
return context.collection != context.scene.collection
|
|
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
def lineart_make_line_type_entry(col, line_type, text_disp, expand, search_from):
|
|
|
|
|
col.prop(line_type, "use", text=text_disp)
|
|
|
|
|
if line_type.use and expand:
|
|
|
|
|
col.prop_search(line_type, "layer", search_from,
|
|
|
|
|
"layers", icon='GREASEPENCIL')
|
2021-07-06 12:05:27 +10:00
|
|
|
col.prop_search(line_type, "material", search_from,
|
2021-03-16 19:35:53 +01:00
|
|
|
"materials", icon='SHADING_TEXTURE')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class COLLECTION_PT_collection_flags(CollectionButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Restrictions"
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
|
|
|
|
|
collection = context.collection
|
|
|
|
|
vl = context.view_layer
|
|
|
|
|
vlc = vl.active_layer_collection
|
|
|
|
|
|
|
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.prop(collection, "hide_select", text="Selectable", toggle=False, invert_checkbox=True)
|
|
|
|
|
col.prop(collection, "hide_render", toggle=False)
|
|
|
|
|
|
|
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.prop(vlc, "holdout", toggle=False)
|
|
|
|
|
col.prop(vlc, "indirect_only", toggle=False)
|
|
|
|
|
|
|
|
|
|
|
Add Instance Offset operators to Collections property panel
Add three operators to the Collections properties panel:
- `object.instance_offset_to_cursor`, which is already available from
the Object properties panel. The operator works on the active
collection, though, so it's weird to not have it in the Collections
panel.
- `object.instance_offset_from_object` is a new operator, which performs
the same operation as above, but then based on the active object's
evaluated world position.
- `object.instance_offset_to_cursor` is also new, and performs the
opposite of the first operator: it moves the 3D cursor to the
collection's instance offset.
The first two operators make it easier to set the instance offset. The
last operator makes it possible to actually see the offset in the 3D
viewport; drawing it using some overlay could also work, but that would
be more effort to get right, and then snapping the 3D cursor would still
be useful.
The operators are placed in a popup menu, as to not clutter the
interface too much with various buttons.
Reviewed By: dfelinto, eyecandy
Differential Revision: https://developer.blender.org/D14966
2022-06-07 13:08:11 +02:00
|
|
|
class COLLECTION_MT_context_menu_instance_offset(Menu):
|
|
|
|
|
bl_label = "Instance Offset"
|
|
|
|
|
|
|
|
|
|
def draw(self, _context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.operator("object.instance_offset_from_cursor")
|
|
|
|
|
layout.operator("object.instance_offset_from_object")
|
|
|
|
|
layout.operator("object.instance_offset_to_cursor")
|
|
|
|
|
|
|
|
|
|
|
2021-03-17 13:46:41 -04:00
|
|
|
class COLLECTION_PT_instancing(CollectionButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Instancing"
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
collection = context.collection
|
|
|
|
|
|
Add Instance Offset operators to Collections property panel
Add three operators to the Collections properties panel:
- `object.instance_offset_to_cursor`, which is already available from
the Object properties panel. The operator works on the active
collection, though, so it's weird to not have it in the Collections
panel.
- `object.instance_offset_from_object` is a new operator, which performs
the same operation as above, but then based on the active object's
evaluated world position.
- `object.instance_offset_to_cursor` is also new, and performs the
opposite of the first operator: it moves the 3D cursor to the
collection's instance offset.
The first two operators make it easier to set the instance offset. The
last operator makes it possible to actually see the offset in the 3D
viewport; drawing it using some overlay could also work, but that would
be more effort to get right, and then snapping the 3D cursor would still
be useful.
The operators are placed in a popup menu, as to not clutter the
interface too much with various buttons.
Reviewed By: dfelinto, eyecandy
Differential Revision: https://developer.blender.org/D14966
2022-06-07 13:08:11 +02:00
|
|
|
row = layout.row(align=True)
|
2021-03-17 13:46:41 -04:00
|
|
|
row.prop(collection, "instance_offset")
|
Add Instance Offset operators to Collections property panel
Add three operators to the Collections properties panel:
- `object.instance_offset_to_cursor`, which is already available from
the Object properties panel. The operator works on the active
collection, though, so it's weird to not have it in the Collections
panel.
- `object.instance_offset_from_object` is a new operator, which performs
the same operation as above, but then based on the active object's
evaluated world position.
- `object.instance_offset_to_cursor` is also new, and performs the
opposite of the first operator: it moves the 3D cursor to the
collection's instance offset.
The first two operators make it easier to set the instance offset. The
last operator makes it possible to actually see the offset in the 3D
viewport; drawing it using some overlay could also work, but that would
be more effort to get right, and then snapping the 3D cursor would still
be useful.
The operators are placed in a popup menu, as to not clutter the
interface too much with various buttons.
Reviewed By: dfelinto, eyecandy
Differential Revision: https://developer.blender.org/D14966
2022-06-07 13:08:11 +02:00
|
|
|
row.menu("COLLECTION_MT_context_menu_instance_offset", icon='DOWNARROW_HLT', text="")
|
2021-03-16 19:35:53 +01:00
|
|
|
|
2021-03-17 13:46:41 -04:00
|
|
|
|
|
|
|
|
class COLLECTION_PT_lineart_collection(CollectionButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Line Art"
|
2021-03-29 16:27:18 +02:00
|
|
|
bl_order = 10
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
layout.use_property_decorate = False
|
|
|
|
|
collection = context.collection
|
|
|
|
|
|
|
|
|
|
row = layout.row()
|
2021-03-17 13:46:41 -04:00
|
|
|
row.prop(collection, "lineart_usage")
|
|
|
|
|
|
2021-07-19 22:58:15 +08:00
|
|
|
layout.prop(collection, "lineart_use_intersection_mask", text="Collection Mask")
|
2021-06-29 20:47:55 +08:00
|
|
|
|
2021-07-19 22:58:15 +08:00
|
|
|
col = layout.column(align=True)
|
|
|
|
|
col.active = collection.lineart_use_intersection_mask
|
|
|
|
|
row = col.row(align=True, heading="Masks")
|
2021-07-06 12:05:27 +10:00
|
|
|
for i in range(8):
|
2021-07-19 22:58:15 +08:00
|
|
|
row.prop(collection, "lineart_intersection_mask", index=i, text=" ", toggle=True)
|
|
|
|
|
if i == 3:
|
|
|
|
|
row = col.row(align=True)
|
2021-06-29 20:47:55 +08:00
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
|
2022-06-28 10:49:51 +10:00
|
|
|
class COLLECTION_PT_collection_custom_props(CollectionButtonsPanel, PropertyPanel, Panel):
|
|
|
|
|
_context_path = "collection"
|
|
|
|
|
_property_type = Collection
|
|
|
|
|
|
|
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
classes = (
|
Add Instance Offset operators to Collections property panel
Add three operators to the Collections properties panel:
- `object.instance_offset_to_cursor`, which is already available from
the Object properties panel. The operator works on the active
collection, though, so it's weird to not have it in the Collections
panel.
- `object.instance_offset_from_object` is a new operator, which performs
the same operation as above, but then based on the active object's
evaluated world position.
- `object.instance_offset_to_cursor` is also new, and performs the
opposite of the first operator: it moves the 3D cursor to the
collection's instance offset.
The first two operators make it easier to set the instance offset. The
last operator makes it possible to actually see the offset in the 3D
viewport; drawing it using some overlay could also work, but that would
be more effort to get right, and then snapping the 3D cursor would still
be useful.
The operators are placed in a popup menu, as to not clutter the
interface too much with various buttons.
Reviewed By: dfelinto, eyecandy
Differential Revision: https://developer.blender.org/D14966
2022-06-07 13:08:11 +02:00
|
|
|
COLLECTION_MT_context_menu_instance_offset,
|
2021-03-16 19:35:53 +01:00
|
|
|
COLLECTION_PT_collection_flags,
|
|
|
|
|
COLLECTION_PT_instancing,
|
2021-03-17 13:46:41 -04:00
|
|
|
COLLECTION_PT_lineart_collection,
|
2022-06-28 10:49:51 +10:00
|
|
|
COLLECTION_PT_collection_custom_props,
|
2021-03-16 19:35:53 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|