[Bf-blender-cvs] [b790e32dedb] temp-lanpr-staging: LANPR: Use BLI math functions. Some added.

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


Commit: b790e32dedb4ef31a8bc8a8a9a9ade1e38504db5
Author: YimingWu
Date:   Mon Aug 12 09:58:24 2019 +0800
Branches: temp-lanpr-staging
https://developer.blender.org/rBb790e32dedb4ef31a8bc8a8a9a9ade1e38504db5

LANPR: Use BLI math functions. Some added.

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

M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/draw/engines/lanpr/lanpr_cpu.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 53e686c87a6..7f526585e3b 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -106,6 +106,7 @@ MINLINE void add_v2_v2(float r[2], const float a[2]);
 MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2]);
 MINLINE void add_v2_v2v2_int(int r[2], const int a[2], const int b[2]);
 MINLINE void add_v3_v3(float r[3], const float a[3]);
+MINLINE void add_v3_v3_db(double r[3], const double a[3]);
 MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void add_v4_v4(float r[4], const float a[4]);
 MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
@@ -119,6 +120,7 @@ MINLINE void sub_v2_v2v2_int(int r[2], const int a[2], const int b[2]);
 MINLINE void sub_v3_v3(float r[3], const float a[3]);
 MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void sub_v3_v3v3_int(int r[3], const int a[3], const int b[3]);
+MINLINE void sub_v3_v3v3_db(double r[3], const double a[3], const double b[3]);
 MINLINE void sub_v4_v4(float r[4], const float a[4]);
 MINLINE void sub_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
@@ -127,6 +129,7 @@ MINLINE void sub_v3db_v3fl_v3fl(double r[3], const float a[3], const float b[3])
 MINLINE void mul_v2_fl(float r[2], float f);
 MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f);
 MINLINE void mul_v3_fl(float r[3], float f);
+MINLINE void mul_v3db_db(double r[3], double f);
 MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f);
 MINLINE void mul_v2_v2(float r[2], const float a[2]);
 MINLINE void mul_v2_v2v2(float r[2], const float a[2], const float b[2]);
@@ -189,6 +192,8 @@ MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESU
 
 MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
 
+MINLINE double dot_v3v3_db(const double a[3], const double b[3]) ATTR_WARN_UNUSED_RESULT;
+
 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]);
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 865c2f5dc25..f646907797c 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -374,6 +374,13 @@ MINLINE void add_v3_v3(float r[3], const float a[3])
   r[2] += a[2];
 }
 
+MINLINE void add_v3_v3_db(double r[3], const double a[3])
+{
+  r[0] += a[0];
+  r[1] += a[1];
+  r[2] += a[2];
+}
+
 MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
 {
   r[0] = a[0] + b[0];
@@ -450,6 +457,13 @@ MINLINE void sub_v3_v3v3_int(int r[3], const int a[3], const int b[3])
   r[2] = a[2] - b[2];
 }
 
+MINLINE void sub_v3_v3v3_db(double r[3], const double a[3], const double b[3])
+{
+  r[0] = a[0] - b[0];
+  r[1] = a[1] - b[1];
+  r[2] = a[2] - b[2];
+}
+
 MINLINE void sub_v3db_v3fl_v3fl(double r[3], const float a[3], const float b[3])
 {
   r[0] = (double)a[0] - (double)b[0];
@@ -492,6 +506,13 @@ MINLINE void mul_v3_fl(float r[3], float f)
   r[2] *= f;
 }
 
+MINLINE void mul_v3db_db(double r[3], double f)
+{
+  r[0] *= f;
+  r[1] *= f;
+  r[2] *= f;
+}
+
 MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
 {
   r[0] = a[0] * f;
@@ -836,6 +857,11 @@ MINLINE double dot_v3db_v3fl(const double a[3], const float b[3])
   return a[0] * (double)b[0] + a[1] * (double)b[1] + a[2] * (double)b[2];
 }
 
