forked from bartvdbraak/blender
Fix #33279: crash in particle brush cut tool when cutting hairs that go outside the view.
This commit is contained in:
parent
f5bf63dc96
commit
7cc12e5170
@ -401,6 +401,7 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
|
|||||||
static int key_test_depth(PEData *data, const float co[3], const int screen_co[2])
|
static int key_test_depth(PEData *data, const float co[3], const int screen_co[2])
|
||||||
{
|
{
|
||||||
View3D *v3d= data->vc.v3d;
|
View3D *v3d= data->vc.v3d;
|
||||||
|
ViewDepths *vd = data->vc.rv3d->depths;
|
||||||
double ux, uy, uz;
|
double ux, uy, uz;
|
||||||
float depth;
|
float depth;
|
||||||
|
|
||||||
@ -428,12 +429,15 @@ static int key_test_depth(PEData *data, const float co[3], const int screen_co[2
|
|||||||
/* view3d_validate_backbuf(&data->vc); */
|
/* view3d_validate_backbuf(&data->vc); */
|
||||||
glReadPixels(screen_co[0], screen_co[1], 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
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 */
|
#else /* faster to use depths, these are calculated in PE_set_view3d_data */
|
||||||
{
|
|
||||||
ViewDepths *vd = data->vc.rv3d->depths;
|
/* check if screen_co is within bounds because brush_cut uses out of screen coords */
|
||||||
assert(vd && vd->depths);
|
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 */
|
/* we know its not clipped */
|
||||||
depth = vd->depths[screen_co[1] * vd->w + screen_co[0]];
|
depth = vd->depths[screen_co[1] * vd->w + screen_co[0]];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((float)uz - 0.00001f > depth)
|
if ((float)uz - 0.00001f > depth)
|
||||||
|
Loading…
Reference in New Issue
Block a user