[Bf-blender-cvs] [7446f907074] temp-lineart-contained: Cleanup various lineart files, add FIXME comments.

Sebastian Parborg noreply at git.blender.org
Fri Feb 12 00:13:20 CET 2021


Commit: 7446f9070748a6a1ed4ae7aaf2ed79b538728948
Author: Sebastian Parborg
Date:   Thu Feb 11 18:49:52 2021 +0100
Branches: temp-lineart-contained
https://developer.blender.org/rB7446f9070748a6a1ed4ae7aaf2ed79b538728948

Cleanup various lineart files, add FIXME comments.

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

M	source/blender/editors/object/CMakeLists.txt
M	source/blender/editors/object/object_add.c
M	source/blender/gpencil_modifiers/intern/lineart/ED_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/gpencil_modifiers/intern/lineart/lineart_intern.h
M	source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
M	source/blender/makesdna/DNA_lineart_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_collection.c
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index e1cfdf45aee..f594bb79239 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -89,7 +89,7 @@ endif()
 if(WITH_LINEART)
   add_definitions(-DWITH_LINEART)
 endif()
-  
+
 if(WITH_EXPERIMENTAL_FEATURES)
   add_definitions(-DWITH_GEOMETRY_NODES)
   add_definitions(-DWITH_POINT_CLOUD)
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 1da2cc027fb..5869ebd91b3 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1450,7 +1450,8 @@ static const EnumPropertyItem *object_gpencil_add_options(bContext *C,
                                                           PropertyRNA *UNUSED(prop),
                                                           bool *r_free)
 {
-  EnumPropertyItem *item = NULL, *item_ref = rna_enum_object_gpencil_type_items;
+  EnumPropertyItem *item = NULL;
+  const EnumPropertyItem *item_ref = rna_enum_object_gpencil_type_items;
   int totitem = 0;
   int i = 0;
   int orig_count = RNA_enum_items_count(item_ref);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/ED_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/ED_lineart.h
index be5e712c964..39b12ad16b6 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/ED_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/ED_lineart.h
@@ -455,19 +455,18 @@ BLI_INLINE int lineart_LineIntersectTest2d(
       }
       return 0;
     }
+
+    *aRatio = ratiod(a1[1], a2[1], ry);
+    if (fabs(b2[0] - b1[0]) > fabs(b2[1] - b1[1])) {
+      rr = ratiod(b1[0], b2[0], rx);
+    }
     else {
-      *aRatio = ratiod(a1[1], a2[1], ry);
-      if (fabs(b2[0] - b1[0]) > fabs(b2[1] - b1[1])) {
-        rr = ratiod(b1[0], b2[0], rx);
-      }
-      else {
-        rr = ratiod(b1[1], b2[1], ry);
-      }
-      if ((*aRatio) > 0 && (*aRatio) < 1 && rr > 0 && rr < 1) {
-        return 1;
-      }
-      return 0;
+      rr = ratiod(b1[1], b2[1], ry);
+    }
+    if ((*aRatio) > 0 && (*aRatio) < 1 && rr > 0 && rr < 1) {
+      return 1;
     }
+    return 0;
   }
   return 0;
 
@@ -524,7 +523,10 @@ BLI_INLINE int lineart_LineIntersectTest2d(
 #endif
 }
 
-int ED_lineart_point_inside_triangled(double v[2], double v0[2], double v1[2], double v2[2]);
+int ED_lineart_point_inside_triangle(const double v[2],
+                                     const double v0[2],
+                                     const double v1[2],
+                                     const double v2[2]);
 
 struct Depsgraph;
 struct Scene;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index 08297176e13..00b17bd9d89 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -73,11 +73,9 @@ static LineartRenderLine *lineart_line_get_connected(LineartBoundingArea *ba,
           *new_rv = LRT_OTHER_RV(nrl, nrl->l);
           return nrl;
         }