+MINLINE double dot_v3v3_db(const double a[3], const double b[3])
+{
+  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+}
+
 MINLINE float cross_v2v2(const float a[2], const float b[2])
 {
   return a[0] * b[1] - a[1] * b[0];
diff --git a/source/blender/draw/engines/lanpr/lanpr_cpu.c b/source/blender/draw/engines/lanpr/lanpr_cpu.c
index 29def5bfd92..423ad643d9a 100644
--- a/source/blender/draw/engines/lanpr/lanpr_cpu.c
+++ b/source/blender/draw/engines/lanpr/lanpr_cpu.c
@@ -94,8 +94,8 @@ static void lanpr_rebuild_render_draw_command(LANPR_RenderBuffer *rb, LANPR_Line
 
     GPU_vertbuf_data_alloc(vbo, vertCount);
 
-    tv = v = CreateNewBuffer(float, 6 * Count);
-    tn = N = CreateNewBuffer(float, 6 * Count);
+    tv = v = MEM_callocN(sizeof(float)*6*Count, "temp v data");
+    tn = N = MEM_callocN(sizeof(float)*6*Count, "temp n data");
 
     if (ll->contour.enabled) {
       tv = lanpr_make_leveled_edge_vertex_array(rb, &rb->contours, tv, tn, &tn, ll, 1.0f);
diff --git a/source/blender/editors/include/ED_lanpr.h b/source/blender/editors/include/ED_lanpr.h
index 593dc105ad0..057107444c7 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -581,89 +581,6 @@ BLI_INLINE double tMatGetLinearRatio(real l, real r, real FromL)
   double ra = (FromL - l) / (r - l);
   return ra;
 }
-BLI_INLINE void tMatVectorMinus2d(tnsVector2d result, tnsVector2d l, tnsVector2d r)
-{
-  result[0] = l[0] - r[0];
-  result[1] = l[1] - r[1];
-}
-
-BLI_INLINE void tMatVectorMinus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r)
-{
-  result[0] = l[0] - r[0];
-  result[1] = l[1] - r[1];
-  result[2] = l[2] - r[2];
-}
-BLI_INLINE void tMatVectorSubtract3d(tnsVector3d l, tnsVector3d r)
-{
-  l[0] = l[0] - r[0];
-  l[1] = l[1] - r[1];
-  l[2] = l[2] - r[2];
-}
-BLI_INLINE void tMatVectorPlus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r)
-{
-  result[0] = l[0] + r[0];
-  result[1] = l[1] + r[1];
-  result[2] = l[2] + r[2];
-}
-BLI_INLINE void tMatVectorAccum3d(tnsVector3d l, tnsVector3d r)
-{
-  l[0] = l[0] + r[0];
-  l[1] = l[1] + r[1];
-  l[2] = l[2] + r[2];
-}
-BLI_INLINE void tMatVectorAccum2d(tnsVector2d l, tnsVector2d r)
-{
-  l[0] = l[0] + r[0];
-  l[1] = l[1] + r[1];
-}
-BLI_INLINE void tMatVectorNegate3d(tnsVector3d result, tnsVector3d l)
-{
-  result[0] = -l[0];
-  result[1] = -l[1];
-  result[2] = -l[2];
-}
-BLI_INLINE void tMatVectorNegateSelf3d(tnsVector3d l)
-{
-  l[0] = -l[0];
-  l[1] = -l[1];
-  l[2] = -l[2];
-}
-BLI_INLINE void tMatVectorCopy2d(tnsVector2d from, tnsVector2d to)
-{
-  to[0] = from[0];
-  to[1] = from[1];
-}
-BLI_INLINE void tMatVectorCopy3d(tnsVector3d from, tnsVector3d to)
-{
-  to[0] = from[0];
-  to[1] = from[1];
-  to[2] = from[2];
-}
-BLI_INLINE void tMatVectorCopy4d(tnsVector4d from, tnsVector4d to)
-{
-  to[0] = from[0];
-  to[1] = from[1];
-  to[2] = from[2];
-  to[3] = from[3];
-}
-BLI_INLINE void tMatVectorMultiSelf4d(tnsVector3d from, real num)
-{
-  from[0] *= num;
-  from[1] *= num;
-  from[2] *= num;
-  from[3] *= num;
-}
-BLI_INLINE void tMatVectorMultiSelf3d(tnsVector3d from, real num)
-{
-  from[0] *= num;
-  from[1] *= num;
-  from[2] *= num;
-}
-BLI_INLINE void tMatVectorMultiSelf2d(tnsVector3d from, real num)
-{
-  from[0] *= num;
-  from[1] *= num;
-}
 
 BLI_INLINE real tMatDirectionToRad(tnsVector2d Dir)
 {
@@ -701,26 +618,6 @@ BLI_INLINE void tMatVectorConvert3fd(tnsVector3f from, tnsVector3d to)
 
 int ED_lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v1, tnsVector2d v2);
 
