[Bf-blender-cvs] [255048842fa] temp-lanpr-staging: Cleanup: Remove tnsLinearItp().

YimingWu noreply at git.blender.org
Fri Aug 16 03:27:52 CEST 2019


Commit: 255048842fa83ed1c830dacb2cb77245ff99d048
Author: YimingWu
Date:   Mon Aug 12 10:24:09 2019 +0800
Branches: temp-lanpr-staging
https://developer.blender.org/rB255048842fa83ed1c830dacb2cb77245ff99d048

Cleanup: Remove tnsLinearItp().

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

M	source/blender/draw/engines/lanpr/lanpr_dpix.c
M	source/blender/draw/engines/lanpr/lanpr_snake.c
M	source/blender/editors/include/ED_lanpr.h
M	source/blender/editors/lanpr/lanpr_cpu.c

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

diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c
index 62dfb5b3209..2e850500a83 100644
--- a/source/blender/draw/engines/lanpr/lanpr_dpix.c
+++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c
@@ -318,8 +318,8 @@ int lanpr_feed_atlas_data_intersection_cache(void *UNUSED(vedata),
 static void lanpr_dpix_index_to_coord(int index, float *x, float *y)
 {
   int texture_size = lanpr_share.texture_size;
-  (*x) = tnsLinearItp(-1, 1, (float)(index % texture_size + 0.5) / (float)texture_size);
-  (*y) = tnsLinearItp(-1, 1, (float)(index / texture_size + 0.5) / (float)texture_size);
+  (*x) = interpf(1, -1, (float)(index % texture_size + 0.5) / (float)texture_size);
+  (*y) = interpf(1, -1, (float)(index / texture_size + 0.5) / (float)texture_size);
 }
 
 static void lanpr_dpix_index_to_coord_absolute(int index, float *x, float *y)
diff --git a/source/blender/draw/engines/lanpr/lanpr_snake.c b/source/blender/draw/engines/lanpr/lanpr_snake.c
index a27b996cc0c..aaec6ab289e 100644
--- a/source/blender/draw/engines/lanpr/lanpr_snake.c
+++ b/source/blender/draw/engines/lanpr/lanpr_snake.c
@@ -252,8 +252,8 @@ int lanpr_reverse_direction(int From)
 
 void lanpr_texture_to_ndc(int x, int y, int w, int h, float *x_ndc, float *y_ndc)
 {
-  *x_ndc = tnsLinearItp(-1, 1, (float)x / (float)w);
-  *y_ndc = tnsLinearItp(-1, 1, (float)y / (float)h);
+  *x_ndc = interpf(1, -1, (float)x / (float)w);
+  *y_ndc = interpf(1, -1, (float)y / (float)h);
 }
 
 void lanpr_count_drawing_elements(LANPR_PrivateData *pd,
diff --git a/source/blender/editors/include/ED_lanpr.h b/source/blender/editors/include/ED_lanpr.h
index 057107444c7..73edfa0ca55 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -34,8 +34,6 @@
 
 #include "DNA_lanpr_types.h"
 
-#define _CRT_SECURE_NO_WARNINGS
-
 #ifndef BYTE
 #  define BYTE unsigned char
 #endif
@@ -430,16 +428,10 @@ typedef struct LANPR_BoundingArea {
 /* #define TNS_OVERRIDE_ALL_OTHERS_IN_GROUP      3 */
 /* #define TNS_OVERRIDE_ALL_OTHERS               4 */
 
-#define tnsLinearItp(l, r, T) ((l) * (1.0f - (T)) + (r) * (T))
-
 #define TNS_TILE(tile, r, c, CCount) tile[r * CCount + c]
 
 #define TNS_CLAMP(a, Min, Max) a = a < Min ? Min : (a > Max ? Max : a)
 
-#define TNS_MAX2_INDEX(a, b) (a > b ? 0 : 1)
-
-#define TNS_MIN2_INDEX(a, b) (a < b ? 0 : 1)
-
 #define TNS_MAX3_INDEX(a, b, c) (a > b ? (a > c ? 0 : (b > c ? 1 : 2)) : (b > c ? 1 : 2))
 
 #define TNS_MIN3_INDEX(a, b, c) (a < b ? (a < c ? 0 : (b < c ? 1 : 2)) : (b < c ? 1 : 2))
@@ -521,14 +513,14 @@ BLI_INLINE int lanpr_LineIntersectTest2d(
       return 0;
     }
     double r2 = tMatGetLinearRatio(b1[0], b2[0], a1[0]);
-    x = tnsLinearItp(b1[0], b2[0], r2);
-    y = tnsLinearItp(b1[1], b2[1], r2);
+    x = interpd(b2[0], b1[0], r2);
+    y = interpd(b2[1], b1[1], r2);
     *aRatio = Ratio = tMatGetLinearRatio(a1[1], a2[1], y);
   }
   else {
     if (xDiff2 == 0) {
       Ratio = tMatGetLinearRatio(a1[0], a2[0], b1[0]);
-      x = tnsLinearItp(a1[0], a2[0], Ratio);
+      x = interpd(a2[0], a1[0], Ratio);
       *aRatio = Ratio;
     }
     else {
@@ -547,7 +539,7 @@ BLI_INLINE int lanpr_LineIntersectTest2d(
   }
 
   if (b1[0] == b2[0]) {
-    y = tnsLinearItp(a1[1], a2[1], Ratio);
+    y = interpd(a2[1], a1[1], Ratio);
     if (y > MAX2(b1[1], b2[1]) || y < MIN2(b1[1], b2[1]))
       return 0;
   }
@@ -560,15 +552,13 @@ BLI_INLINE int lanpr_LineIntersectTest2d(
 }
 BLI_INLINE double lanpr_GetLineZ(tnsVector3d l, tnsVector3d r, real Ratio)
 {
-  /*  double z = 1 / tnsLinearItp(1 / l[2], 1 / r[2], Ratio); */
-  double z = tnsLinearItp(l[2], r[2], Ratio);
+  double z = interpd(r[2], l[2], Ratio);
   return z;
 }
 BLI_INLINE double lanpr_GetLineZPoint(tnsVector3d l, tnsVector3d r, tnsVector3d FromL)
 {
   double ra = (FromL[0] - l[0]) / (r[0] - l[0]);
-  return tnsLinearItp(l[2], r[2], ra);
-  /*  return 1 / tnsLinearItp(1 / l[2], 1 / r[2], r); */
+  return interpd(r[2], l[2], ra);
 }
 BLI_INLINE double lanpr_GetLinearRatio(tnsVector3d l, tnsVector3d r, tnsVector3d FromL)
 {
@@ -582,71 +572,13 @@ BLI_INLINE double tMatGetLinearRatio(real l, real r, real FromL)
   return ra;
 }
 
-BLI_INLINE real tMatDirectionToRad(tnsVector2d Dir)
-{
-  real arcc = acos(Dir[0]);
-  real arcs = asin(Dir[1]);
-
-  if (Dir[0] >= 0) {
-    if (Dir[1] >= 0)
-      return arcc;
-    else
-      return M_PI * 2 - arcc;
-  }
-  else {
-    if (Dir[1] >= 0)
-      return arcs + M_PI / 2;
-    else
-      return M_PI + arcs;
-  }
-}
-
-BLI_INLINE void tMatVectorConvert4fd(tnsVector4f from, tnsVector4d to)
-{
-  to[0] = from[0];
-  to[1] = from[1];
-  to[2] = from[2];
-  to[3] = from[3];
-}
-
-BLI_INLINE void tMatVectorConvert3fd(tnsVector3f from, tnsVector3d to)
-{
-  to[0] = from[0];
-  to[1] = from[1];
-  to[2] = from[2];
-}
-
 int ED_lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v1, tnsVector2d v2);
 
-void *list_append_pointer_only(ListBase *h, void *p);
-void *list_append_pointer_sized_only(ListBase *h, void *p, int size);
-void *list_push_pointer_only(ListBase *h, void *p);
-void *list_push_pointer_sized_only(ListBase *h, void *p, int size);
-
-void *list_append_pointer(ListBase *h, void *p);
-void *list_append_pointer_sized(ListBase *h, void *p, int size);
-void *list_push_pointer(ListBase *h, void *p);
-void *list_push_pointer_sized(ListBase *h, void *p, int size);
-
 void *list_append_pointer_static(ListBase *h, LANPR_StaticMemPool *smp, void *p);
 void *list_append_pointer_static_sized(ListBase *h, LANPR_StaticMemPool *smp, void *p, int size);
 void *list_push_pointer_static(ListBase *h, LANPR_StaticMemPool *smp, void *p);
 void *list_push_pointer_static_sized(ListBase *h, LANPR_StaticMemPool *smp, void *p, int size);
 
-void *list_pop_pointer_only(ListBase *h);
-void list_remove_pointer_item_only(ListBase *h, LinkData *lip);
-void list_remove_pointer_only(ListBase *h, void *p);
-void list_clear_pointer_only(ListBase *h);
-void list_generate_pointer_list_only(ListBase *from1, ListBase *from2, ListBase *to);
-
-void *list_pop_pointer(ListBase *h);
-void list_remove_pointer_item(ListBase *h, LinkData *lip);
-void list_remove_pointer(ListBase *h, void *p);
-void list_clear_pointer(ListBase *h);
-void list_generate_pointer_list(ListBase *from1, ListBase *from2, ListBase *to);
-
-void list_copy_handle(ListBase *target, ListBase *src);
-
 void *list_append_pointer_static_pool(LANPR_StaticMemPool *mph, ListBase *h, void *p);
 void *list_pop_pointer_no_free(ListBase *h);
 void list_remove_pointer_item_no_free(ListBase *h, LinkData *lip);
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index a20858c71bf..c1a98ac5c21 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -1946,7 +1946,7 @@ static int lanpr_triangle_line_imagespace_intersection_v2(SpinLock *UNUSED(spl),
 
   copy_v3_v3_db(Cv, CameraDir);
 
-  tMatVectorConvert4fd(cam->obmat[3], vd4);
+  copy_v4db_v4fl(vd4, cam->obmat[3]);
   if (((Camera *)cam->data)->type == CAM_PERSP) {
     sub_v3_v3v3_db(Cv, vd4, rt->v[0]->gloc);
   }
@@ -2293,7 +2293,7 @@ static LANPR_RenderLine *lanpr_triangle_generate_intersection_line_only(
   LANPR_RenderVert *Share = lanpr_triangle_share_point(testing, rt);
   Camera *cam = rb->scene->camera->data;
 
-  tMatVectorConvert3fd(rb->scene->camera->obmat[3], cl);
+  copy_v3db_v3fl(cl, rb->scene->camera->obmat[3]);
 
   if (Share) {
     LANPR_RenderVert *NewShare;
@@ -2504,7 +2504,7 @@ static void lanpr_compute_scene_contours(LANPR_RenderBuffer *rb, float threshold
     Dot2 = 0;
 
     if (c->type == CAM_PERSP) {
-      tMatVectorConvert3fd(cam_obj->obmat[3], cam_location);
+      copy_v3db_v3fl(cam_location, cam_obj->obmat[3]);
       sub_v3_v3v3_db(view_vector, rl->l->gloc, cam_location);
     }
 
@@ -2852,15 +2852,15 @@ void *lanpr_make_leveled_edge_vertex_array(LANPR_RenderBuffer *UNUSED(rb),
         CLAMP(irls->at, 0, 1);
       }
 
-      *v = tnsLinearItp(rl->l->fbcoord[0], rl->r->fbcoord[0], rls->at);
+      *v = interpf(rl->r->fbcoord[0], rl->l->fbcoord[0], rls->at);
       v++;
-      *v = tnsLinearItp(rl->l->fbcoord[1], rl->r->fbcoord[1], rls->at);
+      *v = interpf(rl->r->fbcoord[1], rl->l->fbcoord[1], rls->at);
       v++;
       *v = componet_id;
       v++;
-      *v = tnsLinearItp(rl->l->fbcoord[0], rl->r->fbcoord[0], irls ? irls->at : 1);
+      *v = interpf(rl->r->fbcoord[0], rl->l->fbcoord[0], irls ? irls->at : 1);
       v++;
-      *v = tnsLinearItp(rl->l->fbcoord[1], rl->r->fbcoord[1], irls ? irls->at : 1);
+      *v = interpf(rl->r->fbcoord[1], rl->l->fbcoord[1], irls ? irls->at : 1);
       v++;
       *v = componet_id;
       v++;



More information about the Bf-blender-cvs mailing list