[Bf-blender-cvs] [3420c3d8c6c] master: LineArt: Remove geometry space chaining

YimingWu noreply at git.blender.org
Fri Mar 19 18:29:14 CET 2021


Commit: 3420c3d8c6cc026df093133799f116021aa9ba51
Author: YimingWu
Date:   Fri Mar 19 20:55:38 2021 +0800
Branches: master
https://developer.blender.org/rB3420c3d8c6cc026df093133799f116021aa9ba51

LineArt: Remove geometry space chaining

It caused some chaining errors when used in combination with image space
chaining. After some internal discussion, we realized it is not
useful as chaining in image space essentially does the same thing.

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

M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
M	source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M	source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index b66e970b107..27c1c40066e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -387,9 +387,7 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel)
   uiItemR(col, ptr, "fuzzy_intersections", 0, NULL, ICON_NONE);
   uiItemR(col, ptr, "fuzzy_everything", 0, NULL, ICON_NONE);
 
-  col = uiLayoutColumn(layout, true);
-  uiItemR(col, ptr, "chaining_geometry_threshold", 0, NULL, ICON_NONE);
-  uiItemR(col, ptr, "chaining_image_threshold", 0, NULL, ICON_NONE);
+  uiItemR(layout, ptr, "chaining_image_threshold", 0, NULL, ICON_NONE);
 
   uiItemR(layout, ptr, "resample_length", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
 
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index c01b1a4c86b..79dc584065c 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -289,7 +289,6 @@ typedef struct LineartRenderBuffer {
   float shift_x, shift_y;
   float crease_threshold;
   float chaining_image_threshold;
-  float chaining_geometry_threshold;
   float angle_splitting_threshold;
 
   /* FIXME: (Yiming) Temporary solution for speeding up calculation by not including lines that
@@ -512,7 +511,7 @@ void MOD_lineart_destroy_render_data(struct LineartGpencilModifierData *lmd);
 
 void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb);
 void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb);
-void MOD_lineart_chain_connect(LineartRenderBuffer *rb, const bool do_geometry_space);
+void MOD_lineart_chain_connect(LineartRenderBuffer *rb);
 void MOD_lineart_chain_discard_short(LineartRenderBuffer *rb, const float threshold);
 void MOD_lineart_chain_split_angle(LineartRenderBuffer *rb, float angle_threshold_rad);
 
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index fae5bcd7c2e..3ac8ec378a2 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -694,7 +694,6 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
                                                                 int occlusion,
                                                                 unsigned char transparency_mask,
                                                                 float dist,
-                                                                int do_geometry_space,
                                                                 float *result_new_len,
                                                                 LineartBoundingArea *caller_ba)
 {
@@ -739,8 +738,7 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
       }
     }
 
-    float new_len = do_geometry_space ? len_v3v3(cre->rlci->gpos, rlci->gpos) :
-                                        len_v2v2(cre->rlci->pos, rlci->pos);
+    float new_len = len_v2v2(cre->rlci->pos, rlci->pos);
     if (new_len < dist) {
       closest_cre = cre;
       dist = new_len;
@@ -758,23 +756,15 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
   if (dist_to < dist && dist_to > 0) { \
     LISTBASE_FOREACH (LinkData *, ld, list) { \
       LineartBoundingArea *sba = (LineartBoundingArea *)ld->data; \
-      adjacent_closest = lineart_chain_get_closest_cre(rb, \
-                                                       sba, \
-                                                       rlc, \
-                                                       rlci, \
-                                                       occlusion, \
-                                                       transparency_mask, \
-                                                       dist, \
-                                                       do_geometry_space, \
-                                                       &adjacent_new_len, \
-                                                       ba); \
+      adjacent_closest = lineart_chain_get_closest_cre( \
+          rb, sba, rlc, rlci, occlusion, transparency_mask, dist, &adjacent_new_len, ba); \
       if (adjacent_new_len < dist) { \
         dist = adjacent_new_len; \
         closest_cre = adjacent_closest; \
       } \
     } \
   }
-  if (!do_geometry_space && !caller_ba) {
+  if (!caller_ba) {
     LRT_TEST_ADJACENT_AREAS(rlci->pos[0] - ba->l, &ba->lp);
     LRT_TEST_ADJACENT_AREAS(ba->r - rlci->pos[0], &ba->rp);
     LRT_TEST_ADJACENT_AREAS(ba->u - rlci->pos[1], &ba->up);
@@ -789,20 +779,19 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
 /* This function only connects two different chains. It will not do any clean up or smart chaining.
  * So no: removing overlapping chains, removal of short isolated segments, and no loop reduction is
  * implemented yet. */
-void MOD_lineart_chain_connect(LineartRenderBuffer *rb, const bool do_geometry_space)
+void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
 {
   LineartLineChain *rlc;
   LineartLineChainItem *rlci_l, *rlci_r;
   LineartBoundingArea *ba_l, *ba_r;
   LineartChainRegisterEntry *closest_cre_l, *closest_cre_r, *closest_cre;
-  float dist = do_geometry_space ? rb->chaining_geometry_threshold : rb->chaining_image_threshold;
+  float dist = rb->chaining_image_threshold;
   float dist_l, dist_r;
   int occlusion, reverse_main;
   unsigned char transparency_mask;
   ListBase swap = {0};
 
-  if ((!do_geometry_space && rb->chaining_image_threshold < 0.0001) ||
-      (do_geometry_space && rb->chaining_geometry_threshold < 0.0001)) {
+  if (rb->chaining_image_threshold < 0.0001) {
     return;
   }
 
@@ -825,26 +814,10 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb, const bool do_geometry_s
     rlci_r = rlc->chain.last;
     while ((ba_l = lineart_bounding_area_get_end_point(rb, rlci_l)) &&
            (ba_r = lineart_bounding_area_get_end_point(rb, rlci_r))) {
-      closest_cre_l = lineart_chain_get_closest_cre(rb,
-                                                    ba_l,
-                                                    rlc,
-                                                    rlci_l,
-                                                    occlusion,
-                                                    transparency_mask,
-                                                    dist,
-                                                    do_geometry_space,
-                                                    &dist_l,
-                                                    NULL);
-      closest_cre_r = lineart_chain_get_closest_cre(rb,
-                                                    ba_r,
-                                                    rlc,
-                                                    rlci_r,
-                                                    occlusion,
-                                                    transparency_mask,
-                                                    dist,
-                                                    do_geometry_space,
-                                                    &dist_r,
-                                                    NULL);
+      closest_cre_l = lineart_chain_get_closest_cre(
+          rb, ba_l, rlc, rlci_l, occlusion, transparency_mask, dist, &dist_l, NULL);
+      closest_cre_r = lineart_chain_get_closest_cre(
+          rb, ba_r, rlc, rlci_r, occlusion, transparency_mask, dist, &dist_r, NULL);
       if (closest_cre_l && closest_cre_r) {
         if (dist_l < dist_r) {
           closest_cre = closest_cre_l;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 77de09a5526..7d79ce46c1a 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -2645,7 +2645,6 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
   rb->crease_threshold = cos(M_PI - lmd->crease_threshold);
   rb->angle_splitting_threshold = lmd->angle_splitting_threshold;
   rb->chaining_image_threshold = lmd->chaining_image_threshold;
-  rb->chaining_geometry_threshold = lmd->chaining_geometry_threshold;
 
   rb->fuzzy_intersections = (lmd->calculation_flags & LRT_INTERSECTION_AS_CONTOUR) != 0;
   rb->fuzzy_everything = (lmd->calculation_flags & LRT_EVERYTHING_AS_CONTOUR) != 0;
@@ -3676,32 +3675,18 @@ int MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, LineartGpencilModifi
      * spit, where the splitting point could be any cut in e->segments. */
     MOD_lineart_chain_split_for_fixed_occlusion(rb);
 
-    /* Then we connect chains based on the _proximity_ of their end points in geometry or image
-     * space, here's the place threashold value gets involved. */
-
-    /* If both chaining thresholds are zero, then we allow at least image space chaining to do a
-     * little bit of work so we don't end up in fragmented strokes. */
-    float *t_image = &lmd->chaining_image_threshold;
-    float *t_geom = &lmd->chaining_geometry_threshold;
-    if (*t_image < FLT_EPSILON && *t_geom < FLT_EPSILON) {
-      *t_geom = 0.0f;
-      *t_image = 0.001f;
-    }
+    /* Then we connect chains based on the _proximity_ of their end points in image space, here's
+     * the place threashold value gets involved. */
 
     /* do_geometry_space = true. */
-    MOD_lineart_chain_connect(rb, true);
+    MOD_lineart_chain_connect(rb);
 
-    /* After chaining, we need to clear flags so we can do another round in image space. */
-    MOD_lineart_chain_clear_picked_flag(rb);
-
-    /* do_geometry_space = false (it's image_space). */
-    MOD_lineart_chain_connect(rb, false);
-
-    /* Clear again so we don't confuse GPencil generation calls. */
+    /* After chaining, we need to cle

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list