diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-10-05 17:25:13 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-10-05 17:25:25 +0300 |
commit | fe58ba2ade6509546eeb7146f2f02727c4636da9 (patch) | |
tree | e03d61953cca31ea00b195e9546e470a486874d2 | |
parent | 6f773e289b72e7853a938ea407938130bc9e54aa (diff) |
New property to define render engine for grease pencil
-rw-r--r-- | release/scripts/startup/bl_ui/properties_material.py | 5 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_material_gpencil.py | 8 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_object.py | 7 | ||||
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 11 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 9 |
8 files changed, 44 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py index 1c7f3639f0a..a32f3ed4042 100644 --- a/release/scripts/startup/bl_ui/properties_material.py +++ b/release/scripts/startup/bl_ui/properties_material.py @@ -93,8 +93,9 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel): ob = context.object mat = context.material - if (ob and ob.type == 'GPENCIL') or (mat and mat.grease_pencil): - return False + if (ob and ob.type == 'GPENCIL' and ob.use_grease_pencil_scene_engine is False): + if mat and mat.grease_pencil: + return False return (ob or mat) and (context.engine in cls.COMPAT_ENGINES) diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py index 9d099ff2231..170593cd727 100644 --- a/release/scripts/startup/bl_ui/properties_material_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py @@ -97,6 +97,11 @@ class GPMaterialButtonsPanel: @classmethod def poll(cls, context): + ob = context.active_object + # If using scene engine, don't use this type of materials + if ob and ob.type == 'GPENCIL' and ob.use_grease_pencil_scene_engine: + return False + ma = context.material return ma and ma.grease_pencil @@ -112,6 +117,9 @@ class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel): def poll(cls, context): ob = context.object ma = context.material + # If using scene engine, don't use this type of materials + if ob and ob.type == 'GPENCIL' and ob.use_grease_pencil_scene_engine: + return False return (ma and ma.grease_pencil) or (ob and ob.type == 'GPENCIL') diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 81a641a20cf..85b6263cc5b 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -405,8 +405,13 @@ class OBJECT_PT_visibility(ObjectButtonsPanel, Panel): if context.object.type == 'GPENCIL': col = layout.column(heading="Grease Pencil") - col.prop(ob, "use_grease_pencil_lights", toggle=False) + subcol = layout.column() + subcol.prop(ob, "use_grease_pencil_lights", toggle=False) + subcol.active = not ob.use_grease_pencil_scene_engine + subcol = layout.column() + subcol.prop(ob, "use_grease_pencil_scene_engine", toggle=False) + subcol.active = context.scene.render.engine == 'BLENDER_EEVEE' layout.separator() col = layout.column(heading="Mask") col.prop(ob, "is_holdout") diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 8811a9febb9..7cbc74be7e7 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -696,6 +696,7 @@ bool DRW_object_is_in_edit_mode(const struct Object *ob); int DRW_object_visibility_in_active_context(const struct Object *ob); bool DRW_object_is_flat_normal(const struct Object *ob); bool DRW_object_use_hide_faces(const struct Object *ob); +bool DRW_object_use_gpencil_engine(const struct Object *ob); bool DRW_object_is_visible_psys_in_active_context(const struct Object *object, const struct ParticleSystem *psys); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 5ae0351cdd3..4f5c7fa054a 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -271,6 +271,17 @@ bool DRW_object_use_hide_faces(const struct Object *ob) return false; } +bool DRW_object_use_gpencil_engine(const struct Object *ob) +{ + BLI_assert((ob->base_flag & BASE_VISIBLE_DEPSGRAPH) != 0); + + if (ob->type == OB_GPENCIL) { + return (ob->dtx & OB_USE_GPENCIL_SCENE_ENGINE) == 0; + } + + return false; +} + bool DRW_object_is_visible_psys_in_active_context(const Object *object, const ParticleSystem *psys) { const bool for_render = DRW_state_is_image_render(); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 7b2667905ff..737efd76118 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -767,7 +767,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) } else { const char *name = DATA_("Material"); - if (!(ob != NULL && ob->type == OB_GPENCIL)) { + if ((!(ob != NULL && ob->type == OB_GPENCIL)) || (GP_OBJECT_USE_SCENE_RENDER(ob))) { ma = BKE_material_add(bmain, name); } else { diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 5a88ce7c9f5..f00554b2ddd 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -231,6 +231,9 @@ enum eObjectLineArt_Flags { OBJECT_LRT_OWN_CREASE = (1 << 0), }; +#define GP_OBJECT_USE_SCENE_RENDER(ob) \ +((ob) && ((ob->dtx & OB_USE_GPENCIL_SCENE_ENGINE) != 0)) + typedef struct Object { ID id; /** Animation data (must be immediately after id for utilities to use it). */ @@ -601,6 +604,8 @@ enum { OB_DRAW_NO_SHADOW_CAST = 1 << 9, /* Enable lights for grease pencil. */ OB_USE_GPENCIL_LIGHTS = 1 << 10, + /* Use Scene Render Engine for grease pencil. */ + OB_USE_GPENCIL_SCENE_ENGINE = 1 << 11, }; /* empty_drawtype: no flags */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 99865078cbe..80249922c15 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -3704,6 +3704,15 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Lights", "Lights affect grease pencil object"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_GPencil_update"); + prop = RNA_def_property(srna, "use_grease_pencil_scene_engine", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_USE_GPENCIL_SCENE_ENGINE); + RNA_def_property_boolean_default(prop, false); + RNA_def_property_ui_text( + prop, + "Use Scene Render Engine", + "Use the scene render engine to render this object instead of the Grease Pencil engine"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_GPencil_update"); + prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP); RNA_def_property_ui_text( |