-        else {
-          if (rv->fbcoord[0] == nrl->r->fbcoord[0] && rv->fbcoord[1] == nrl->r->fbcoord[1]) {
-            *new_rv = LRT_OTHER_RV(nrl, nrl->r);
-            return nrl;
-          }
+        if (rv->fbcoord[0] == nrl->r->fbcoord[0] && rv->fbcoord[1] == nrl->r->fbcoord[1]) {
+          *new_rv = LRT_OTHER_RV(nrl, nrl->r);
+          return nrl;
         }
       }
       continue;
@@ -476,25 +474,24 @@ static LineartBoundingArea *lineart_bounding_area_get_rlci_recursive(
   if (root->child == NULL) {
     return root;
   }
-  else {
-    LineartBoundingArea *ch = root->child;
+
+  LineartBoundingArea *ch = root->child;
 #define IN_BOUND(ba, rlci) \
   ba.l <= rlci->pos[0] && ba.r >= rlci->pos[0] && ba.b <= rlci->pos[1] && ba.u >= rlci->pos[1]
 
-    if (IN_BOUND(ch[0], rlci)) {
-      return lineart_bounding_area_get_rlci_recursive(rb, &ch[0], rlci);
-    }
-    else if (IN_BOUND(ch[1], rlci)) {
-      return lineart_bounding_area_get_rlci_recursive(rb, &ch[1], rlci);
-    }
-    else if (IN_BOUND(ch[2], rlci)) {
-      return lineart_bounding_area_get_rlci_recursive(rb, &ch[2], rlci);
-    }
-    else if (IN_BOUND(ch[3], rlci)) {
-      return lineart_bounding_area_get_rlci_recursive(rb, &ch[3], rlci);
-    }
-#undef IN_BOUND
+  if (IN_BOUND(ch[0], rlci)) {
+    return lineart_bounding_area_get_rlci_recursive(rb, &ch[0], rlci);
   }
+  if (IN_BOUND(ch[1], rlci)) {
+    return lineart_bounding_area_get_rlci_recursive(rb, &ch[1], rlci);
+  }
+  if (IN_BOUND(ch[2], rlci)) {
+    return lineart_bounding_area_get_rlci_recursive(rb, &ch[2], rlci);
+  }
+  if (IN_BOUND(ch[3], rlci)) {
+    return lineart_bounding_area_get_rlci_recursive(rb, &ch[3], rlci);
+  }
+#undef IN_BOUND
   return NULL;
 }
 
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index afbc675445f..19a757bece1 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -151,11 +151,10 @@ static LineartRenderLineSegment *lineart_render_line_give_segment(LineartRenderB
     memset(rls, 0, sizeof(LineartRenderLineSegment));
     return rls;
   }
-  else {
-    BLI_spin_unlock(&rb->lock_cuts);
-    return (LineartRenderLineSegment *)lineart_mem_aquire_thread(&rb->render_data_pool,
-                                                                 sizeof(LineartRenderLineSegment));
-  }
+
+  BLI_spin_unlock(&rb->lock_cuts);
+  return (LineartRenderLineSegment *)lineart_mem_aquire_thread(&rb->render_data_pool,
+                                                               sizeof(LineartRenderLineSegment));
 }
 
 static void lineart_render_line_cut(LineartRenderBuffer *rb,
@@ -224,7 +223,7 @@ static void lineart_render_line_cut(LineartRenderBuffer *rb,
       untouched = 1;
       break;
     }
-    else if (rls->at > end) {
+    if (rls->at > end) {
       end_segment = rls;
       ns2 = lineart_render_line_give_segment(rb);
       break;
@@ -239,8 +238,9 @@ static void lineart_render_line_cut(LineartRenderBuffer *rb,
       ns2 = ns;
       end_segment = ns2;
     }
-    else
+    else {
       ns2 = lineart_render_line_give_segment(rb);
+    }
   }
 
   if (start_segment) {
@@ -445,7 +445,10 @@ static void lineart_main_occlusion_begin(LineartRenderBuffer *rb)
   MEM_freeN(rti);
 }
 
-int ED_lineart_point_inside_triangled(double v[2], double v0[2], double v1[2], double v2[2])
+int ED_lineart_point_inside_triangle(const double v[2],
+                                     const double v0[2],
+                                     const double v1[2],
+                                     const double v2[2])
 {
   double cl, c;
 
@@ -456,15 +459,15 @@ int ED_lineart_point_inside_triangled(double v[2], double v0[2], double v1[2], d
   if (c * cl <= 0) {
     return 0;
   }
-  else
-    c = cl;
+
+  c = cl;
 
   cl = (v2[0] - v[0]) * (v0[1] - v[1]) - (v2[1] - v[1]) * (v0[0] - v[0]);
   if (c * cl <= 0) {
     return 0;
   }
-  else
-    c = cl;
+
+  c = cl;
 
   cl = (v0[0] - v[0]) * (v1[1] - v[1]) - (v0[1] - v[1]) * (v1[0] - v[0]);
   if (c * cl <= 0) {
@@ -489,23 +492,21 @@ static int lineart_point_on_segment(double v[2], double v0[2], double v1[2])
   if (v1[0] - v0[0]) {
     c1 = ratiod(v0[0], v1[0], v[0]);
   }
-  else {
-    if (v[0] == v1[0]) {
-      c2 = ratiod(v0[1], v1[1], v[1]);
-      return (c2 >= 0 && c2 <= 1);
-    }
+  else if (v[0] == v1[0]) {
+    c2 = ratiod(v0[1], v1[1], v[1]);
+    return (c2 >= 0 && c2 <= 1);
   }
 
   if (v1[1] - v0[1]) {
     c2 = ratiod(v0[1], v1[1], v[1]);
   }
-  else {
-    if (v[1] == v1[1]) {
-      c1 = ratiod(v0[0], v1[0], v[0]);
-      return (c1 >= 0 && c1 <= 1);
-    }
+  else if (v[1] == v1[1]) {
+    c1 = ratiod(v0[0], v1[0], v[0]);
+    return (c1 >= 0 && c1 <= 1);
   }
 
+  // XXX FIXME seems like there is a chance that c1 and c2 is used uninitalized here.
+
   if (LRT_DOUBLE_CLOSE_ENOUGH(c1, c2) && c1 >= 0 && c1 <= 1) {
     return 1;
   }
@@ -529,21 +530,22 @@ static int lineart_point_triangle_relation(double v[2], double v0[2], double v1[
   if ((r = c * cl) < 0) {
     return 0;
   }
-  else
-    c = cl;
+
+  c = cl;
 
   cl = (v2[0] - v[0]) * (v0[1] - v[1]) - (v2[1] - v[1]) * (v0[0] - v[0]);
   if ((r = c * cl) < 0) {
     return 0;
   }
-  else
-    c = cl;
+
+  c = cl;
 
   cl = (v0[0] - v[0]) * (v1[1] - v[1]) - (v0[1] - v[1]) * (v1[0] - v[0]);
   if ((r = c * cl) < 0) {
     return 0;
   }
-  else if (r == 0) {
+
+  if (r == 0) {
     return 1;
   }
 
@@ -703,6 +705,11 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
 
   new_rl = &((LineartRenderLine *)leln->pointer)[l_count];
 
+  // XXX FIXME
+  // Seems like the logic here is faulty.
+  // rl is not assinged so rl->l_obindex seems like it will read random values the first time
+  // around. l_obi and r_obi doesn't seem like they are initialized either...
+
 #define INCREASE_RL \
   l_count++; \
   l_obi = rl->l_obindex; \
@@ -777,7 +784,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
        *       |
        *       |
        *     (near)---------->(far)
- . */
+       */
       if (!in0) {
 
         /* cut point for line 2---|-----0. */
@@ -811,7 +818,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
         /** 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.
- . */
+         */
         rl->l = &rv[1];
         rl->r = &rv[0];
         /* only one adjacent triangle, because the other side is the near plane. */
@@ -941,7 +948,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
        *        |     ***  |
        *        |        **2
        *      (near)---------->(far)
- . */
+       */
       if (in0) {
         /* Cut point for line 0---|------1. */
         sub_v3

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list