diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-11-26 15:57:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-11-26 15:57:35 +0300 |
commit | a44acdf348693ed5b6d64c1a84969578a513c0f6 (patch) | |
tree | 8b439c6a5b143270b6aee300b117781f5fab1f94 /source/blender/editors | |
parent | c2cd9ab039e57dce489b13e4653f461369bd65c6 (diff) |
bugfix [#23118] Blender freezes when combing hair - OS X path changes related?
- glReadPixels() was running to get the depth on each pixel, this works fine one some cards but was locking up on OSX.
- Replace glReadPixels() call with a single call to view3d_update_depths() right after view3d_validate_backbuf(), so the depths are only read once.
- Unrelated to the changes above, but should improve performance: view3d_validate_backbuf() was being called on every redraw while combing, now only call once when combing starts.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 52 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 1 |
3 files changed, 29 insertions, 25 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 2b5dc3b14ff..870fd452b22 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -79,6 +79,7 @@ void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my); void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ +void view3d_update_depths(struct ARegion *ar); float read_cached_depth(struct ViewContext *vc, int x, int y); void request_depth_update(struct RegionView3D *rv3d); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 9f736404d52..f27387a9e65 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include <math.h> #include <string.h> +#include <assert.h> #include "MEM_guardedalloc.h" @@ -369,8 +370,16 @@ static void PE_set_view3d_data(bContext *C, PEData *data) /* note, the object argument means the modelview matrix does not account for the objects matrix, use viewmat rather then (obmat * viewmat) */ view3d_get_transformation(data->vc.ar, data->vc.rv3d, NULL, &data->mats); - if((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) - view3d_validate_backbuf(&data->vc); + if((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) { + if(data->vc.v3d->flag & V3D_INVALID_BACKBUF) { + view3d_validate_backbuf(&data->vc); + + /* we may need to force an update here by setting the rv3d as dirty + * for now it seems ok, but take care!: + * rv3d->depths->dirty = 1; */ + view3d_update_depths(data->vc.ar); + } + } } /*************************** selection utilities *******************************/ @@ -397,14 +406,23 @@ static int key_test_depth(PEData *data, float co[3]) x=wco[0]; y=wco[1]; +#if 0 /* works well but too slow on some systems [#23118] */ x+= (short)data->vc.ar->winrct.xmin; y+= (short)data->vc.ar->winrct.ymin; /* PE_set_view3d_data calls this. no need to call here */ /* view3d_validate_backbuf(&data->vc); */ glReadPixels(x, y, 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); + /* we know its not clipped */ + depth= vd->depths[y * vd->w + x]; + } +#endif - if((float)uz - 0.0001 > depth) + if((float)uz - 0.00001 > depth) return 0; else return 1; @@ -3321,6 +3339,9 @@ typedef struct BrushEdit { int first; int lastmouse[2]; + + /* optional cached view settings to avoid setting on every mousemove */ + PEData data; } BrushEdit; static int brush_edit_init(bContext *C, wmOperator *op) @@ -3345,6 +3366,9 @@ static int brush_edit_init(bContext *C, wmOperator *op) bedit->ob= ob; bedit->edit= edit; + /* cache view depths and settings for re-use */ + PE_set_view3d_data(C, &bedit->data); + return 1; } @@ -3392,6 +3416,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) if(((pset->brushtype == PE_BRUSH_ADD) ? (sqrt(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first) { + PEData data= bedit->data; view3d_operator_needs_opengl(C); selected= (short)count_selected_keys(scene, edit); @@ -3399,9 +3424,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) switch(pset->brushtype) { case PE_BRUSH_COMB: { - PEData data; - - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; @@ -3421,10 +3443,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_CUT: { - PEData data; - if(edit->psys && edit->pathcache) { - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; data.cutfac= brush->strength; @@ -3445,9 +3464,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_LENGTH: { - PEData data; - - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; @@ -3466,10 +3482,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_PUFF: { - PEData data; - if(edit->psys) { - PE_set_view3d_data(C, &data); data.dm= psmd->dm; data.mval= mval; data.rad= (float)brush->size; @@ -3490,10 +3503,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_ADD: { - PEData data; - if(edit->psys && edit->psys->part->from==PART_FROM_FACE) { - PE_set_view3d_data(C, &data); data.mval= mval; added= brush_add(&data, brush->count); @@ -3507,9 +3517,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_SMOOTH: { - PEData data; - - PE_set_view3d_data(C, &data); data.mval= mval; data.rad= (float)brush->size; @@ -3531,9 +3538,6 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_WEIGHT: { - PEData data; - PE_set_view3d_data(C, &data); - if(edit->psys) { data.dm= psmd->dm; data.mval= mval; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index b77c68b2735..445a83b4266 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -136,7 +136,6 @@ void add_view3d_after(ListBase *lb, Base *base, int flag); void circf(float x, float y, float rad); void circ(float x, float y, float rad); -void view3d_update_depths(struct ARegion *ar); void view3d_update_depths_rect(struct ARegion *ar, struct ViewDepths *d, struct rcti *rect); float view3d_depth_near(struct ViewDepths *d); |