From 45b28c0f88475f0b2d556a237d474c7415344461 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Tue, 25 May 2021 23:45:47 +0800 Subject: GPencil: Add a use_light option when creating object. This option is default off when creating line art objects because line art seldom use lighting and the normal data would be all over the place anyway. Reviewed By: Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D11372 --- source/blender/editors/object/object_add.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8cf7d60e6c4..b0255e79858 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1312,6 +1312,7 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) const int type = RNA_enum_get(op->ptr, "type"); const bool use_in_front = RNA_boolean_get(op->ptr, "use_in_front"); + const bool use_lights = RNA_boolean_get(op->ptr, "use_lights"); const int stroke_depth_order = RNA_enum_get(op->ptr, "stroke_depth_order"); ushort local_view_bits; @@ -1432,6 +1433,13 @@ static int object_gpencil_add_exec(bContext *C, wmOperator *op) id_us_plus(&md->target_material->id); } + if (use_lights) { + ob->dtx |= OB_USE_GPENCIL_LIGHTS; + } + else { + ob->dtx &= ~OB_USE_GPENCIL_LIGHTS; + } + /* Stroke object is drawn in front of meshes by default. */ if (use_in_front) { ob->dtx |= OB_DRAW_IN_FRONT; @@ -1474,6 +1482,7 @@ static void object_add_ui(bContext *UNUSED(C), wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); if (type == GP_LRT_COLLECTION || type == GP_LRT_OBJECT || type == GP_LRT_SCENE) { + uiItemR(layout, op->ptr, "use_lights", 0, NULL, ICON_NONE); uiItemR(layout, op->ptr, "use_in_front", 0, NULL, ICON_NONE); bool in_front = RNA_boolean_get(op->ptr, "use_in_front"); uiLayout *row = uiLayoutRow(layout, false); @@ -1520,6 +1529,8 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot) false, "In Front", "Show line art grease pencil in front of everything"); + RNA_def_boolean( + ot->srna, "use_lights", false, "Use Lights", "Use lights for this grease pencil object"); RNA_def_enum( ot->srna, "stroke_depth_order", -- cgit v1.2.3