Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py19
-rw-r--r--source/blender/editors/render/render_intern.hh2
-rw-r--r--source/blender/editors/render/render_ops.cc2
-rw-r--r--source/blender/editors/render/render_shading.cc108
4 files changed, 128 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index 83e797583ad..44d764f1a2d 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# <pep8 compliant>
-from bpy.types import Panel, UIList
+from bpy.types import Menu, Panel, UIList
class VIEWLAYER_UL_aov(UIList):
@@ -138,7 +138,7 @@ class ViewLayerAOVPanel(ViewLayerButtonsPanel, Panel):
row = layout.row()
col = row.column()
col.template_list("VIEWLAYER_UL_aov", "aovs", view_layer,
- "aovs", view_layer, "active_aov_index", rows=2)
+ "aovs", view_layer, "active_aov_index", rows=3)
col = row.column()
sub = col.column(align=True)
@@ -187,6 +187,16 @@ class VIEWLAYER_PT_layer_passes_cryptomatte(ViewLayerCryptomattePanel, Panel):
COMPAT_ENGINES = {'BLENDER_EEVEE'}
+class VIEWLAYER_MT_lightgroup_sync(Menu):
+ bl_label = "Lightgroup Sync"
+
+ def draw(self, _context):
+ layout = self.layout
+
+ layout.operator("scene.view_layer_add_used_lightgroups", icon='ADD')
+ layout.operator("scene.view_layer_remove_unused_lightgroups", icon='REMOVE')
+
+
class ViewLayerLightgroupsPanel(ViewLayerButtonsPanel, Panel):
bl_label = "Light Groups"
@@ -201,12 +211,14 @@ class ViewLayerLightgroupsPanel(ViewLayerButtonsPanel, Panel):
row = layout.row()
col = row.column()
col.template_list("UI_UL_list", "lightgroups", view_layer,
- "lightgroups", view_layer, "active_lightgroup_index", rows=2)
+ "lightgroups", view_layer, "active_lightgroup_index", rows=3)
col = row.column()
sub = col.column(align=True)
sub.operator("scene.view_layer_add_lightgroup", icon='ADD', text="")
sub.operator("scene.view_layer_remove_lightgroup", icon='REMOVE', text="")
+ sub.separator()
+ sub.menu("VIEWLAYER_MT_lightgroup_sync", icon='DOWNARROW_HLT', text="")
class VIEWLAYER_PT_layer_passes_lightgroups(ViewLayerLightgroupsPanel):
@@ -215,6 +227,7 @@ class VIEWLAYER_PT_layer_passes_lightgroups(ViewLayerLightgroupsPanel):
classes = (
+ VIEWLAYER_MT_lightgroup_sync,
VIEWLAYER_PT_layer,
VIEWLAYER_PT_layer_passes,
VIEWLAYER_PT_eevee_layer_passes_data,
diff --git a/source/blender/editors/render/render_intern.hh b/source/blender/editors/render/render_intern.hh
index 85d917ae8e8..a4056f3dab3 100644
--- a/source/blender/editors/render/render_intern.hh
+++ b/source/blender/editors/render/render_intern.hh
@@ -35,6 +35,8 @@ void SCENE_OT_view_layer_add_aov(struct wmOperatorType *ot);
void SCENE_OT_view_layer_remove_aov(struct wmOperatorType *ot);
void SCENE_OT_view_layer_add_lightgroup(struct wmOperatorType *ot);
void SCENE_OT_view_layer_remove_lightgroup(struct wmOperatorType *ot);
+void SCENE_OT_view_layer_add_used_lightgroups(struct wmOperatorType *ot);
+void SCENE_OT_view_layer_remove_unused_lightgroups(struct wmOperatorType *ot);
void SCENE_OT_light_cache_bake(struct wmOperatorType *ot);
void SCENE_OT_light_cache_free(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_ops.cc b/source/blender/editors/render/render_ops.cc
index f671b2f950d..def220fb4fc 100644
--- a/source/blender/editors/render/render_ops.cc
+++ b/source/blender/editors/render/render_ops.cc
@@ -41,6 +41,8 @@ void ED_operatortypes_render()
WM_operatortype_append(SCENE_OT_view_layer_remove_aov);
WM_operatortype_append(SCENE_OT_view_layer_add_lightgroup);
WM_operatortype_append(SCENE_OT_view_layer_remove_lightgroup);
+ WM_operatortype_append(SCENE_OT_view_layer_add_used_lightgroups);
+ WM_operatortype_append(SCENE_OT_view_layer_remove_unused_lightgroups);
WM_operatortype_append(SCENE_OT_render_view_add);
WM_operatortype_append(SCENE_OT_render_view_remove);
diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc
index 4c885d50b4c..1bd6b87f1a7 100644
--- a/source/blender/editors/render/render_shading.cc
+++ b/source/blender/editors/render/render_shading.cc
@@ -1217,6 +1217,114 @@ void SCENE_OT_view_layer_remove_lightgroup(wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name View Layer Add Used Lightgroups Operator
+ * \{ */
+
+static GSet *get_used_lightgroups(Scene *scene)
+{
+ GSet *used_lightgroups = BLI_gset_str_new(__func__);
+
+ FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
+ if (ob->lightgroup && ob->lightgroup->name[0]) {
+ BLI_gset_add(used_lightgroups, ob->lightgroup->name);
+ }
+ }
+ FOREACH_SCENE_OBJECT_END;
+
+ if (scene->world && scene->world->lightgroup && scene->world->lightgroup->name[0]) {
+ BLI_gset_add(used_lightgroups, scene->world->lightgroup->name);
+ }
+
+ return used_lightgroups;
+}
+
+static int view_layer_add_used_lightgroups_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+
+ GSet *used_lightgroups = get_used_lightgroups(scene);
+ GSET_FOREACH_BEGIN (const char *, used_lightgroup, used_lightgroups) {
+ if (!BLI_findstring(
+ &view_layer->lightgroups, used_lightgroup, offsetof(ViewLayerLightgroup, name))) {
+ BKE_view_layer_add_lightgroup(view_layer, used_lightgroup);
+ }
+ }
+ GSET_FOREACH_END();
+ BLI_gset_free(used_lightgroups, nullptr);
+
+ if (scene->nodetree) {
+ ntreeCompositUpdateRLayers(scene->nodetree);
+ }
+
+ DEG_id_tag_update(&scene->id, 0);
+ DEG_relations_tag_update(CTX_data_main(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_view_layer_add_used_lightgroups(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Add Used Lightgroups";
+ ot->idname = "SCENE_OT_view_layer_add_used_lightgroups";
+ ot->description = "Add all used Light Groups";
+
+ /* api callbacks */
+ ot->exec = view_layer_add_used_lightgroups_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name View Layer Remove Unussed Lightgroups Operator
+ * \{ */
+
+static int view_layer_remove_unused_lightgroups_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene *scene = CTX_data_scene(C);
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+
+ GSet *used_lightgroups = get_used_lightgroups(scene);
+ LISTBASE_FOREACH_MUTABLE (ViewLayerLightgroup *, lightgroup, &view_layer->lightgroups) {
+ if (!BLI_gset_haskey(used_lightgroups, lightgroup->name)) {
+ BKE_view_layer_remove_lightgroup(view_layer, lightgroup);
+ }
+ }
+ BLI_gset_free(used_lightgroups, nullptr);
+
+ if (scene->nodetree) {
+ ntreeCompositUpdateRLayers(scene->nodetree);
+ }
+
+ DEG_id_tag_update(&scene->id, 0);
+ DEG_relations_tag_update(CTX_data_main(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
+
+ return OPERATOR_FINISHED;
+}
+
+void SCENE_OT_view_layer_remove_unused_lightgroups(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Remove Unused Lightgroups";
+ ot->idname = "SCENE_OT_view_layer_remove_unused_lightgroups";
+ ot->description = "Remove all unused Light Groups";
+
+ /* api callbacks */
+ ot->exec = view_layer_remove_unused_lightgroups_exec;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Light Cache Bake Operator
* \{ */