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:
authorLukas Stockner <lukas.stockner@freenet.de>2022-04-04 04:50:55 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2022-04-08 02:08:03 +0300
commit3214028ae822d6b9b1622589d27dd9b9746f2aa8 (patch)
tree08cb475db64f13d6507cd723c537f8dba568e39f /source/blender/editors/render
parent5dd855102130bfbc140cbe334a8f79c309e4a5c5 (diff)
Cycles: Support adding Lightgroups from the object/world properties
Currently, only Lightgroups that exist in the current view layer can be selected from object or world properties. The internal UI code already has support for search fields that accept unknown input, so I just added that to the API and use it for lightgroups. When a lightgroup is entered that does not exist in the current view layer (e.g. because it's completely new, because the view layer was switched or because it was deleted earlier), a new button next to it becomes active and adds it to the view layer when pressed. Differential Revision: https://developer.blender.org/D14540
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/render_shading.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc
index 07a07b462ef..d9929025c28 100644
--- a/source/blender/editors/render/render_shading.cc
+++ b/source/blender/editors/render/render_shading.cc
@@ -1118,12 +1118,25 @@ void SCENE_OT_view_layer_remove_aov(wmOperatorType *ot)
/** \name View Layer Add Lightgroup Operator
* \{ */
-static int view_layer_add_lightgroup_exec(bContext *C, wmOperator *UNUSED(op))
+static int view_layer_add_lightgroup_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_view_layer_add_lightgroup(view_layer);
+ char name[MAX_NAME];
+ RNA_string_get(op->ptr, "name", name);
+ /* If a name is provided, ensure that it is unique. */
+ if (name[0]) {
+ /* Ensure that there are no dots in the name. */
+ BLI_str_replace_char(name, '.', '_');
+ LISTBASE_FOREACH (ViewLayerLightgroup *, lightgroup, &view_layer->lightgroups) {
+ if (strcmp(lightgroup->name, name) == 0) {
+ return OPERATOR_CANCELLED;
+ }
+ }
+ }
+
+ BKE_view_layer_add_lightgroup(view_layer, name);
if (scene->nodetree) {
ntreeCompositUpdateRLayers(scene->nodetree);
@@ -1148,6 +1161,14 @@ void SCENE_OT_view_layer_add_lightgroup(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
+
+ /* properties */
+ ot->prop = RNA_def_string(ot->srna,
+ "name",
+ nullptr,
+ sizeof(((ViewLayerLightgroup *)NULL)->name),
+ "Name",
+ "Name of newly created lightgroup");
}
/** \} */