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>2014-03-30 04:08:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-30 04:08:33 +0400
commit1f58bfb8bebf207d3020ff474ac5e018c8179f25 (patch)
treecf365a66923b4a03bcfbf6ef43d07ccf6309a19e /source/blender/blenlib
parent23ef10c705a21d86e06f64d7af06fddbd9a42928 (diff)
Code cleanup: de-duplicate cotangent weight function & add arg sizes
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h1
-rw-r--r--source/blender/blenlib/BLI_noise.h2
-rw-r--r--source/blender/blenlib/intern/math_geom.c18
-rw-r--r--source/blender/blenlib/intern/noise.c2
4 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 29ebf9f4688..7dcee518287 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -57,6 +57,7 @@ float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3]
float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]);
float area_poly_v3(const float verts[][3], unsigned int nr, const float normal[3]);
float area_poly_v2(const float verts[][2], unsigned int nr);
+float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3]);
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2]);
float cross_poly_v2(const float verts[][2], unsigned int nr);
diff --git a/source/blender/blenlib/BLI_noise.h b/source/blender/blenlib/BLI_noise.h
index d9457fbaae7..f3292d26b1e 100644
--- a/source/blender/blenlib/BLI_noise.h
+++ b/source/blender/blenlib/BLI_noise.h
@@ -57,7 +57,7 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype);
/* newnoise: cellNoise & cellNoiseV (for vector/point/color) */
float cellNoise(float x, float y, float z);
-void cellNoiseV(float x, float y, float z, float *ca);
+void cellNoiseV(float x, float y, float z, float r_ca[3]);
#ifdef __cplusplus
}
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 7665b8eedd0..71a6e195631 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -179,6 +179,24 @@ float area_poly_v2(const float verts[][2], unsigned int nr)
return fabsf(0.5f * cross_poly_v2(verts, nr));
}
+float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3])
+{
+ float a[3], b[3], c[3], c_len;
+
+ sub_v3_v3v3(a, v2, v1);
+ sub_v3_v3v3(b, v3, v1);
+ cross_v3_v3v3(c, a, b);
+
+ c_len = len_v3(c);
+
+ if (c_len > FLT_EPSILON) {
+ return dot_v3v3(a, b) / c_len;
+ }
+ else {
+ return 0.0f;
+ }
+}
+
/********************************* Planes **********************************/
/**
diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 982a74b1ffd..f002ea54b32 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -1407,7 +1407,7 @@ float cellNoise(float x, float y, float z)
}
/* returns a vector/point/color in ca, using point hasharray directly */
-void cellNoiseV(float x, float y, float z, float *ca)
+void cellNoiseV(float x, float y, float z, float ca[3])
{
int xi = (int)(floor(x));
int yi = (int)(floor(y));