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:
authorJoseph Eagar <joeedh@gmail.com>2011-05-02 01:39:13 +0400
committerJoseph Eagar <joeedh@gmail.com>2011-05-02 01:39:13 +0400
commit088899236b0904c0a3d0fc5a92b0cb5ffd35cd17 (patch)
tree2d528fb9da3bba533e1ae42d7f2baa823d0d1f2e /source/blender/blenlib
parent7cc98cbb0b6f2ef113a568532eb0921e77cc973d (diff)
=trunk=
Recommitted eltopo collision code (but disabled by default) with Genscher's permission. To use, you need to install liblapack and libblas
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h5
-rw-r--r--source/blender/blenlib/intern/math_geom.c30
2 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 8937612b41b..756d1501536 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -91,6 +91,11 @@ int isect_line_line_v3(const float v1[3], const float v2[3],
int isect_line_line_strict_v3(const float v1[3], const float v2[3],
const float v3[3], const float v4[3], float vi[3], float *lambda);
+/*if clip is nonzero, will only return true if lambda is >= 0.0
+ (i.e. intersection point is along positive d)*/
+int isect_ray_plane_v3(float p1[3], float d[3], float v0[3],
+ float v1[3], float v2[3], float *lambda, int clip);
+
/* line/ray triangle */
int isect_line_tri_v3(const float p1[3], const float p2[3],
const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 4af56c66dde..afce5a602ed 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -486,7 +486,6 @@ int isect_line_tri_v3(const float p1[3], const float p2[3], const float v0[3], c
return 1;
}
-
/* moved from effect.c
test if the ray starting at p1 going in d direction intersects the triangle v0..v2
return non zero if it does
@@ -527,6 +526,35 @@ int isect_ray_tri_v3(const float p1[3], const float d[3], const float v0[3], con
return 1;
}
+int isect_ray_plane_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, int clip)
+{
+ 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);
+ /* note: these values were 0.000001 in 2.4x but for projection snapping on
+ * a human head (1BU==1m), subsurf level 2, this gave many errors - campbell */
+ if ((a > -0.00000001f) && (a < 0.00000001f)) return 0;
+ f = 1.0f/a;
+
+ sub_v3_v3v3(s, p1, v0);
+
+ u = f * dot_v3v3(s, p);
+
+ cross_v3_v3v3(q, s, e1);
+
+ v = f * dot_v3v3(d, q);
+
+ *lambda = f * dot_v3v3(e2, q);
+ if (clip && (*lambda < 0.0f)) return 0;
+
+ return 1;
+}
+
int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float epsilon)
{
float p[3], s[3], e1[3], e2[3], q[3];