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>2011-07-08 19:58:00 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-07-08 19:58:00 +0400
commita6bb0f93ad471a993e2d82b3b50030d1381bdcf9 (patch)
tree2dc5f5f9ee0b0ebc85c2d48f2fce6708612fceff
parenta5906de7c4f1bd188030ee4b8d9822c7c31fc2ea (diff)
Fix #27897: mesh with negative scale disappears while sculpting, clipping
planes were wrong in that case.
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index aadb355f743..eeaf87757ce 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -468,8 +468,9 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, rcti *rect)
{
+ float modelview[4][4];
double xs, ys, p[3];
- short val;
+ int val, flip_sign, a;
/* near zero floating point values can give issues with gluUnProject
in side view on some implementations */
@@ -493,11 +494,21 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, rc
VECCOPY(bb->vec[4+val], p);
}
+ /* verify if we have negative scale. doing the transform before cross
+ product flips the sign of the vector compared to doing cross product
+ before transform then, so we correct for that. */
+ for(a=0; a<16; a++)
+ ((float*)modelview)[a] = mats->modelview[a];
+ flip_sign = is_negative_m4(modelview);
+
/* then plane equations */
for(val=0; val<4; val++) {
normal_tri_v3(planes[val], bb->vec[val], bb->vec[val==3?0:val+1], bb->vec[val+4]);
+ if(flip_sign)
+ negate_v3(planes[val]);
+
planes[val][3]= - planes[val][0]*bb->vec[val][0]
- planes[val][1]*bb->vec[val][1]
- planes[val][2]*bb->vec[val][2];