[Bf-blender-cvs] [62d3a0d1ec5] lanpr-under-gp: LineArt: Clipped line switch.

YimingWu noreply at git.blender.org
Fri Sep 11 11:17:18 CEST 2020


Commit: 62d3a0d1ec5ca53cb57eeaad355e35d630a380ab
Author: YimingWu
Date:   Fri Sep 11 17:16:41 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB62d3a0d1ec5ca53cb57eeaad355e35d630a380ab

LineArt: Clipped line switch.

===================================================================

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/editors/include/ED_lineart.h
M	source/blender/editors/lineart/lineart_cpu.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 1317455df92..5b8b3877ab9 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -754,6 +754,7 @@ class RENDER_PT_lineart_line_types(RenderButtonsPanel, Panel):
         layout.label(text="Extras:")
         layout.prop(lineart, "allow_duplication", text="Allow Instances")
         layout.prop(lineart, "allow_overlapping_edges")
+        layout.prop(lineart, "allow_clipping_boundaries")
 
 
 class RENDER_PT_lineart_baking(RenderButtonsPanel, Panel):
diff --git a/source/blender/editors/include/ED_lineart.h b/source/blender/editors/include/ED_lineart.h
index c435d09b70c..f9eef65d730 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -253,6 +253,7 @@ typedef struct LineartRenderBuffer {
   char use_intersections;
   char fuzzy_intersections;
   char fuzzy_everything;
+  char allow_boundaries;
 
   /** Keep an copy of these data so the scene can be freed when lineart is runnning. */
   char cam_is_persp;
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index 851a3075c5f..9748ec6dfd9 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -768,7 +768,7 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
   double a;
   int v_count = 0, t_count = 0, l_count = 0;
   Object *ob;
-  bool added;
+  bool added, allow_boundaries = rb->allow_boundaries;
   double cam_pos[3];
   double clip_start = rb->near_clip, clip_end = rb->far_clip;
   double view_dir[3], clip_advance[3];
@@ -933,7 +933,9 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
 
             /* New line connecting two new points */
             INCREASE_RL
-            BLI_addtail(&rb->all_render_lines, rl);
+            if (allow_boundaries) {
+              BLI_addtail(&rb->all_render_lines, rl);
+            }
             /** note: inverting rl->l/r (left/right point) doesn't matter as long as
              * rt->rl and rt->v has the same sequence. and the winding direction
              * can be either CW or CCW but needs to be consistent throughout the calculation.
@@ -1009,7 +1011,9 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
             REMOVE_ORIGINAL_LINES
 
             INCREASE_RL
-            BLI_addtail(&rb->all_render_lines, rl);
+            if (allow_boundaries) {
+              BLI_addtail(&rb->all_render_lines, rl);
+            }
             rl->l = &rv[0];
             rl->r = &rv[1];
             rl->tl = rt1;
@@ -1074,7 +1078,9 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
             REMOVE_ORIGINAL_LINES
 
             INCREASE_RL
-            BLI_addtail(&rb->all_render_lines, rl);
+            if (allow_boundaries) {
+              BLI_addtail(&rb->all_render_lines, rl);
+            }
             rl->l = &rv[1];
             rl->r = &rv[0];
             rl->tl = rt1;
@@ -1174,7 +1180,9 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
 
             /* New line connects two new points */
             INCREASE_RL
-            BLI_addtail(&rb->all_render_lines, rl);
+            if (allow_boundaries) {
+              BLI_addtail(&rb->all_render_lines, rl);
+            }
             rl->l = &rv[1];
             rl->r = &rv[0];
             rl->tl = rt1;
@@ -1271,7 +1279,9 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
             rt->rl[1]->next = rt->rl[1]->prev = 0;
 
             INCREASE_RL
-            BLI_addtail(&rb->all_render_lines, rl);
+            if (allow_boundaries) {
+              BLI_addtail(&rb->all_render_lines, rl);
+            }
             rl->l = &rv[1];
             rl->r = &rv[0];
             rl->tl = rt1;
@@ -1357,7 +1367,9 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
             rt->rl[2]->next = rt->rl[2]->prev = 0;
 
             INCREASE_RL
-            BLI_addtail(&rb->all_render_lines, rl);
+            if (allow_boundaries) {
+              BLI_addtail(&rb->all_render_lines, rl);
+            }
             rl->l = &rv[1];
             rl->r = &rv[0];
             rl->tl = rt1;
@@ -2597,11 +2609,15 @@ LineartRenderBuffer *ED_lineart_create_render_buffer(Scene *scene)
       return NULL;
     }
     Camera *c = scene->camera->data;
+    double clipping_offset = 0;
+    if (scene->lineart.flags & LRT_ALLOW_CLIPPING_BOUNDARIES) {
+      clipping_offset = 0.0001;
+    }
     copy_v3db_v3fl(rb->camera_pos, scene->camera->obmat[3]);
     copy_m4_m4(rb->cam_obmat, scene->camera->obmat);
     rb->cam_is_persp = (c->type == CAM_PERSP);
-    rb->near_clip = c->clip_start;
-    rb->far_clip = c->clip_end;
+    rb->near_clip = c->clip_start + clipping_offset;
+    rb->far_clip = c->clip_end - clipping_offset;
     rb->w = scene->r.xsch;
     rb->h = scene->r.ysch;
 
@@ -2617,6 +2633,7 @@ LineartRenderBuffer *ED_lineart_create_render_buffer(Scene *scene)
 
   rb->fuzzy_intersections = (scene->lineart.flags & LRT_INTERSECTION_AS_CONTOUR) != 0;
   rb->fuzzy_everything = (scene->lineart.flags & LRT_EVERYTHING_AS_CONTOUR) != 0;
+  rb->allow_boundaries = (scene->lineart.flags & LRT_ALLOW_CLIPPING_BOUNDARIES) != 0;
 
   rb->use_contour = (scene->lineart.line_types & LRT_EDGE_FLAG_CONTOUR) != 0;
   rb->use_crease = (scene->lineart.line_types & LRT_EDGE_FLAG_CREASE) != 0;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 1dd4ca40cf9..b59e563748a 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1671,6 +1671,7 @@ typedef enum eLineartMainFlags {
   LRT_EVERYTHING_AS_CONTOUR = (1 << 8),
   LRT_ALLOW_DUPLI_OBJECTS = (1 << 9),
   LRT_ALLOW_OVERLAPPING_EDGES = (1 << 10),
+  LRT_ALLOW_CLIPPING_BOUNDARIES = (1 << 11),
 } eLineartMainFlags;
 
 typedef struct SceneLineart {
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index dfeca9f7a73..9f98207a47e 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -7379,6 +7379,13 @@ static void rna_def_scene_lineart(BlenderRNA *brna)
                            "Allow lines from edge split to show properly, may run slower.");
   RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update");
 
+  prop = RNA_def_property(srna, "allow_clipping_boundaries", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_ALLOW_CLIPPING_BOUNDARIES);
+  RNA_def_property_boolean_default(prop, 1);
+  RNA_def_property_ui_text(
+      prop, "Clipping Boundaries", "Allow lines on near/far clipping plane to be shown.");
+  RNA_def_property_update(prop, NC_SCENE, "rna_lineart_update");
+
   prop = RNA_def_property(srna, "crease_threshold", PROP_FLOAT, PROP_NONE);
   RNA_def_property_float_default(prop, 0.5f);
   RNA_def_property_ui_text(prop, "Crease Threshold", "Cosine value of face angle");



More information about the Bf-blender-cvs mailing list