diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-07-08 19:58:00 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-07-08 19:58:00 +0400 |
commit | a6bb0f93ad471a993e2d82b3b50030d1381bdcf9 (patch) | |
tree | 2dc5f5f9ee0b0ebc85c2d48f2fce6708612fceff | |
parent | a5906de7c4f1bd188030ee4b8d9822c7c31fc2ea (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.c | 13 |
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]; |