Revision: 52521
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52521
Author:   blendix
Date:     2012-11-23 21:22:13 +0000 (Fri, 23 Nov 2012)
Log Message:
-----------
Fix #33279: crash in particle brush cut tool when cutting hairs that go outside 
the view.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/physics/particle_edit.c

Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c        
2012-11-23 19:10:56 UTC (rev 52520)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c        
2012-11-23 21:22:13 UTC (rev 52521)
@@ -401,6 +401,7 @@
 static int key_test_depth(PEData *data, const float co[3], const int 
screen_co[2])
 {
        View3D *v3d= data->vc.v3d;
+       ViewDepths *vd = data->vc.rv3d->depths;
        double ux, uy, uz;
        float depth;
 
@@ -428,12 +429,15 @@
        /* view3d_validate_backbuf(&data->vc); */
        glReadPixels(screen_co[0], screen_co[1], 1, 1, GL_DEPTH_COMPONENT, 
GL_FLOAT, &depth);
 #else /* faster to use depths, these are calculated in PE_set_view3d_data */
-       {
-               ViewDepths *vd = data->vc.rv3d->depths;
-               assert(vd && vd->depths);
+
+       /* check if screen_co is within bounds because brush_cut uses out of 
screen coords */
+       if(screen_co[0] >= 0 && screen_co[0] < vd->w && screen_co[1] >= 0 && 
screen_co[1] < vd->h) {
+               BLI_assert(vd && vd->depths);
                /* we know its not clipped */
                depth = vd->depths[screen_co[1] * vd->w + screen_co[0]];
        }
+       else
+               return 0;
 #endif
 
        if ((float)uz - 0.00001f > depth)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to