[Bf-blender-cvs] [a0d89533358] soc-2019-npr: Math: Double version of interpolate functions.

YimingWu noreply at git.blender.org
Mon Jul 15 10:46:35 CEST 2019


Commit: a0d8953335806bd3e0bd8c06b94450d84a25e408
Author: YimingWu
Date:   Mon Jul 15 16:43:07 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBa0d8953335806bd3e0bd8c06b94450d84a25e408

Math: Double version of interpolate functions.

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

M	source/blender/blenlib/BLI_math_base.h
M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_base_inline.c
M	source/blender/blenlib/intern/math_vector.c
M	source/blender/draw/CMakeLists.txt
R100	source/blender/draw/engines/lanpr/lanpr_ops.c	source/blender/draw/engines/lanpr/lanpr_cpu.c
M	source/blender/editors/include/ED_lanpr.h
M	source/blender/editors/lanpr/lanpr_chain.c
M	source/blender/editors/lanpr/lanpr_ops.c
M	source/blender/editors/lanpr/lanpr_util.c

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

diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 177a1a84b16..6345e5f706c 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -112,6 +112,7 @@ MINLINE float saasin(float fac);
 MINLINE float sasqrt(float fac);
 
 MINLINE float interpf(float a, float b, float t);
+MINLINE double interpd(double a, double b, double t);
 
 MINLINE float min_ff(float a, float b);
 MINLINE float max_ff(float a, float b);
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 2815046865d..53e686c87a6 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -231,9 +231,11 @@ MINLINE double normalize_v3_d(double n[3]);
 /******************************* Interpolation *******************************/
 
 void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t);
+void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], const double t);
 void interp_v2_v2v2v2(
     float r[2], const float a[2], const float b[2], const float c[2], const float t[3]);
 void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t);
+void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], const double t);
 void interp_v3_v3v3v3(
     float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3]);
 void interp_v3_v3v3v3v3(float p[3],
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 8f30255a08b..ce381fbe4a1 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -171,6 +171,11 @@ MINLINE float interpf(float target, float origin, float fac)
   return (fac * target) + (1.0f - fac) * origin;
 }
 
+MINLINE double interpd(double target, double  origin, double fac)
+{
+  return (fac * target) + (1.0f - fac) * origin;
+}
+
 /* used for zoom values*/
 MINLINE float power_of_2(float val)
 {
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c
index 1977558ac88..961850d3a9a 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -1392,4 +1392,21 @@ void mul_vn_db(double *array_tar, const int size, const double f)
   }
 }
 
+void interp_v3_v3v3_db(double target[3], const double a[3], const double b[3], const double t)
+{
+  const double s = 1.0f - t;
+
+  target[0] = s * a[0] + t * b[0];
+  target[1] = s * a[1] + t * b[1];
+  target[2] = s * a[2] + t * b[2];
+}
+
+void interp_v2_v2v2_db(double target[2], const double a[2], const double b[2], const double t)
+{
+  const double s = 1.0f - t;
+
+  target[0] = s * a[0] + t * b[0];
+  target[1] = s * a[1] + t * b[1];
+}
+
 /** \} */
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 245de082a59..a6ec33ec9d1 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -129,7 +129,7 @@ set(SRC
 	engines/lanpr/lanpr_dpix.c
 	engines/lanpr/lanpr_engine.c
 	engines/lanpr/lanpr_snake.c
-	engines/lanpr/lanpr_ops.c
+	engines/lanpr/lanpr_cpu.c
   engines/lanpr/lanpr_chain_draw.c
 
   DRW_engine.h
diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c b/source/blender/draw/engines/lanpr/lanpr_cpu.c
similarity index 100%
rename from source/blender/draw/engines/lanpr/lanpr_ops.c
rename to source/blender/draw/engines/lanpr/lanpr_cpu.c
diff --git a/source/blender/editors/include/ED_lanpr.h b/source/blender/editors/include/ED_lanpr.h
index ff395760530..5c4abd9187e 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -681,9 +681,6 @@ BLI_INLINE void tMatVectorConvert3fd(tnsVector3f from, tnsVector3d to)
 }
 
 int ED_lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v1, tnsVector2d v2);
