[Bf-blender-cvs] [5462908a296] soc-2019-npr: LANPR: Add checkbox to normal controlled line weight.
YimingWu
noreply at git.blender.org
Mon Aug 5 04:49:11 CEST 2019
Commit: 5462908a2962bb30867b5ece161ea3a0f88640ed
Author: YimingWu
Date: Mon Aug 5 10:48:43 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB5462908a2962bb30867b5ece161ea3a0f88640ed
LANPR: Add checkbox to normal controlled line weight.
===================================================================
M release/scripts/startup/bl_ui/properties_render.py
M source/blender/draw/engines/lanpr/lanpr_cpu.c
M source/blender/editors/lanpr/lanpr_cpu.c
M source/blender/makesdna/DNA_lanpr_types.h
M source/blender/makesrna/intern/rna_lanpr.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 12577e78146..ff13da1f977 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -897,10 +897,9 @@ class RENDER_PT_lanpr_line_normal_effects(RenderButtonsPanel, Panel):
active_layer = lanpr.layers.active_layer
return scene.render.engine=="BLENDER_LANPR" and active_layer and lanpr.master_mode == "SOFTWARE"
- # sub panel doesn't support this?
- #def draw_header(self, context):
- #active_layer = lanpr.layers.active_layer
- #self.layout.prop(context.scene.lanpr, "enabled", text="")
+ def draw_header(self, context):
+ active_layer = context.scene.lanpr.layers.active_layer
+ self.layout.prop(active_layer, "normal_enabled", text="")
def draw(self, context):
scene = context.scene
diff --git a/source/blender/draw/engines/lanpr/lanpr_cpu.c b/source/blender/draw/engines/lanpr/lanpr_cpu.c
index 6d2d49eac15..be4f1668044 100644
--- a/source/blender/draw/engines/lanpr/lanpr_cpu.c
+++ b/source/blender/draw/engines/lanpr/lanpr_cpu.c
@@ -161,9 +161,10 @@ void ED_lanpr_rebuild_all_command(SceneLANPR *lanpr)
void ED_lanpr_calculate_normal_object_vector(LANPR_LineLayer *ll, float *normal_object_direction)
{
Object *ob;
+ if(!ll->normal_enabled){
+ return;
+ }
switch (ll->normal_mode) {
- case LANPR_NORMAL_DONT_CARE:
- return;
case LANPR_NORMAL_DIRECTIONAL:
if (!(ob = ll->normal_control_object)) {
normal_object_direction[0] = 0;
@@ -217,6 +218,7 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
float clear_depth = 1.0f;
uint clear_stencil = 0xFF;
eGPUFrameBufferBits clear_bits = GPU_DEPTH_BIT | GPU_COLOR_BIT;
+ static int zero_value = 0;
if (lanpr->use_world_background) {
copy_v3_v3(use_background_color, &scene->world->horr);
@@ -327,7 +329,7 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
DRW_shgroup_uniform_int(
rb->ChainShgrp, "enable_intersection", &ll->intersection.enabled, 1);
- DRW_shgroup_uniform_int(rb->ChainShgrp, "normal_mode", &ll->normal_mode, 1);
+ DRW_shgroup_uniform_int(rb->ChainShgrp, "normal_mode", ll->normal_enabled?&ll->normal_mode:&zero_value, 1);
DRW_shgroup_uniform_int(
rb->ChainShgrp, "normal_effect_inverse", &ll->normal_effect_inverse, 1);
DRW_shgroup_uniform_float(rb->ChainShgrp, "normal_ramp_begin", &ll->normal_ramp_begin, 1);
@@ -427,7 +429,7 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
DRW_shgroup_uniform_vec4(ll->shgrp, "preview_viewport", stl->g_data->dpix_viewport, 1);
DRW_shgroup_uniform_vec4(ll->shgrp, "output_viewport", stl->g_data->output_viewport, 1);
- DRW_shgroup_uniform_int(ll->shgrp, "normal_mode", &ll->normal_mode, 1);
+ DRW_shgroup_uniform_int(ll->shgrp, "normal_mode", ll->normal_enabled?&ll->normal_mode:&zero_value, 1);
DRW_shgroup_uniform_int(
ll->shgrp, "normal_effect_inverse", &ll->normal_effect_inverse, 1);
DRW_shgroup_uniform_float(ll->shgrp, "normal_ramp_begin", &ll->normal_ramp_begin, 1);
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index 1085dac6685..514d918fd0d 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -150,6 +150,8 @@ LANPR_LineLayer *ED_lanpr_new_line_layer(SceneLANPR *lanpr)
ll->normal_ramp_begin = 0.0f;
ll->normal_ramp_end = 1.0f;
+ ll->normal_mode = LANPR_NORMAL_DIRECTIONAL;
+
lanpr->active_layer = ll;
BLI_addtail(&lanpr->line_layers, ll);
diff --git a/source/blender/makesdna/DNA_lanpr_types.h b/source/blender/makesdna/DNA_lanpr_types.h
index 317af82d911..1add9bd61d7 100644
--- a/source/blender/makesdna/DNA_lanpr_types.h
+++ b/source/blender/makesdna/DNA_lanpr_types.h
@@ -46,7 +46,8 @@ typedef enum LANPR_TaperSettings {
} LANPR_TaperSettings;
typedef enum LANPR_NomalEffect {
- LANPR_NORMAL_DONT_CARE = 0,
+ /* Shouldn't have access to zero value. */
+ /* Enable/disable is another flag. */
LANPR_NORMAL_DIRECTIONAL = 1,
LANPR_NORMAL_POINT = 2,
} LANPR_NomalEffect;
@@ -112,8 +113,12 @@ typedef struct LANPR_LineLayer {
int use_same_style;
- int normal_mode;
- int normal_effect_inverse;
+ int _pad1;
+ char _pad2;
+
+ char normal_enabled;
+ char normal_mode;
+ char normal_effect_inverse;
float normal_ramp_begin;
float normal_ramp_end;
float normal_thickness_begin;
@@ -122,7 +127,7 @@ typedef struct LANPR_LineLayer {
/** For component evaluation */
int logic_mode;
- int _pad2;
+ int _pad3;
ListBase components;
diff --git a/source/blender/makesrna/intern/rna_lanpr.c b/source/blender/makesrna/intern/rna_lanpr.c
index 83fdeca0ea0..69a005692b7 100644
--- a/source/blender/makesrna/intern/rna_lanpr.c
+++ b/source/blender/makesrna/intern/rna_lanpr.c
@@ -62,11 +62,6 @@ void RNA_def_lanpr(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}};
static const EnumPropertyItem rna_enum_lanpr_normal_mode[] = {
- {LANPR_NORMAL_DONT_CARE,
- "DISABLED",
- 0,
- "Disabled",
- "Normal value does not affect line style"},
{LANPR_NORMAL_DIRECTIONAL,
"DIRECTIONAL",
0,
@@ -127,40 +122,42 @@ void RNA_def_lanpr(BlenderRNA *brna)
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_ui_text(prop, "Name", "Name of this layer");
+ prop = RNA_def_property(srna,"normal_enabled",PROP_BOOLEAN,PROP_NONE);
+ RNA_def_property_ui_text(prop, "Enabled", "Enable normal controlled line weight");
+
prop = RNA_def_property(srna, "normal_mode", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_items(prop, rna_enum_lanpr_normal_mode);
- RNA_def_property_enum_default(prop, LANPR_NORMAL_DONT_CARE);
- RNA_def_property_ui_text(prop, "Normal", "Normal Controlled Style");
+ RNA_def_property_enum_items(prop, rna_enum_lanpr_normal_mode);\
+ RNA_def_property_ui_text(prop, "Normal", "Normal controlled line weight");
prop = RNA_def_property(srna, "normal_effect_inverse", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_ui_text(prop, "Inverse", "Inverse Normal Thickness");
+ RNA_def_property_ui_text(prop, "Inverse", "Inverse normal effect");
prop = RNA_def_property(
srna, "normal_ramp_begin", PROP_FLOAT, PROP_FACTOR); /* begin is least strength */
RNA_def_property_float_default(prop, 0.0f);
- RNA_def_property_ui_text(prop, "Ramp Begin", "Normal Ramp Begin Value");
+ RNA_def_property_ui_text(prop, "Ramp Begin", "Normal ramp begin value");
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.05, 2);
prop = RNA_def_property(srna, "normal_ramp_end", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 1.0f);
- RNA_def_property_ui_text(prop, "Ramp End", "Normal Ramp End Value");
+ RNA_def_property_ui_text(prop, "Ramp End", "Normal ramp end value");
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.05, 2);
prop = RNA_def_property(
srna, "normal_thickness_begin", PROP_FLOAT, PROP_NONE); /* begin is least strength */
RNA_def_property_float_default(prop, 0.2f);
- RNA_def_property_ui_text(prop, "Thickness Begin", "Normal Thickness Begin Value");
+ RNA_def_property_ui_text(prop, "Thickness Begin", "Normal thickness begin value");
RNA_def_property_ui_range(prop, 0.0f, 5.0f, 0.05, 2);
prop = RNA_def_property(srna, "normal_thickness_end", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_default(prop, 1.5f);
- RNA_def_property_ui_text(prop, "Thickness End", "Normal Thickness End Value");
+ RNA_def_property_ui_text(prop, "Thickness End", "Normal thickness end value");
RNA_def_property_ui_range(prop, 0.0f, 5.0f, 0.05, 2);
prop = RNA_def_property(srna, "normal_control_object", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Object", "Normal Style Control Object");
+ RNA_def_property_ui_text(prop, "Object", "Normal style control object");
prop = RNA_def_property(srna, "use_same_style", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_default(prop, true);
More information about the Bf-blender-cvs
mailing list