Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-04-16 20:49:37 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-16 20:49:37 +0400
commit67f8e3a3a7af4146b9bb7ae40f1bdc8dabc2b48f (patch)
treee70b92076373c720df61107bcd8e134d1006c76a /source/blender/blenlib
parente889fa467816950c828f7696be2433c472a7d4ad (diff)
inline function for "Newell's Method" used for normal calc.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_vector.h2
-rw-r--r--source/blender/blenlib/intern/math_base_inline.c2
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c15
-rw-r--r--source/blender/blenlib/intern/scanfill.c4
4 files changed, 17 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 7fba2699fc7..54c06616110 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -124,6 +124,8 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]);
MINLINE float cross_v2v2(const float a[2], const float b[2]);
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3]);
+
MINLINE void star_m3_v3(float rmat[3][3],float a[3]);
/*********************************** Length **********************************/
diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c
index 58c882e894e..b2d5392c596 100644
--- a/source/blender/blenlib/intern/math_base_inline.c
+++ b/source/blender/blenlib/intern/math_base_inline.c
@@ -92,7 +92,7 @@ MINLINE float saasinf(float fac)
MINLINE float sasqrtf(float fac)
{
if (fac <= 0.0f) return 0.0f;
- return (float)sqrtf(fac);
+ return sqrtf(fac);
}
MINLINE float interpf(float target, float origin, float fac)
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 62e582c89c4..ef8f26e3780 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -480,6 +480,17 @@ MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
r[2] = a[0] * b[1] - a[1] * b[0];
}
+/* Newell's Method */
+/* excuse this fairly spesific function,
+ * its used for polygon normals all over the place
+ * could use a better name */
+MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3])
+{
+ n[0] += (v_prev[1] - v_curr[1]) * (v_prev[2] + v_curr[2]);
+ n[1] += (v_prev[2] - v_curr[2]) * (v_prev[0] + v_curr[0]);
+ n[2] += (v_prev[0] - v_curr[0]) * (v_prev[1] + v_curr[1]);
+}
+
MINLINE void star_m3_v3(float rmat[][3], float a[3])
{
rmat[0][0] = rmat[1][1] = rmat[2][2] = 0.0;
@@ -505,7 +516,7 @@ MINLINE float len_squared_v3(const float v[3])
MINLINE float len_v2(const float v[2])
{
- return (float)sqrtf(v[0] * v[0] + v[1] * v[1]);
+ return sqrtf(v[0] * v[0] + v[1] * v[1]);
}
MINLINE float len_v2v2(const float v1[2], const float v2[2])
@@ -514,7 +525,7 @@ MINLINE float len_v2v2(const float v1[2], const float v2[2])
x = v1[0] - v2[0];
y = v1[1] - v2[1];
- return (float)sqrtf(x * x + y * y);
+ return sqrtf(x * x + y * y);
}
MINLINE float len_v3(const float a[3])
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index a303cadab85..1b60d58b154 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -864,9 +864,7 @@ int BLI_edgefill(ScanFillContext *sf_ctx, const short do_quad_tri_speedup)
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
if (LIKELY(!compare_v3v3(v_prev, eve->co, COMPLIMIT))) {
- n[0] += (v_prev[1] - eve->co[1]) * (v_prev[2] + eve->co[2]);
- n[1] += (v_prev[2] - eve->co[2]) * (v_prev[0] + eve->co[0]);
- n[2] += (v_prev[0] - eve->co[0]) * (v_prev[1] + eve->co[1]);
+ add_newell_cross_v3_v3v3(n, v_prev, eve->co);
}
v_prev = eve->co;
}