diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-12-11 19:59:09 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-12-11 19:59:09 +0300 |
commit | cb4d9a7427e28f360dc168fab225e24c343dc10e (patch) | |
tree | f41ecc32910e23f6caf64d65d97772f16d45dc7e /source/blender/blenlib/intern/math_geom.c | |
parent | 026364dcca6539c4e3ad6a5010cba81e61638ef2 (diff) |
Sculpt:
* Temporary workaround for sculpt not working well with small polygons,
still seems to be some issues, but can at least paint now.
* Small optimization avoiding local function variable aliasing.
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index efa5876e1b0..75c32c5b45b 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -458,6 +458,39 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2 return 1; } +int isect_ray_tri_epsilon_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float epsilon) +{ + float p[3], s[3], e1[3], e2[3], q[3]; + float a, f, u, v; + + sub_v3_v3v3(e1, v1, v0); + sub_v3_v3v3(e2, v2, v0); + + cross_v3_v3v3(p, d, e2); + a = dot_v3v3(e1, p); + if (a == 0.0f) return 0; + f = 1.0f/a; + + sub_v3_v3v3(s, p1, v0); + + cross_v3_v3v3(q, s, e1); + *lambda = f * dot_v3v3(e2, q); + if ((*lambda < 0.0)) return 0; + + u = f * dot_v3v3(s, p); + if ((u < -epsilon)||(u > 1.0+epsilon)) return 0; + + v = f * dot_v3v3(d, q); + if ((v < -epsilon)||((u + v) > 1.0+epsilon)) return 0; + + if(uv) { + uv[0]= u; + uv[1]= v; + } + + return 1; +} + int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold) { float p[3], s[3], e1[3], e2[3], q[3]; |