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
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')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h2
-rw-r--r--source/blender/blenlib/intern/math_geom.c49
-rw-r--r--source/blender/blenlib/intern/pbvh.c5
3 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 0bbe8fac976..f650a55d8ad 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -111,6 +111,8 @@ int isect_axial_line_tri_v3(int axis, float co1[3], float co2[3],
int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3]);
+int clip_line_plane(float clipco[3], float plane[4], float co[3]);
+
/****************************** Interpolation ********************************/
/* tri or quad, d can be NULL */
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)
diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c
index 6f33fab2571..c1bdbf32fac 100644
--- a/source/blender/blenlib/intern/pbvh.c
+++ b/source/blender/blenlib/intern/pbvh.c
@@ -694,6 +694,11 @@ void BLI_pbvh_search_gather(PBVH *bvh,
pbvh_iter_end(&iter);
+ if(tot == 0 && array) {
+ MEM_freeN(array);
+ array= NULL;
+ }
+
*r_array= array;
*r_tot= tot;
}