Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/lanpr/lanpr_cpu.c')
-rw-r--r--source/blender/draw/engines/lanpr/lanpr_cpu.c176
1 files changed, 86 insertions, 90 deletions
diff --git a/source/blender/draw/engines/lanpr/lanpr_cpu.c b/source/blender/draw/engines/lanpr/lanpr_cpu.c
index 1088b082d90..26bf418f584 100644
--- a/source/blender/draw/engines/lanpr/lanpr_cpu.c
+++ b/source/blender/draw/engines/lanpr/lanpr_cpu.c
@@ -57,80 +57,72 @@ static void lanpr_rebuild_render_draw_command(LANPR_RenderBuffer *rb, LANPR_Line
int i;
int vertCount;
- if (ll->type == TNS_COMMAND_LINE) {
- static GPUVertFormat format = {0};
- static struct {
- uint pos, normal;
- } attr_id;
- if (format.attr_len == 0) {
- attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- attr_id.normal = GPU_vertformat_attr_add(
- &format, "normal", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- }
-
- GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
-
- if (ll->contour.enabled) {
- Count += lanpr_count_leveled_edge_segment_count(&rb->contours, ll);
- }
- if (ll->crease.enabled) {
- Count += lanpr_count_leveled_edge_segment_count(&rb->crease_lines, ll);
- }
- if (ll->intersection.enabled) {
- Count += lanpr_count_leveled_edge_segment_count(&rb->intersection_lines, ll);
- }
- if (ll->edge_mark.enabled) {
- Count += lanpr_count_leveled_edge_segment_count(&rb->edge_marks, ll);
- }
- if (ll->material_separate.enabled) {
- Count += lanpr_count_leveled_edge_segment_count(&rb->material_lines, ll);
- }
-
- vertCount = Count * 2;
+ static GPUVertFormat format = {0};
+ static struct {
+ uint pos, normal;
+ } attr_id;
+ if (format.attr_len == 0) {
+ attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ attr_id.normal = GPU_vertformat_attr_add(
+ &format, "normal", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ }
- if (!vertCount) {
- return;
- }
+ GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
- GPU_vertbuf_data_alloc(vbo, vertCount);
+ if (ll->contour.enabled) {
+ Count += lanpr_count_leveled_edge_segment_count(&rb->contours, ll);
+ }
+ if (ll->crease.enabled) {
+ Count += lanpr_count_leveled_edge_segment_count(&rb->crease_lines, ll);
+ }
+ if (ll->intersection.enabled) {
+ Count += lanpr_count_leveled_edge_segment_count(&rb->intersection_lines, ll);
+ }
+ if (ll->edge_mark.enabled) {
+ Count += lanpr_count_leveled_edge_segment_count(&rb->edge_marks, ll);
+ }
+ if (ll->material_separate.enabled) {
+ Count += lanpr_count_leveled_edge_segment_count(&rb->material_lines, ll);
+ }
- tv = v = MEM_callocN(sizeof(float) * 6 * Count, "temp v data");
- tn = N = MEM_callocN(sizeof(float) * 6 * Count, "temp n data");
+ vertCount = Count * 2;
- if (ll->contour.enabled) {
- tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->contours, tv, tn, &tn, ll, 1.0f);
- }
- if (ll->crease.enabled) {
- tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->crease_lines, tv, tn, &tn, ll, 2.0f);
- }
- if (ll->material_separate.enabled) {
- tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->material_lines, tv, tn, &tn, ll, 3.0f);
- }
- if (ll->edge_mark.enabled) {
- tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->edge_marks, tv, tn, &tn, ll, 4.0f);
- }
- if (ll->intersection.enabled) {
- tv = lanpr_make_leveled_edge_vertex_array(
- rb, &rb->intersection_lines, tv, tn, &tn, ll, 5.0f);
- }
+ if (!vertCount) {
+ return;
+ }
- for (i = 0; i < vertCount; i++) {
- GPU_vertbuf_attr_set(vbo, attr_id.pos, i, &v[i * 3]);
- GPU_vertbuf_attr_set(vbo, attr_id.normal, i, &N[i * 3]);
- }
+ GPU_vertbuf_data_alloc(vbo, vertCount);
- MEM_freeN(v);
- MEM_freeN(N);
+ tv = v = MEM_callocN(sizeof(float) * 6 * Count, "temp v data");
+ tn = N = MEM_callocN(sizeof(float) * 6 * Count, "temp n data");
- ll->batch = GPU_batch_create_ex(
- GPU_PRIM_LINES, vbo, 0, GPU_USAGE_DYNAMIC | GPU_BATCH_OWNS_VBO);
+ if (ll->contour.enabled) {
+ tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->contours, tv, tn, &tn, ll, 1.0f);
+ }
+ if (ll->crease.enabled) {
+ tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->crease_lines, tv, tn, &tn, ll, 2.0f);
+ }
+ if (ll->material_separate.enabled) {
+ tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->material_lines, tv, tn, &tn, ll, 3.0f);
+ }
+ if (ll->edge_mark.enabled) {
+ tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->edge_marks, tv, tn, &tn, ll, 4.0f);
+ }
+ if (ll->intersection.enabled) {
+ tv = lanpr_make_leveled_edge_vertex_array(
+ rb, &rb->intersection_lines, tv, tn, &tn, ll, 5.0f);
+ }
- return;
+ for (i = 0; i < vertCount; i++) {
+ GPU_vertbuf_attr_set(vbo, attr_id.pos, i, &v[i * 3]);
+ GPU_vertbuf_attr_set(vbo, attr_id.normal, i, &N[i * 3]);
}
- /* if (ll->type == TNS_COMMAND_MATERIAL || ll->type == TNS_COMMAND_EDGE) { */
- /* later implement .... */
- /* } */
+ MEM_freeN(v);
+ MEM_freeN(N);
+
+ ll->batch = GPU_batch_create_ex(
+ GPU_PRIM_LINES, vbo, 0, GPU_USAGE_DYNAMIC | GPU_BATCH_OWNS_VBO);
}
void ED_lanpr_rebuild_all_command(SceneLANPR *lanpr)
{
@@ -157,7 +149,7 @@ 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) {
+ if (!(ll->flags & LANPR_LINE_LAYER_NORMAL_ENABLED)) {
return;
}
switch (ll->normal_mode) {
@@ -272,44 +264,44 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
DRW_shgroup_uniform_vec4(rb->ChainShgrp,
"contour_color",
- ll->use_same_style ? ll->color : ll->contour.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->contour.color,
1);
DRW_shgroup_uniform_vec4(
- rb->ChainShgrp, "crease_color", ll->use_same_style ? ll->color : ll->crease.color, 1);
+ rb->ChainShgrp, "crease_color", (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->crease.color, 1);
DRW_shgroup_uniform_vec4(rb->ChainShgrp,
"material_color",
- ll->use_same_style ? ll->color : ll->material_separate.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->material_separate.color,
1);
DRW_shgroup_uniform_vec4(rb->ChainShgrp,
"edge_mark_color",
- ll->use_same_style ? ll->color : ll->edge_mark.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->edge_mark.color,
1);
DRW_shgroup_uniform_vec4(rb->ChainShgrp,
"intersection_color",
- ll->use_same_style ? ll->color : ll->intersection.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->intersection.color,
1);
static float unit_thickness = 1.0f;
DRW_shgroup_uniform_float(rb->ChainShgrp, "thickness", &ll->thickness, 1);
DRW_shgroup_uniform_float(rb->ChainShgrp,
"thickness_contour",
- ll->use_same_style ? &unit_thickness : &ll->contour.thickness,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &unit_thickness : &ll->contour.thickness,
1);
DRW_shgroup_uniform_float(rb->ChainShgrp,
"thickness_crease",
- ll->use_same_style ? &unit_thickness : &ll->crease.thickness,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &unit_thickness : &ll->crease.thickness,
1);
DRW_shgroup_uniform_float(rb->ChainShgrp,
"thickness_material",
- ll->use_same_style ? &unit_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &unit_thickness :
&ll->material_separate.thickness,
1);
DRW_shgroup_uniform_float(rb->ChainShgrp,
"thickness_edge_mark",
- ll->use_same_style ? &unit_thickness : &ll->edge_mark.thickness,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &unit_thickness : &ll->edge_mark.thickness,
1);
DRW_shgroup_uniform_float(rb->ChainShgrp,
"thickness_intersection",
- ll->use_same_style ? &unit_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &unit_thickness :
&ll->intersection.thickness,
1);
DRW_shgroup_uniform_int(rb->ChainShgrp, "enable_contour", &ll->contour.enabled, 1);
@@ -320,10 +312,12 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
DRW_shgroup_uniform_int(
rb->ChainShgrp, "enable_intersection", &ll->intersection.enabled, 1);
+ static int normal_effect_inverse;
+ normal_effect_inverse = (ll->flags & LANPR_LINE_LAYER_NORMAL_INVERSE)?1:0;
DRW_shgroup_uniform_int(
- rb->ChainShgrp, "normal_mode", ll->normal_enabled ? &ll->normal_mode : &zero_value, 1);
+ rb->ChainShgrp, "normal_mode", (ll->flags & LANPR_LINE_LAYER_NORMAL_ENABLED) ? &ll->normal_mode : &zero_value, 1);
DRW_shgroup_uniform_int(
- rb->ChainShgrp, "normal_effect_inverse", &ll->normal_effect_inverse, 1);
+ rb->ChainShgrp, "normal_effect_inverse", &normal_effect_inverse, 1);
DRW_shgroup_uniform_float(rb->ChainShgrp, "normal_ramp_begin", &ll->normal_ramp_begin, 1);
DRW_shgroup_uniform_float(rb->ChainShgrp, "normal_ramp_end", &ll->normal_ramp_end, 1);
DRW_shgroup_uniform_float(
@@ -335,7 +329,7 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
DRW_shgroup_uniform_int(rb->ChainShgrp, "occlusion_level_start", &ll->qi_begin, 1);
DRW_shgroup_uniform_int(rb->ChainShgrp,
"occlusion_level_end",
- ll->use_multiple_levels ? &ll->qi_end : &ll->qi_begin,
+ (ll->flags & LANPR_LINE_LAYER_USE_MULTIPLE_LEVELS) ? &ll->qi_end : &ll->qi_begin,
1);
DRW_shgroup_uniform_vec4(
@@ -376,55 +370,57 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render)
DRW_shgroup_uniform_float(ll->shgrp, "camzoom", &camzoom, 1);
DRW_shgroup_uniform_vec4(
- ll->shgrp, "contour_color", ll->use_same_style ? ll->color : ll->contour.color, 1);
+ ll->shgrp, "contour_color", (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->contour.color, 1);
DRW_shgroup_uniform_vec4(
- ll->shgrp, "crease_color", ll->use_same_style ? ll->color : ll->crease.color, 1);
+ ll->shgrp, "crease_color", (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->crease.color, 1);
DRW_shgroup_uniform_vec4(ll->shgrp,
"material_color",
- ll->use_same_style ? ll->color : ll->material_separate.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->material_separate.color,
1);
DRW_shgroup_uniform_vec4(ll->shgrp,
"edge_mark_color",
- ll->use_same_style ? ll->color : ll->edge_mark.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->edge_mark.color,
1);
DRW_shgroup_uniform_vec4(ll->shgrp,
"intersection_color",
- ll->use_same_style ? ll->color : ll->intersection.color,
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? ll->color : ll->intersection.color,
1);
static float uniform_thickness = 1.0f;
DRW_shgroup_uniform_float(ll->shgrp, "thickness", &ll->thickness, 1);
DRW_shgroup_uniform_float(ll->shgrp,
"thickness_contour",
- ll->use_same_style ? &uniform_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &uniform_thickness :
&ll->contour.thickness,
1);
DRW_shgroup_uniform_float(ll->shgrp,
"thickness_crease",
- ll->use_same_style ? &uniform_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &uniform_thickness :
&ll->crease.thickness,
1);
DRW_shgroup_uniform_float(ll->shgrp,
"thickness_material",
- ll->use_same_style ? &uniform_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &uniform_thickness :
&ll->material_separate.thickness,
1);
DRW_shgroup_uniform_float(ll->shgrp,
"thickness_edge_mark",
- ll->use_same_style ? &uniform_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &uniform_thickness :
&ll->edge_mark.thickness,
1);
DRW_shgroup_uniform_float(ll->shgrp,
"thickness_intersection",
- ll->use_same_style ? &uniform_thickness :
+ (ll->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) ? &uniform_thickness :
&ll->intersection.thickness,
1);
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);
+ static int normal_effect_inverse;
+ normal_effect_inverse = (ll->flags & LANPR_LINE_LAYER_NORMAL_INVERSE)?1:0;
DRW_shgroup_uniform_int(
- ll->shgrp, "normal_mode", ll->normal_enabled ? &ll->normal_mode : &zero_value, 1);
+ ll->shgrp, "normal_mode", (ll->flags & LANPR_LINE_LAYER_NORMAL_ENABLED) ? &ll->normal_mode : &zero_value, 1);
DRW_shgroup_uniform_int(
- ll->shgrp, "normal_effect_inverse", &ll->normal_effect_inverse, 1);
+ ll->shgrp, "normal_effect_inverse", &normal_effect_inverse, 1);
DRW_shgroup_uniform_float(ll->shgrp, "normal_ramp_begin", &ll->normal_ramp_begin, 1);
DRW_shgroup_uniform_float(ll->shgrp, "normal_ramp_end", &ll->normal_ramp_end, 1);
DRW_shgroup_uniform_float(