[Bf-blender-cvs] [259ab267ec4] temp-lineart-contained: LineArt: Comment cleanups in lineart_cpu.c and so on.

YimingWu noreply at git.blender.org
Mon Mar 15 15:58:07 CET 2021


Commit: 259ab267ec4ed309ab243e345be55df7385dd7ca
Author: YimingWu
Date:   Mon Mar 15 22:57:37 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB259ab267ec4ed309ab243e345be55df7385dd7ca

LineArt: Comment cleanups in lineart_cpu.c and so on.

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

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

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

diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index d1254a5f76d..ee61b47af49 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -59,7 +59,9 @@ typedef struct LineartRenderTriangle {
   unsigned char transparency_mask;
   unsigned char flags; /* eLineartTriangleFlags */
 
-  /* Now only use single link list, because we don't need to go back in order. */
+  /* Only use single link list, because we don't need to go back in order.
+   * This variable is also reused to store the pointer to adjacent lines of this triangle before
+   * intersection statge */
   struct LinkNode *intersecting_verts;
 } LineartRenderTriangle;
 
@@ -512,13 +514,11 @@ int MOD_lineart_compute_feature_lines(struct Depsgraph *depsgraph,
 
 struct Scene;
 
-LineartBoundingArea *MOD_lineart_get_point_bounding_area_rb(LineartRenderBuffer *rb,
-                                                            double x,
-                                                            double y);
+LineartBoundingArea *MOD_lineart_get_parent_bounding_area_rb(LineartRenderBuffer *rb,
+                                                             double x,
+                                                             double y);
 
-LineartBoundingArea *MOD_lineart_get_point_bounding_area_deep_rb(LineartRenderBuffer *rb,
-                                                                 double x,
-                                                                 double y);
+LineartBoundingArea *MOD_lineart_get_bounding_area_rb(LineartRenderBuffer *rb, double x, double y);
 
 struct bGPDlayer;
 struct bGPDframe;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index ce0e75baed3..36115fa1027 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -229,7 +229,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
     }
 
     /*  Step 1: grow left. */
-    ba = MOD_lineart_get_point_bounding_area_deep_rb(rb, rl->l->fbcoord[0], rl->l->fbcoord[1]);
+    ba = MOD_lineart_get_bounding_area(rb, rl->l->fbcoord[0], rl->l->fbcoord[1]);
     new_rv = rl->l;
     rls = rl->segments.first;
     VERT_COORD_TO_FLOAT(new_rv);
@@ -316,7 +316,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
                                     last_transparency,
                                     new_rl->r_obindex);
       }
-      ba = MOD_lineart_get_point_bounding_area_deep_rb(rb, new_rv->fbcoord[0], new_rv->fbcoord[1]);
+      ba = MOD_lineart_get_bounding_area(rb, new_rv->fbcoord[0], new_rv->fbcoord[1]);
     }
 
     /* Restore normal value. */
@@ -369,7 +369,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
                                rl->r_obindex);
 
     /*  Step 3: grow right. */
-    ba = MOD_lineart_get_point_bounding_area_deep_rb(rb, rl->r->fbcoord[0], rl->r->fbcoord[1]);
+    ba = MOD_lineart_get_bounding_area(rb, rl->r->fbcoord[0], rl->r->fbcoord[1]);
     new_rv = rl->r;
     while (ba && (new_rl = lineart_line_get_connected(ba, new_rv, &new_rv, rl->flags))) {
       new_rl->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
@@ -454,7 +454,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
                                    last_transparency,
                                    new_rl->r_obindex);
       }
