[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38236] trunk/blender/source/blender/ editors/space_view3d/view3d_view.c: Fix #27897: mesh with negative scale disappears while sculpting, clipping
Brecht Van Lommel
brechtvanlommel at pandora.be
Fri Jul 8 17:58:01 CEST 2011
Revision: 38236
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38236
Author: blendix
Date: 2011-07-08 15:58:00 +0000 (Fri, 08 Jul 2011)
Log Message:
-----------
Fix #27897: mesh with negative scale disappears while sculpting, clipping
planes were wrong in that case.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_view3d/view3d_view.c
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2011-07-08 13:22:58 UTC (rev 38235)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c 2011-07-08 15:58:00 UTC (rev 38236)
@@ -468,8 +468,9 @@
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 @@
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];
More information about the Bf-blender-cvs
mailing list