[Bf-blender-cvs] [a640228d922] soc-2019-npr: Added support structure for material controlled line style.
YimingWu
noreply at git.blender.org
Sun May 19 08:38:13 CEST 2019
Commit: a640228d92273154acc644d525b095b5318c248b
Author: YimingWu
Date: Sun May 19 14:37:03 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBa640228d92273154acc644d525b095b5318c248b
Added support structure for material controlled line style.
Also with a primitive UI.
===================================================================
A bvhtree
A mesh
M release/scripts/startup/bl_ui/properties_material.py
M source/blender/draw/engines/lanpr/lanpr_all.h
M source/blender/makesdna/DNA_material_types.h
M source/blender/makesrna/intern/rna_material.c
A v
A x
===================================================================
diff --git a/bvhtree b/bvhtree
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/mesh b/mesh
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index dde67e27f37..f741c7782c9 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -200,6 +200,27 @@ class EEVEE_MATERIAL_PT_volume(MaterialButtonsPanel, Panel):
panel_node_draw(layout, mat.node_tree, 'OUTPUT_MATERIAL', "Volume")
+class EEVEE_MATERIAL_PT_lines(MaterialButtonsPanel, Panel):
+ bl_label = "Lines"
+ bl_context = "material"
+ COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_LANPR'}
+
+ def draw_header(self, context):
+ layout = self.layout
+ mat = context.material
+ layout.prop(mat, "enable_lines", text="")
+
+ def draw(self, context):
+ layout = self.layout
+ mat = context.material
+
+ if mat.enable_lines:
+ layout.label(text="Transparency")
+ layout.prop(mat,"mask_layers_count", expand=True)
+ layout.label(text="Customization")
+ layout.template_list("LANPR_linesets", "", mat, "line_layers", mat.line_layers, "active_layer_index", rows=1)
+ else:
+ layout.prop(mat, "exclude_line_geometry", toggle=True)
class EEVEE_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
bl_label = "Settings"
@@ -258,6 +279,7 @@ classes = (
EEVEE_MATERIAL_PT_context_material,
EEVEE_MATERIAL_PT_surface,
EEVEE_MATERIAL_PT_volume,
+ EEVEE_MATERIAL_PT_lines,
EEVEE_MATERIAL_PT_settings,
MATERIAL_PT_viewport,
MATERIAL_PT_custom_props,
diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h
index 7ba0687add5..a1e0fe92afb 100644
--- a/source/blender/draw/engines/lanpr/lanpr_all.h
+++ b/source/blender/draw/engines/lanpr/lanpr_all.h
@@ -434,9 +434,9 @@ typedef struct LANPR_RenderElementLinkNode {
typedef struct LANPR_RenderLineSegment {
nListItem Item;
- //real Begin, End; // 0->At[L] 1->At[R]
- real at;
- u8bit OcclusionLevel; //after
+ real at; // at==0: left at==1: right
+ u8bit OcclusionLevel; // after "at" point
+ short MaterialMaskMark; // e.g. to determine lines beind a glass window material.
}LANPR_RenderLineSegment;
typedef struct LANPR_RenderVert {
@@ -469,7 +469,7 @@ typedef struct LANPR_RenderLine {
struct LANPR_RenderTriangle *TL, *TR;
ListBase Segments;
//tnsEdge* Edge;//should be edge material
- //tnsRenderTriangle* Testing;//Should Be tRT** Testing[NumOfThreads]
+ //tnsRenderTriangle* Testing;//Should Be tRT** Testing[NumOfThreads] struct Materil *MaterialRef;
char MinOcclude;
char Flags; // also for line type determination on chainning
struct Object *ObjectRef;
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index d65a4896758..58f641fada9 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -27,6 +27,7 @@
#include "DNA_defs.h"
#include "DNA_ID.h"
#include "DNA_listBase.h"
+#include "DNA_lanpr_types.h"
#ifndef MAX_MTEX
# define MAX_MTEX 18
@@ -136,6 +137,14 @@ typedef enum eMaterialGPencilStyle_Mode {
GP_STYLE_MODE_BOX = 2, /* rectangles */
} eMaterialGPencilStyle_Mode;
+typedef enum eMaterialLANPRMaskLayerCount {
+ LANPR_MASK_NONE = 0,
+ LANPR_MASK_ONE = 1,
+ LANPR_MASK_TWO = 2,
+ LANPR_MASK_THREE = 3,
+ LANPR_MASK_FOUR =4,
+} eMaterialLANPRMaskLayerCount;
+
typedef struct Material {
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
@@ -176,6 +185,14 @@ typedef struct Material {
short line_priority;
short vcol_alpha;
+ /* lanpr settings */
+ char mask_layers_count;
+ char exclude_line_display;
+ char exclude_line_geometry;
+ char _pad5;
+ struct LANPR_LineLayer *active_layer;
+ ListBase line_layers;
+
/* Texture painting slots. */
short paint_active_slot;
short paint_clone_slot;
@@ -194,6 +211,7 @@ typedef struct Material {
* Cached slots for texture painting, must be refreshed in
* refresh_texpaint_image_cache before using.
*/
+ char _pad4[4];
struct TexPaintSlot *texpaintslot;
/** Runtime cache for GLSL materials. */
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 93dc7febd32..0aa7ac67555 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -32,6 +32,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "BLI_math.h"
+
const EnumPropertyItem rna_enum_ramp_blend_items[] = {
{MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
{0, "", ICON_NONE, NULL, NULL},
@@ -352,6 +354,68 @@ static void rna_GpencilColorData_fill_image_set(struct ReportList *UNUSED(report
pcolor->ima = (struct Image *)id;
}
+/* lanpr */
+
+static bool rna_lanpr_enable_lines_get(PointerRNA *ptr)
+{
+ Material *mat = (Material *)ptr->id.data;
+ return !mat->exclude_line_display;
+}
+static void rna_lanpr_enable_lines_set(PointerRNA *ptr, const bool value)
+{
+ Material *mat = (Material *)ptr->id.data;
+ mat->exclude_line_display = !(value);
+}
+
+void rna_lanpr_material_active_line_layer_index_range(
+ PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
+{
+ Material *mat = (Material *)ptr->data;
+ *min = 0;
+ *max = max_ii(0, BLI_listbase_count(&mat->line_layers) - 1);
+}
+
+int rna_lanpr_material_active_line_layer_index_get(PointerRNA *ptr)
+{
+ Material *mat = (Material *)ptr->data;
+ LANPR_LineLayer *ls;
+ int i = 0;
+ for (ls = mat->line_layers.first; ls; ls = ls->next) {
+ if (ls == mat->active_layer) return i;
+ i++;
+ }
+ return 0;
+}
+
+void rna_lanpr_material_active_line_layer_index_set(PointerRNA *ptr, int value)
+{
+ Material *mat = (Material *)ptr->data;
+ LANPR_LineLayer *ls;
+ int i = 0;
+ for (ls = mat->line_layers.first; ls; ls = ls->next) {
+ if (i == value) {
+ mat->active_layer = ls;
+ return;
+ }
+ i++;
+ }
+ mat->active_layer = 0;
+}
+
+PointerRNA rna_lanpr_material_active_line_layer_get(PointerRNA *ptr)
+{
+ Material *mat = (Material *)ptr->data;
+ LANPR_LineLayer *ls = mat->active_layer;
+ return rna_pointer_inherit_refine(ptr, &RNA_LANPR_LineLayer, ls);
+}
+
+void rna_lanpr_material_active_line_layer_set(PointerRNA *ptr, PointerRNA value)
+{
+ Material *mat = (Material *)ptr->data;
+ mat->active_layer = value.data;
+}
+
+
#else
static void rna_def_material_display(StructRNA *srna)
@@ -405,6 +469,54 @@ static void rna_def_material_display(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Material_update");
}
+static void rna_def_material_lanpr(struct StructRNA *srna,struct BlenerRNA *brna)
+{
+ PropertyRNA *prop;
+
+ static const EnumPropertyItem lanpr_material_mask_layer_count[] = {
+ {LANPR_MASK_NONE, "NONE", 0, "None", "Treat as normal occlusion"},
+ {LANPR_MASK_ONE, "ONE", 0, "One Layer", "One layered glass"},
+ {LANPR_MASK_TWO, "TWO", 0, "Two Layers", "Two layered glass"},
+ {0, NULL, 0, NULL, NULL},
+ };
+
+
+ prop = RNA_def_property(srna, "enable_lines", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Enable Lines", "Enable feature line calculation");
+ RNA_def_property_boolean_funcs(prop, "rna_lanpr_enable_lines_get", "rna_lanpr_enable_lines_set");
+
+ prop = RNA_def_property(srna, "exclude_line_geometry", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Exclude Line Geometry", "Remove geometry from this material from feature line calculation.");
+
+ prop = RNA_def_property(srna, "mask_layers_count", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, lanpr_material_mask_layer_count);
+ RNA_def_property_enum_default(prop, 0);
+ RNA_def_property_ui_text(prop, "Mask Layers", "Reduce occlusion level by layers");
+
+ prop = RNA_def_property(srna, "line_layers", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "line_layers", NULL);
+ RNA_def_property_struct_type(prop, "LANPR_LineLayer");
+ RNA_def_property_ui_text(prop, "Line Layers", "LANPR Line Layers");
+
+ RNA_def_property_srna(prop, "MaterialLineLayers");
+ srna = RNA_def_struct(brna, "MaterialLineLayers", NULL);
+ RNA_def_struct_sdna(srna, "Material");
+ RNA_def_struct_ui_text(srna, "Override Line Layers", "");
+
+ prop = RNA_def_property(srna, "active_layer", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "LANPR_LineLayer");
+ RNA_def_property_pointer_funcs(prop, "rna_lanpr_material_active_line_layer_get", "rna_lanpr_material_active_line_layer_set", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Active Line Layer", "Active line layer being displayed");
+ RNA_def_property_update(prop, NC_MATERIAL, NULL);
+
+ prop = RNA_def_property(srna, "active_layer_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_funcs(prop, "rna_lanpr_material_active_line_layer_index_get",
+ "rna_lanpr_material_active_line_layer_index_set",
+ "rna_lanpr_material_active_line_layer_index_range");
+ RNA_def_property_ui_text(prop, "Active Line Layer Index", "Index of active line layer slot");
+ RNA_def_property_update(prop, NC_MATERIAL, NULL);
+}
+
static void rna_def_material_greasepencil(BlenderRNA *brna)
{
StructRNA *srna;
@@ -873,6 +985,8 @@ void RNA_def_material(BlenderRNA *brna)
rna_def_material_greasepencil(brna);
+ rna_def_material_lanpr(srna, brna);
+
RNA_api_material(srna);
}
diff --git a/v b/v
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/x b/x
new file mode 100644
index 00000000000..e69de29bb2d
More information about the Bf-blender-cvs
mailing list