[Bf-blender-cvs] [b95f15862e8] temp-lanpr-review: Cleanup: Get rid of real/tmat/tnsvector stuff in LANPR internal code.

YimingWu noreply at git.blender.org
Fri Nov 22 11:11:01 CET 2019


Commit: b95f15862e8b2a304c139cbea0858d9398782599
Author: YimingWu
Date:   Fri Nov 22 18:10:20 2019 +0800
Branches: temp-lanpr-review
https://developer.blender.org/rBb95f15862e8b2a304c139cbea0858d9398782599

Cleanup: Get rid of real/tmat/tnsvector stuff in LANPR internal code.

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

M	source/blender/editors/include/ED_lanpr.h
M	source/blender/editors/lanpr/lanpr_cpu.c
M	source/blender/editors/lanpr/lanpr_util.c

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

diff --git a/source/blender/editors/include/ED_lanpr.h b/source/blender/editors/include/ED_lanpr.h
index 5aaea66cad8..d7da029a4f7 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -34,15 +34,6 @@
 #include <math.h>
 #include <string.h>
 
-typedef double real;
-
-typedef real tnsVector2d[2];
-typedef real tnsVector3d[3];
-typedef real tnsVector4d[4];
-typedef float tnsVector3f[3];
-typedef float tnsVector4f[4];
-typedef int tnsVector2i[2];
-
 typedef struct LANPR_StaticMemPoolNode {
   Link item;
   int used_byte;
@@ -59,8 +50,8 @@ typedef struct LANPR_RenderTriangle {
   struct LANPR_RenderTriangle *next, *prev;
   struct LANPR_RenderVert *v[3];
   struct LANPR_RenderLine *rl[3];
-  real gn[3];
-  real gc[3];
+  double gn[3];
+  double gc[3];
   /*  struct BMFace *F; */
   short material_id;
   ListBase intersecting_verts;
@@ -85,7 +76,7 @@ typedef struct LANPR_RenderElementLinkNode {
 typedef struct LANPR_RenderLineSegment {
   struct LANPR_RenderLineSegment *next, *prev;
   /** at==0: left  at==1: right  (this is in 2D projected space) */
-  real at;
+  double at;
   /** Occlusion level after "at" point */
   unsigned char occlusion;
   /** For determining lines beind a glass window material. (TODO: implement this) */
@@ -94,8 +85,8 @@ typedef struct LANPR_RenderLineSegment {
 
 typedef struct LANPR_RenderVert {
   struct LANPR_RenderVert *next, *prev;
-  real gloc[4];
-  real fbcoord[4];
+  double gloc[4];
+  double fbcoord[4];
   int fbcoordi[2];
   /**  Used as "r" when intersecting */
   struct BMVert *v;
@@ -184,7 +175,7 @@ typedef struct LANPR_RenderBuffer {
   int w, h;
   int tile_size_w, tile_size_h;
   int tile_count_x, tile_count_y;
-  real width_per_tile, height_per_tile;
+  double width_per_tile, height_per_tile;
   double view_projection[4][4];
 
   int output_mode;
@@ -209,7 +200,7 @@ typedef struct LANPR_RenderBuffer {
   struct Material *material_pointers[2048];
 
   /*  Render status */
-  real view_vector[3];
+  double view_vector[3];
 
   int triangle_size;
 
@@ -249,12 +240,12 @@ typedef struct LANPR_RenderBuffer {
   /*  settings */
 
   int max_occlusion_level;
-  real crease_angle;
-  real crease_cos;
+  double crease_angle;
+  double crease_cos;
   int thread_count;
 
   int draw_material_preview;
-  real material_transparency;
+  double material_transparency;
 
   int show_line;
   int show_fast;
@@ -392,8 +383,8 @@ typedef struct LANPR_RenderTaskInfo {
  * storing pointers to adjacent bounding areas.
 */
 typedef struct LANPR_BoundingArea {
-  real l, r, u, b;
-  real cx, cy;
+  double l, r, u, b;
+  double cx, cy;
 
   /** 1,2,3,4 quadrant */
   struct LANPR_BoundingArea *child;
@@ -472,7 +463,7 @@ BLI_INLINE int lanpr_TrangleLineBoundBoxTest(LANPR_RenderTriangle *rt, LANPR_Ren
   return 1;
 }
 
-BLI_INLINE double tmat_get_linear_ratio(real l, real r, real from_l);
+BLI_INLINE double tmat_get_linear_ratio(double l, double r, double from_l);
 BLI_INLINE int lanpr_LineIntersectTest2d(
     const double *a1, const double *a2, const double *b1, const double *b2, double *aRatio)
 {
@@ -527,13 +518,13 @@ BLI_INLINE int lanpr_LineIntersectTest2d(
   return 1;
 }
 
-BLI_INLINE double tmat_get_linear_ratio(real l, real r, real from_l)
+BLI_INLINE double tmat_get_linear_ratio(double l, double r, double from_l)
 {
   double ra = (from_l - l) / (r - l);
   return ra;
 }
 
-int ED_lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v1, tnsVector2d v2);
+int ED_lanpr_point_inside_triangled(double v[2], double v0[2], double v1[2], double v2[2]);
 
 struct Depsgraph;
 struct SceneLANPR;
@@ -572,8 +563,8 @@ int ED_lanpr_max_occlusion_in_line_layers(struct SceneLANPR *lanpr);
 LANPR_LineLayer *ED_lanpr_new_line_layer(struct SceneLANPR *lanpr);
 LANPR_LineLayerComponent *ED_lanpr_new_line_component(struct SceneLANPR *lanpr);
 
-LANPR_BoundingArea *ED_lanpr_get_point_bounding_area(LANPR_RenderBuffer *rb, real x, real y);
-LANPR_BoundingArea *ED_lanpr_get_point_bounding_area_deep(LANPR_RenderBuffer *rb, real x, real y);
+LANPR_BoundingArea *ED_lanpr_get_point_bounding_area(LANPR_RenderBuffer *rb, double x, double y);
+LANPR_BoundingArea *ED_lanpr_get_point_bounding_area_deep(LANPR_RenderBuffer *rb, double x, double y);
 
 void ED_lanpr_post_frame_update_external(struct Scene *s, struct Depsgraph *dg);
 
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index 8cb0e27d79d..e12beeab38a 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -82,13 +82,13 @@ static void lanpr_link_line_with_bounding_area(LANPR_RenderBuffer *rb,
 
 static LANPR_BoundingArea *lanpr_get_next_bounding_area(LANPR_BoundingArea *This,
                                                         LANPR_RenderLine *rl,
-                                                        real x,
-                                                        real y,
-                                                        real k,
+                                                        double x,
+                                                        double y,
+                                                        double k,
                                                         int positive_x,
                                                         int positive_y,
-                                                        real *next_x,
-                                                        real *next_y);
+                                                        double *next_x,
+                                                        double *next_y);
 static int lanpr_triangle_line_imagespace_intersection_v2(SpinLock *spl,
                                                           LANPR_RenderTriangle *rt,
                                                           LANPR_RenderLine *rl,
@@ -444,8 +444,8 @@ int use_smooth_contour_modifier_contour = 0; /*  debug purpose */
 
 static void lanpr_cut_render_line(LANPR_RenderBuffer *rb,
                                   LANPR_RenderLine *rl,
-                                  real begin,
-                                  real end)
+                                  double begin,
+                                  double end)
 {
   LANPR_RenderLineSegment *rls = rl->segments.first, *irls;
   LANPR_RenderLineSegment *begin_segment = 0, *end_segment = 0;
@@ -464,7 +464,7 @@ static void lanpr_cut_render_line(LANPR_RenderBuffer *rb,
   }
 
   if (begin > end) {
-    real t = begin;
+    double t = begin;
     begin = end;
     end = t;
   }
@@ -656,14 +656,14 @@ static void lanpr_calculate_single_line_occlusion(LANPR_RenderBuffer *rb,
                                                   LANPR_RenderLine *rl,
                                                   int thread_id)
 {
-  real x = rl->l->fbcoord[0], y = rl->l->fbcoord[1];
+  double x = rl->l->fbcoord[0], y = rl->l->fbcoord[1];
   LANPR_BoundingArea *ba = lanpr_get_first_possible_bounding_area(rb, rl);
   LANPR_BoundingArea *nba = ba;
   LANPR_RenderTriangleThread *rt;
   LinkData *lip;
   Object *c = rb->scene->camera;
-  real l, r;
-  real k = (rl->r->fbcoord[1] - rl->l->fbcoord[1]) /
+  double l, r;
+  double k = (rl->r->fbcoord[1] - rl->l->fbcoord[1]) /
            (rl->r->fbcoord[0] - rl->l->fbcoord[0] + 1e-30);
   int positive_x = (rl->r->fbcoord[0] - rl->l->fbcoord[0]) > 0 ?
                       1 :
@@ -798,7 +798,7 @@ static void lanpr_calculate_line_occlusion_begin(LANPR_RenderBuffer *rb)
   MEM_freeN(rti);
 }
 
-int ED_lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v1, tnsVector2d v2)
+int ED_lanpr_point_inside_triangled(double v[2], double v0[2], double v1[2], double v2[2])
 {
   double cl, c;
 
@@ -826,9 +826,9 @@ int ED_lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v
 
   return 1;
 }
-static int lanpr_point_on_lined(tnsVector2d v, tnsVector2d v0, tnsVector2d v1)
+static int lanpr_point_on_lined(double v[2], double v0[2], double v1[2])
 {
-  real c1, c2;
+  double c1, c2;
 
   c1 = tmat_get_linear_ratio(v0[0], v1[0], v[0]);
   c2 = tmat_get_linear_ratio(v0[1], v1[1], v[1]);
@@ -839,13 +839,13 @@ static int lanpr_point_on_lined(tnsVector2d v, tnsVector2d v0, tnsVector2d v1)
 
   return 0;
 }
-static int lanpr_point_triangle_relation(tnsVector2d v,
-                                         tnsVector2d v0,
-                                         tnsVector2d v1,
-                                         tnsVector2d v2)
+static int lanpr_point_triangle_relation(double v[2],
+                                         double v0[2],
+                                         double v1[2],
+                                         double v2[2])
 {
   double cl, c;
-  real r;
+  double r;
   if (lanpr_point_on_lined(v, v0, v1) || lanpr_point_on_lined(v, v1, v2) ||
       lanpr_point_on_lined(v, v2, v0)) {
     return 1;
@@ -881,14 +881,14 @@ static int lanpr_point_triangle_relation(tnsVector2d v,
 
   return 2;
 }
-static int lanpr_point_inside_triangle3de(tnsVector3d v,
-                                          tnsVector3d v0,
-                                          tnsVector3d v1,
-                                          tnsVector3d v2)
+static int lanpr_point_inside_triangle3de(double v[3],
+                                          double v0[3],
+                                          double v1[3],
+                                          double v2[3])
 {
-  tnsVector3d l, r;
-  tnsVector3d N1, N2;
-  real d;
+  double l[3], r[3];
+  double N1[3], N2[3];
+  double d;
 
   sub_v3_v3v3_db(l, v1, v0);
   sub_v3_v3v3_db(r, v, v1);
@@ -1010,7 +1010,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
   LANPR_RenderLineSegment *rls;
   double (*vp)[4] = rb->view_projection;
   int i;
-  real a;
+  double a;
   int v_count = 0, t_count = 0;
   Object *o;
 
@@ -1087,7 +1087,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
       rt1 = (void *)(((unsigned char *)teln->pointer) + rb->triangle_size * t_count);
       rt2 = (void *)(((unsigned char *)teln->pointer) + rb->triangle_size * (t_count + 1));
 
-      real vv1[3], vv2[3], dot1, dot2;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list