-real lanpr_LinearInterpolate(real l, real r, real T);
-void lanpr_LinearInterpolate2dv(real *l, real *r, real T, real *Result);
-void lanpr_LinearInterpolate3dv(real *l, real *r, real T, real *Result);
 
 #define tnsLinearItp(l, r, T) ((l) * (1.0f - (T)) + (r) * (T))
 
diff --git a/source/blender/editors/lanpr/lanpr_chain.c b/source/blender/editors/lanpr/lanpr_chain.c
index d9ce1c5b0f1..ece0693d5ec 100644
--- a/source/blender/editors/lanpr/lanpr_chain.c
+++ b/source/blender/editors/lanpr/lanpr_chain.c
@@ -273,8 +273,8 @@ void ED_lanpr_NO_THREAD_chain_feature_lines(LANPR_RenderBuffer *rb)
       if (new_rv == new_rl->l) {
         for (rls = new_rl->segments.last; rls; rls = rls->prev) {
           double gpos[3], lpos[3];
-          lanpr_LinearInterpolate3dv(new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at, lpos);
-          lanpr_LinearInterpolate3dv(new_rl->l->gloc, new_rl->r->gloc, rls->at, gpos);
+          interp_v3_v3v3_db( lpos,new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
+          interp_v3_v3v3_db( gpos,new_rl->l->gloc, new_rl->r->gloc, rls->at);
           lanpr_push_render_line_chain_point(rb,
                                              rlc,
                                              lpos[0],
@@ -294,8 +294,8 @@ void ED_lanpr_NO_THREAD_chain_feature_lines(LANPR_RenderBuffer *rb)
         rls = rls->next;
         for (rls; rls; rls = rls->next) {
           double gpos[3], lpos[3];
-          lanpr_LinearInterpolate3dv(new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at, lpos);
-          lanpr_LinearInterpolate3dv(new_rl->l->gloc, new_rl->r->gloc, rls->at, gpos);
+          interp_v3_v3v3_db( lpos,new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
+          interp_v3_v3v3_db( gpos,new_rl->l->gloc, new_rl->r->gloc, rls->at);
           lanpr_push_render_line_chain_point(rb,
                                              rlc,
                                              lpos[0],
@@ -327,8 +327,8 @@ void ED_lanpr_NO_THREAD_chain_feature_lines(LANPR_RenderBuffer *rb)
     last_occlusion = ((LANPR_RenderLineSegment *)rls)->occlusion;
     for (rls = rls->next; rls; rls = rls->next) {
       double gpos[3], lpos[3];
-      lanpr_LinearInterpolate3dv(rl->l->fbcoord, rl->r->fbcoord, rls->at, lpos);
-      lanpr_LinearInterpolate3dv(rl->l->gloc, rl->r->gloc, rls->at, gpos);
+      interp_v3_v3v3_db( lpos,rl->l->fbcoord, rl->r->fbcoord, rls->at);
+      interp_v3_v3v3_db( gpos,rl->l->gloc, rl->r->gloc, rls->at);
       lanpr_append_render_line_chain_point(
           rb, rlc, lpos[0], lpos[1], gpos[0], gpos[1], gpos[2], N, rl->flags, rls->occlusion);
       last_occlusion = rls->occlusion;
@@ -363,8 +363,8 @@ void ED_lanpr_NO_THREAD_chain_feature_lines(LANPR_RenderBuffer *rb)
         rlci->occlusion = last_occlusion; /*  fix leading vertex occlusion */
         for (rls = new_rl->segments.last; rls; rls = rls->prev) {
           double gpos[3], lpos[3];
-          lanpr_LinearInterpolate3dv(new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at, lpos);
-          lanpr_LinearInterpolate3dv(new_rl->l->gloc, new_rl->r->gloc, rls->at, gpos);
+          interp_v3_v3v3_db( lpos,new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
+          interp_v3_v3v3_db( gpos,new_rl->l->gloc, new_rl->r->gloc, rls->at);
           last_occlusion = rls->prev ? rls->prev->occlusion : last_occlusion;
           lanpr_append_render_line_chain_point(rb,
                                                rlc,
@@ -385,8 +385,8 @@ void ED_lanpr_NO_THREAD_chain_feature_lines(LANPR_RenderBuffer *rb)
         rls = rls->next;
         for (rls; rls; rls = rls->next) {
           double gpos[3], lpos[3];
-          lanpr_LinearInterpolate3dv(new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at, lpos);
-          lanpr_LinearInterpolate3dv(new_rl->l->gloc, new_rl->r->gloc, rls->at, gpos);
+          interp_v3_v3v3_db( lpos,new_rl->l->fbcoord, new_rl->r->fbcoord, rls->at);
+          interp_v3_v3v3_db( gpos,new_rl->l->gloc, new_rl->r->gloc, rls->at);
           lanpr_append_render_line_chain_point(rb,
                                                rlc,
                                                lpos[0],
diff --git a/source/blender/editors/lanpr/lanpr_ops.c b/source/blender/editors/lanpr/lanpr_ops.c
index 3895ee6aa7a..97e5e777ab1 100644
--- a/source/blender/editors/lanpr/lanpr_ops.c
+++ b/source/blender/editors/lanpr/lanpr_ops.c
@@ -1123,9 +1123,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot1 = tmat_dot_3d(vv1, view_dir, 0);
             dot2 = tmat_dot_3d(vv2, view_dir, 0);
             a = dot1 / (dot1 + dot2);
-            rv[0].gloc[0] = (1 - a) * rt->v[0]->gloc[0] + a * rt->v[2]->gloc[0];
-            rv[0].gloc[1] = (1 - a) * rt->v[0]->gloc[1] + a * rt->v[2]->gloc[1];
-            rv[0].gloc[2] = (1 - a) * rt->v[0]->gloc[2] + a * rt->v[2]->gloc[2];
+            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);
 
             tMatVectorMinus3d(vv1, rt->v[0]->gloc, cam_pos);
@@ -1133,9 +1131,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot1 = tmat_dot_3d(vv1, view_dir, 0);
             dot2 = tmat_dot_3d(vv2, view_dir, 0);
             a = dot1 / (dot1 + dot2);
-            rv[1].gloc[0] = (1 - a) * rt->v[0]->gloc[0] + a * rt->v[1]->gloc[0];
-            rv[1].gloc[1] = (1 - a) * rt->v[0]->gloc[1] + a * rt->v[1]->gloc[1];
-            rv[1].gloc[2] = (1 - a) * rt->v[0]->gloc[2] + a * rt->v[1]->gloc[2];
+            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);
 
             BLI_remlink(&rb->all_render_lines, (void *)rt->rl[0]);
@@ -1193,9 +1189,7 @@ static void lanpr_cull_triangles(LANPR_RenderBuffer *rb)
             dot1 = tmat_dot_3d(vv1, view_dir, 0);
             dot2 = tmat_dot_3d(vv2, view_dir, 0);
             a = dot1 / (dot1 + dot2);
-            rv[0].gloc[0] = (1 - a) * rt->v[2]->gloc[0] + a * rt->v[0]->gloc[0];
-            rv[0].gloc[1] = (1 - a) * rt->v[2]->gloc[1] + a * rt->v[0]->gloc[1];
-            rv[0].gloc[2] = (1 - a) * rt->v[2]->gloc[2] + a * rt->v[0]->gloc[2];
+            interp_v3_v3v3_db(

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list