Commit: a10eda79550cfb83aa05fc69231715872f9ec5ca
Author: YimingWu
Date:   Wed Aug 14 18:26:07 2019 +0800
Branches: temp-lanpr-staging
https://developer.blender.org/rBa10eda79550cfb83aa05fc69231715872f9ec5ca

LANPR: Use built-in math functions.

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

M       source/blender/blenlib/BLI_math_vector.h
M       source/blender/blenlib/intern/math_vector_inline.c
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/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index 7f526585e3b..ccb42683d5a 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -197,6 +197,7 @@ MINLINE double dot_v3v3_db(const double a[3], const double 
b[3]) ATTR_WARN_UNUSE
 MINLINE float cross_v2v2(const float a[2], const float b[2]) 
ATTR_WARN_UNUSED_RESULT;
 MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void cross_v3_v3v3_hi_prec(float r[3], const float a[3], const float 
b[3]);
+MINLINE void cross_v3_v3v3_db(double r[3], const double a[3], const double 
b[3]);
 
 MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const 
float v_curr[3]);
 
diff --git a/source/blender/blenlib/intern/math_vector_inline.c 
b/source/blender/blenlib/intern/math_vector_inline.c
index f646907797c..8cb618ae14e 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -885,6 +885,14 @@ MINLINE void cross_v3_v3v3_hi_prec(float r[3], const float 
a[3], const float b[3
   r[2] = (float)((double)a[0] * (double)b[1] - (double)a[1] * (double)b[0]);
 }
 
+MINLINE void cross_v3_v3v3_db(double r[3], const double a[3], const double 
b[3])
+{
+  BLI_assert(r != a && r != b);
+  r[0] = a[1] * b[2] - a[2] * b[1];
+  r[1] = a[2] * b[0] - a[0] * b[2];
+  r[2] = a[0] * b[1] - a[1] * b[0];
+}
+
 /* Newell's Method */
 /* excuse this fairly specific function,
  * its used for polygon normals all over the place
diff --git a/source/blender/editors/include/ED_lanpr.h 
b/source/blender/editors/include/ED_lanpr.h
index 73edfa0ca55..dffbd5b7eee 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -91,7 +91,7 @@ typedef struct LANPR_RenderTriangle {
   struct LANPR_RenderTriangle *next, *prev;
   struct LANPR_RenderVert *v[3];
   struct LANPR_RenderLine *rl[3];
-  real gn[3];
+  float gn[3];
   real gc[3];
   /*  struct BMFace *F; */
   short material_id;
@@ -225,8 +225,8 @@ typedef struct LANPR_RenderBuffer {
   int tile_size_w, tile_size_h;
   int tile_count_x, tile_count_y;
   real width_per_tile, height_per_tile;
-  tnsMatrix44d view_projection;
-  tnsMatrix44d vp_inverse;
+  float view_projection[4][4];
+  float vp_inverse[4][4];
 
   int output_mode;
   int output_aa_level;
@@ -253,7 +253,7 @@ typedef struct LANPR_RenderBuffer {
 
   int cached_for_frame;
 
-  real view_vector[3];
+  double view_vector[3];
 
   int triangle_size;
 
@@ -606,8 +606,8 @@ void tmat_apply_transform_44dTrue(tnsVector4d result, 
tnsMatrix44d mat, tnsVecto
 void tmat_load_identity_44d(tnsMatrix44d m);
 void tmat_make_ortho_matrix_44d(
     tnsMatrix44d mProjection, real xMin, real xMax, real yMin, real yMax, real 
zMin, real zMax);
-void tmat_make_perspective_matrix_44d(
-    tnsMatrix44d mProjection, real fFov_rad, real fAspect, real zMin, real 
zMax);
+void tmat_make_perspective_matrix_44f(
+    float (*mProjection)[4], float fFov_rad, float fAspect, float zMin, float 
zMax);
 void tmat_make_translation_matrix_44d(tnsMatrix44d mTrans, real x, real y, 
real z);
 void tmat_make_rotation_matrix_44d(tnsMatrix44d m, real angle_rad, real x, 
real y, real z);
 void tmat_make_scale_matrix_44d(tnsMatrix44d m, real x, real y, real z);
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c 
b/source/blender/editors/lanpr/lanpr_cpu.c
index c1a98ac5c21..ac9bb5ec3ba 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -92,7 +92,7 @@ static int 
lanpr_triangle_line_imagespace_intersection_v2(SpinLock *spl,
                                                           LANPR_RenderTriangle 
*rt,
                                                           LANPR_RenderLine *rl,
                                                           Object *cam,
-                                                          tnsMatrix44d vp,
+                                                          float (*vp)[4],
                                                           real *CameraDir,
                                                           double *From,
                                                           double *To);
@@ -579,7 +579,7 @@ static int 
lanpr_make_next_occlusion_task_info(LANPR_RenderBuffer *rb, LANPR_Ren
     res = 1;
   }
   else {
-    BLI_listbase_is_empty(&rti->contour_pointers);
+    BLI_listbase_clear(&rti->contour_pointers);
     rti->contour = 0;
   }
 
@@ -595,7 +595,7 @@ static int 
lanpr_make_next_occlusion_task_info(LANPR_RenderBuffer *rb, LANPR_Ren
     res = 1;
   }
   else {
-    BLI_listbase_is_empty(&rti->intersection_pointers);
+    BLI_listbase_clear(&rti->intersection_pointers);
     rti->intersection = 0;
   }
 
@@ -611,7 +611,7 @@ static int 
lanpr_make_next_occlusion_task_info(LANPR_RenderBuffer *rb, LANPR_Ren
     res = 1;
   }
   else {
-    BLI_listbase_is_empty(&rti->crease_pointers);
+    BLI_listbase_clear(&rti->crease_pointers);
     rti->crease = 0;
   }
 
@@ -627,7 +627,7 @@ static int 
lanpr_make_next_occlusion_task_info(LANPR_RenderBuffer *rb, LANPR_Ren
     res = 1;
   }
   else {
-    BLI_listbase_is_empty(&rti->material_pointers);
+    BLI_listbase_clear(&rti->material_pointers);
     rti->material = 0;
   }
 
@@ -643,7 +643,7 @@ static int 
lanpr_make_next_occlusion_task_info(LANPR_RenderBuffer *rb, LANPR_Ren
     res = 1;
   }
   else {
-    BLI_listbase_is_empty(&rti->edge_mark_pointers);
+    BLI_listbase_clear(&rti->edge_mark_pointers);
     rti->edge_mark = 0;
   }
 
@@ -861,15 +861,11 @@ static int lanpr_point_inside_triangle3de(tnsVector3d v,
 
   sub_v3_v3v3_db(l, v1, v0);
   sub_v3_v3v3_db(r, v, v1);
-  /*  tmat_normalize_self_3d(l); */
-  /*  tmat_normalize_self_3d(r); */
-  tmat_vector_cross_3d(N1, l, r);
+  cross_v3_v3v3_db(N1,l,r);
 
   sub_v3_v3v3_db(l, v2, v1);
   sub_v3_v3v3_db(r, v, v2);
-  /*  tmat_normalize_self_3d(l); */
-  /*  tmat_normalize_self_3d(r); */
-  tmat_vector_cross_3d(N2, l, r);
+  cross_v3_v3v3_db(N2,l,r);
 
   if ((d = dot_v3v3_db(N1,  N2)) < 0) {
     return 0;
@@ -878,9 +874,7 @@ static int lanpr_point_inside_triangle3de(tnsVector3d v,
 
   sub_v3_v3v3_db(l, v0, v2);
   sub_v3_v3v3_db(r, v, v0);
-  /*  tmat_normalize_self_3d(l); */
-  /*  tmat_normalize_self_3d(r); */
-  tmat_vector_cross_3d(N1, l, r);
+  cross_v3_v3v3_db(N1,l,r);
 
   if ((d = dot_v3v3_db(N1,  N2)) < 0) {
     return 0;
@@ -889,9 +883,7 @@ static int lanpr_point_inside_triangle3de(tnsVector3d v,
 
   sub_v3_v3v3_db(l, v1, v0);
   sub_v3_v3v3_db(r, v, v1);
-  /*  tmat_normalize_self_3d(l); */
-  /*  tmat_normalize_self_3d(r); */
-  tmat_vector_cross_3d(N2, l, r);
+  cross_v3_v3v3_db(N2,l,r);
 
   if ((d = dot_v3v3_db(N1,  N2)) < 0) {
     return 0;
@@ -983,7 +975,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
   LANPR_RenderVert *rv;
   LANPR_RenderElementLinkNode *reln, *veln, *teln;
   LANPR_RenderLineSegment *rls;
-  real *vp = rb->view_projection;
+  float** vp = rb->view_projection;
   int i;
   real a;
   int v_count = 0, t_count = 0;
@@ -1069,7 +1061,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot1 / (dot1 + dot2);
             interp_v3_v3v3_db(rv[0].gloc, rt->v[0]->gloc, rt->v[2]->gloc, a);
-            tmat_apply_transform_44d(rv[0].fbcoord, vp, rv[0].gloc);
+            mul_v4d_m4v4d(rv[0].fbcoord, vp, rv[0].gloc);
 
             sub_v3_v3v3_db(vv1, rt->v[0]->gloc, cam_pos);
             sub_v3_v3v3_db(vv2, cam_pos, rt->v[1]->gloc);
@@ -1077,7 +1069,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot1 / (dot1 + dot2);
             interp_v3_v3v3_db(rv[1].gloc, rt->v[0]->gloc, rt->v[1]->gloc, a);
-            tmat_apply_transform_44d(rv[1].fbcoord, vp, rv[1].gloc);
+            mul_v4d_m4v4d(rv[1].fbcoord, vp, rv[1].gloc);
 
             BLI_remlink(&rb->all_render_lines, (void *)rt->rl[0]);
             rt->rl[0]->next = rt->rl[0]->prev = 0;
@@ -1135,7 +1127,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot1 / (dot1 + dot2);
             interp_v3_v3v3_db(rv[0].gloc, rt->v[2]->gloc, rt->v[0]->gloc, a);
-            tmat_apply_transform_44d(rv[0].fbcoord, vp, rv[0].gloc);
+            mul_v4d_m4v4d(rv[0].fbcoord, vp, rv[0].gloc);
 
             sub_v3_v3v3_db(vv1, rt->v[2]->gloc, cam_pos);
             sub_v3_v3v3_db(vv2, cam_pos, rt->v[1]->gloc);
@@ -1143,7 +1135,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot1 / (dot1 + dot2);
             interp_v3_v3v3_db(rv[1].gloc, rt->v[2]->gloc, rt->v[1]->gloc, a);
-            tmat_apply_transform_44d(rv[1].fbcoord, vp, rv[1].gloc);
+            mul_v4d_m4v4d(rv[1].fbcoord, vp, rv[1].gloc);
 
             BLI_remlink(&rb->all_render_lines, (void *)rt->rl[0]);
             rt->rl[0]->next = rt->rl[0]->prev = 0;
@@ -1201,7 +1193,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot1 / (dot1 + dot2);
             interp_v3_v3v3_db(rv[0].gloc, rt->v[1]->gloc, rt->v[2]->gloc, a);
-            tmat_apply_transform_44d(rv[0].fbcoord, vp, rv[0].gloc);
+            mul_v4d_m4v4d(rv[0].fbcoord, vp, rv[0].gloc);
 
             sub_v3_v3v3_db(vv1, rt->v[1]->gloc, cam_pos);
             sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
@@ -1209,7 +1201,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot1 / (dot1 + dot2);
             interp_v3_v3v3_db(rv[1].gloc, rt->v[1]->gloc, rt->v[0]->gloc, a);
-            tmat_apply_transform_44d(rv[1].fbcoord, vp, rv[1].gloc);
+            mul_v4d_m4v4d(rv[1].fbcoord, vp, rv[1].gloc);
 
             BLI_remlink(&rb->all_render_lines, (void *)rt->rl[0]);
             rt->rl[0]->next = rt->rl[0]->prev = 0;
@@ -1270,7 +1262,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot2 = dot_v3v3_db(vv2,  view_dir);
             a = dot2 / 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to