diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_noise.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 18 | ||||
-rw-r--r-- | source/blender/blenlib/intern/noise.c | 2 |
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)); |