-#define tnsLinearItp(l, r, T) ((l) * (1.0f - (T)) + (r) * (T))
-
-#define CreateNew(Type) MEM_callocN(sizeof(Type), "VOID") /*  nutCalloc(sizeof(Type),1) */
-
-#define CreateNew_Size(size) nutCalloc(size, 1)
-
-#define CreateNewBuffer(Type, Num) \
-  MEM_callocN(sizeof(Type) * Num, "VOID BUFFER") /*  nutCalloc(sizeof(Type),Num); */
-
-void list_handle_empty(ListBase *h);
-
-void list_clear_prev_next(Link *li);
-
-void list_insert_item_before(ListBase *Handle, Link *toIns, Link *pivot);
-void list_insert_item_after(ListBase *Handle, Link *toIns, Link *pivot);
-void list_insert_segment_before(ListBase *Handle, Link *Begin, Link *End, Link *pivot);
-void lstInsertSegmentAfter(ListBase *Handle, Link *Begin, Link *End, Link *pivot);
-int lstHaveItemInList(ListBase *Handle);
-void *lst_get_top(ListBase *Handle);
-
 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);
@@ -754,12 +651,6 @@ void *list_append_pointer_static_pool(LANPR_StaticMemPool *mph, ListBase *h, voi
 void *list_pop_pointer_no_free(ListBase *h);
 void list_remove_pointer_item_no_free(ListBase *h, LinkData *lip);
 
-void list_move_up(ListBase *h, Link *li);
-void list_move_down(ListBase *h, Link *li);
-
-void lstAddElement(ListBase *hlst, void *ext);
-void lstDestroyElementList(ListBase *hlst);
-
 LANPR_StaticMemPoolNode *mem_new_static_pool(LANPR_StaticMemPool *smp);
 void *mem_static_aquire(LANPR_StaticMemPool *smp, int size);
 void *mem_static_aquire_thread(LANPR_StaticMemPool *smp, int size);
@@ -767,19 +658,6 @@ void *mem_static_destroy(LANPR_StaticMemPool *smp);
 
 void tmat_obmat_to_16d(float obmat[4][4], tnsMatrix44d out);
 
-real tmat_dist_idv2(real x1, real y1, real x2, real y2);
-real tmat_dist_3dv(tnsVector3d l, tnsVector3d r);
-real tmat_dist_2dv(tnsVector2d l, tnsVector2d r);
-
-real tmat_length_3d(tnsVector3d l);
-real tmat_length_2d(tnsVector3d l);
-void tmat_normalize_2d(tnsVector2d result, tnsVector2d l);
-void tmat_normalize_3d(tnsVector3d result, tnsVector3d l);
-void tmat_normalize_3f(tnsVector3f result, tnsVector3f l);
-void tmat_normalize_self_3d(tnsVector3d result);
-real tmat_dot_3d(tnsVector3d l, tnsVector3d r, int normalize);
-real tmat_dot_3df(tnsVector3d l, tnsVector3f r, int normalize);
-real tmat_dot_2d(tnsVector2d l, tnsVector2d r, int normalize);
 real tmat_vector_cross_3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
 void tmat_vector_cross_only_3d(tnsVector3d result, tnsVector3d l, tnsVector3d r);
 real tmat_angle_rad_3d(tnsVector3d from, tnsVector3d to, tnsVector3d PositiveReference);
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index 8d4ef34d51f..a20858c71bf 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -523,7 +523,7 @@ static void lanpr_cut_render_line(LANP

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list