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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-05 17:26:38 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-01-05 17:26:38 +0300
commitd16547ab73e7086d5358bba67093173827d12afe (patch)
treecdcc994222129063aaf916f972f8ed3311675266 /source/blender/blenlib/intern/math_geom.c
parent01b762e8463ec6192d43b3bfac7d29b0c24757c0 (diff)
Alt+B view clipping is now taken into account properly for sculpt, particle
edit and snapping, by clipping the view ray.
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r--source/blender/blenlib/intern/math_geom.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 2b94227099c..a80f999cdbb 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1246,6 +1246,55 @@ int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3])
return 1;
}
+int clip_line_plane(float p1[3], float p2[3], float plane[4])
+{
+ float dp[3], n[3], div, t, pc[3];
+
+ copy_v3_v3(n, plane);
+ sub_v3_v3v3(dp, p2, p1);
+ div= dot_v3v3(dp, n);
+
+ if(div == 0.0f) /* parallel */
+ return 1;
+
+ t= -(dot_v3v3(p1, n) + plane[3])/div;
+
+ if(div > 0.0f) {
+ /* behind plane, completely clipped */
+ if(t >= 1.0f) {
+ zero_v3(p1);
+ zero_v3(p2);
+ return 0;
+ }
+
+ /* intersect plane */
+ if(t > 0.0f) {
+ madd_v3_v3v3fl(pc, p1, dp, t);
+ copy_v3_v3(p1, pc);
+ return 1;
+ }
+
+ return 1;
+ }
+ else {
+ /* behind plane, completely clipped */
+ if(t <= 0.0f) {
+ zero_v3(p1);
+ zero_v3(p2);
+ return 0;
+ }
+
+ /* intersect plane */
+ if(t < 1.0f) {
+ madd_v3_v3v3fl(pc, p1, dp, t);
+ copy_v3_v3(p2, pc);
+ return 1;
+ }
+
+ return 1;
+ }
+}
+
/****************************** Interpolation ********************************/
static float tri_signed_area(float *v1, float *v2, float *v3, int i, int j)