Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_add.c
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| static int object_gpencil_add_exec(bContext *C, wmOperator *op) | static int object_gpencil_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C), *ob_orig = ob; | Object *ob = CTX_data_active_object(C), *ob_orig = ob; | ||||
| bGPdata *gpd = (ob && (ob->type == OB_GPENCIL)) ? ob->data : NULL; | bGPdata *gpd = (ob && (ob->type == OB_GPENCIL)) ? ob->data : NULL; | ||||
| const int type = RNA_enum_get(op->ptr, "type"); | 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_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"); | const int stroke_depth_order = RNA_enum_get(op->ptr, "stroke_depth_order"); | ||||
| ushort local_view_bits; | ushort local_view_bits; | ||||
| float loc[3], rot[3]; | float loc[3], rot[3]; | ||||
| bool newob = false; | bool newob = false; | ||||
| /* Note: We use 'Y' here (not 'Z'), as */ | /* Note: We use 'Y' here (not 'Z'), as */ | ||||
| WM_operator_view3d_unit_defaults(C, op); | WM_operator_view3d_unit_defaults(C, op); | ||||
| ▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* Only created one layer and one material. */ | /* Only created one layer and one material. */ | ||||
| strcpy(md->target_layer, ((bGPDlayer *)gpd->layers.first)->info); | strcpy(md->target_layer, ((bGPDlayer *)gpd->layers.first)->info); | ||||
| md->target_material = BKE_gpencil_material(ob, 1); | md->target_material = BKE_gpencil_material(ob, 1); | ||||
| if (md->target_material) { | if (md->target_material) { | ||||
| id_us_plus(&md->target_material->id); | id_us_plus(&md->target_material->id); | ||||
| } | } | ||||
| if (use_lights) { | |||||
antoniov: Here, you only need disable if required. By default the object is added with lights, so to have… | |||||
| ob->dtx |= OB_USE_GPENCIL_LIGHTS; | |||||
| } | |||||
| else { | |||||
| ob->dtx &= ~OB_USE_GPENCIL_LIGHTS; | |||||
| } | |||||
| /* Stroke object is drawn in front of meshes by default. */ | /* Stroke object is drawn in front of meshes by default. */ | ||||
| if (use_in_front) { | if (use_in_front) { | ||||
| ob->dtx |= OB_DRAW_IN_FRONT; | ob->dtx |= OB_DRAW_IN_FRONT; | ||||
| } | } | ||||
| else { | else { | ||||
| if (stroke_depth_order == GP_DRAWMODE_3D) { | if (stroke_depth_order == GP_DRAWMODE_3D) { | ||||
| gpd->draw_mode = GP_DRAWMODE_3D; | gpd->draw_mode = GP_DRAWMODE_3D; | ||||
| } | } | ||||
| Show All 26 Lines | |||||
| uiItemR(layout, op->ptr, "radius", 0, NULL, ICON_NONE); | uiItemR(layout, op->ptr, "radius", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, op->ptr, "align", 0, NULL, ICON_NONE); | uiItemR(layout, op->ptr, "align", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, op->ptr, "location", 0, NULL, ICON_NONE); | uiItemR(layout, op->ptr, "location", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, op->ptr, "rotation", 0, NULL, ICON_NONE); | uiItemR(layout, op->ptr, "rotation", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, op->ptr, "type", 0, NULL, ICON_NONE); | uiItemR(layout, op->ptr, "type", 0, NULL, ICON_NONE); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| if (type == GP_LRT_COLLECTION || type == GP_LRT_OBJECT || type == GP_LRT_SCENE) { | 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); | uiItemR(layout, op->ptr, "use_in_front", 0, NULL, ICON_NONE); | ||||
| bool in_front = RNA_boolean_get(op->ptr, "use_in_front"); | bool in_front = RNA_boolean_get(op->ptr, "use_in_front"); | ||||
| uiLayout *row = uiLayoutRow(layout, false); | uiLayout *row = uiLayoutRow(layout, false); | ||||
| uiLayoutSetActive(row, !in_front); | uiLayoutSetActive(row, !in_front); | ||||
| uiItemR(row, op->ptr, "stroke_depth_order", 0, NULL, ICON_NONE); | uiItemR(row, op->ptr, "stroke_depth_order", 0, NULL, ICON_NONE); | ||||
| } | } | ||||
| } | } | ||||
| Show All 30 Lines | |||||
| ED_object_add_generic_props(ot, false); | ED_object_add_generic_props(ot, false); | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_gpencil_type_items, 0, "Type", ""); | ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_gpencil_type_items, 0, "Type", ""); | ||||
| RNA_def_boolean(ot->srna, | RNA_def_boolean(ot->srna, | ||||
| "use_in_front", | "use_in_front", | ||||
| false, | false, | ||||
| "In Front", | "In Front", | ||||
| "Show line art grease pencil in front of everything"); | "Show line art grease pencil in front of everything"); | ||||
| RNA_def_boolean( | |||||
antoniovUnsubmitted Not Done Inline ActionsDefault must be True antoniov: Default must be `True` | |||||
NicksBestAuthorUnsubmitted Done Inline ActionsThis is only effective for adding line art object not everything else. I think it's fair to set it false? NicksBest: This is only effective for adding line art object not everything else. I think it's fair to set… | |||||
antoniovUnsubmitted Not Done Inline ActionsAnd why this object must be different? I'm not a fan to have different settings for LineArt objects. antoniov: And why this object must be different? I'm not a fan to have different settings for LineArt… | |||||
NicksBestAuthorUnsubmitted Done Inline ActionsHumm... maybe the strokes aren't meant by styled by light in almost all use cases, and because the normal data will not be as desired anyway. NicksBest: Humm... maybe the strokes aren't meant by styled by light in almost all use cases, and because… | |||||
antoniovUnsubmitted Not Done Inline ActionsOk, let's wait for @Matias Mendiola (mendio) @Pablo Vazquez (pablovazquez) opinion. antoniov: Ok, let's wait for @mendio @pablovazquez opinion. | |||||
| ot->srna, "use_lights", false, "Use Lights", "Use lights for this grease pencil object"); | |||||
| RNA_def_enum( | RNA_def_enum( | ||||
| ot->srna, | ot->srna, | ||||
| "stroke_depth_order", | "stroke_depth_order", | ||||
| rna_enum_gpencil_add_stroke_depth_order_items, | rna_enum_gpencil_add_stroke_depth_order_items, | ||||
| GP_DRAWMODE_3D, | GP_DRAWMODE_3D, | ||||
| "Stroke Depth Order", | "Stroke Depth Order", | ||||
| "Defines how the strokes are ordered in 3D space for objects not displayed 'In Front'"); | "Defines how the strokes are ordered in 3D space for objects not displayed 'In Front'"); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines | |||||
Here, you only need disable if required. By default the object is added with lights, so to have two times the ON lights code is not good.
if (!use_lights) { ob->dtx &= ~OB_USE_GPENCIL_LIGHTS; }