-      ba = MOD_lineart_get_point_bounding_area_deep_rb(rb, new_rv->fbcoord[0], new_rv->fbcoord[1]);
+      ba = MOD_lineart_get_bounding_area(rb, new_rv->fbcoord[0], new_rv->fbcoord[1]);
     }
     if (rb->fuzzy_everything) {
       rlc->type = LRT_EDGE_FLAG_CONTOUR;
@@ -499,8 +499,7 @@ static LineartBoundingArea *lineart_bounding_area_get_end_point(LineartRenderBuf
   if (!rlci) {
     return NULL;
   }
-  LineartBoundingArea *root = MOD_lineart_get_point_bounding_area_rb(
-      rb, rlci->pos[0], rlci->pos[1]);
+  LineartBoundingArea *root = MOD_lineart_get_parent_bounding_area(rb, rlci->pos[0], rlci->pos[1]);
   if (root == NULL) {
     return NULL;
   }
@@ -553,8 +552,8 @@ static void lineart_bounding_area_link_chain(LineartRenderBuffer *rb, LineartRen
 {
   LineartRenderLineChainItem *pl = rlc->chain.first;
   LineartRenderLineChainItem *pr = rlc->chain.last;
-  LineartBoundingArea *ba1 = MOD_lineart_get_point_bounding_area_rb(rb, pl->pos[0], pl->pos[1]);
-  LineartBoundingArea *ba2 = MOD_lineart_get_point_bounding_area_rb(rb, pr->pos[0], pr->pos[1]);
+  LineartBoundingArea *ba1 = MOD_lineart_get_parent_bounding_area(rb, pl->pos[0], pl->pos[1]);
+  LineartBoundingArea *ba2 = MOD_lineart_get_parent_bounding_area(rb, pr->pos[0], pr->pos[1]);
 
   if (ba1) {
     lineart_bounding_area_link_point_recursive(rb, ba1, rlc, pl);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 09fd06d2725..3ae2f99fc1e 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -17,7 +17,7 @@
  * All rights reserved.
  */
 
-/** \file
+/* \file
  * \ingroup editors
  */
 
@@ -78,8 +78,6 @@
 
 #include "lineart_intern.h"
 
-/* static function declarations. */
-
 static LineartBoundingArea *lineart_line_first_bounding_area(LineartRenderBuffer *rb,
                                                              LineartRenderLine *rl);
 
@@ -97,12 +95,12 @@ static LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *This
                                                        double *next_x,
                                                        double *next_y);
 
-static int lineart_get_line_bounding_areas(LineartRenderBuffer *rb,
-                                           LineartRenderLine *rl,
-                                           int *rowbegin,
-                                           int *rowend,
-                                           int *colbegin,
-                                           int *colend);
+static bool lineart_get_line_bounding_areas(LineartRenderBuffer *rb,
+                                            LineartRenderLine *rl,
+                                            int *rowbegin,
+                                            int *rowend,
+                                            int *colbegin,
+                                            int *colend);
 
 static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
                                                 LineartBoundingArea *root_ba,
@@ -112,30 +110,29 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
                                                 int recursive_level,
                                                 bool do_intersection);
 
-static int lineart_triangle_line_image_space_occlusion(SpinLock *spl,
-                                                       const LineartRenderTriangle *rt,
-                                                       const LineartRenderLine *rl,
-                                                       const double *override_camera_loc,
-                                                       const bool override_cam_is_persp,
-                                                       const bool allow_overlapping_edges,
-                                                       const double vp[4][4],
-                                                       const double *camera_dir,
-                                                       const float cam_shift_x,
-                                                       const float cam_shift_y,
-                                                       double *from,
-                                                       double *to);
+static bool lineart_triangle_line_image_space_occlusion(SpinLock *spl,
+                                                        const LineartRenderTriangle *rt,
+                                                        const LineartRenderLine *rl,
+                                                        const double *override_camera_loc,
+                                                        const bool override_cam_is_persp,
+                                                        const bool allow_overlapping_edges,
+                                                        const double vp[4][4],
+                                                        const double *camera_dir,
+                                                        const float cam_shift_x,
+                                                        const float cam_shift_y,
+                                                        double *from,
+                                                        double *to);
 
 static void lineart_add_line_to_list(LineartRenderBuffer *rb, LineartRenderLine *rl);
 
-/* Geometry. */
-
 static void lineart_line_discard_segment(LineartRenderBuffer *rb, LineartRenderLineSegment *rls)
 {
   BLI_spin_lock(&rb->lock_cuts);
 
   memset(rls, 0, sizeof(LineartRenderLineSegment));
 
-  /* Reuse memory for the segment data. */
+  /* Storing the node for potentially reuse the memory for new segment data. Line Art data is not
+   * freed after all calulations are done. */
   BLI_addtail(&rb->wasted_cuts, rls);
 
   BLI_spin_unlock(&rb->lock_cuts);
@@ -144,7 +141,8 @@ static void lineart_line_discard_segment(LineartRenderBuffer *rb, LineartRenderL
 static LineartRenderLineSegment *lineart_line_give_segment(LineartRenderBuffer *rb)
 {
   BLI_spin_lock(&rb->lock_cuts);
-  /* See if we already have recouped memory. */
+
+  /* See if there is any already allocated memory we can reuse. */
   if (rb->wasted_cuts.first) {
     LineartRenderLineSegment *rls = (LineartRenderLineSegment *)BLI_pophead(&rb->wasted_cuts);
     BLI_spin_unlock(&rb->lock_cuts);
@@ -158,7 +156,7 @@ static LineartRenderLineSegment *lineart_line_give_segment(LineartRenderBuffer *
                                                      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list