diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-10-30 05:58:19 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-10-30 05:58:19 +0400 |
commit | 2045c8607035f66758e53a50e31545965df89677 (patch) | |
tree | 92e314e77f9e55ba3a1f1a86d970ec4ae49c09a7 /source/blender/editors/sculpt_paint/paint_mask.c | |
parent | a8aa2c5bb4e87338bbfe45cc3a8ccff52aac0b43 (diff) |
One more optimization for lasso, clip PBVH against object space planes
of lasso enclosing rectangle.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_mask.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_mask.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index fa63ef2ca86..2e9efcc02b2 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -269,6 +269,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) int (*mcords)[2] = (int (*)[2])WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { + float clip_planes[4][4]; + BoundBox bb; bglMats mats = {{0}}; Object *ob; ViewContext vc; @@ -285,8 +287,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) float value = select ? 1.0 : 0.0; /* Calculations of individual vertices are done in 2D screen space to diminish the amount of - * calculations done. Bounding box PBVH collision is not computed because it is quite expensive and - * unnecessary */ + * calculations done. Bounding box PBVH collision is not computed against enclosing rectangle + * of lasso */ view3d_set_viewcontext(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); @@ -304,6 +306,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) (const int (*)[2])mcords, mcords_tot, mask_lasso_px_cb, &data); + ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect); + mul_m4_fl(clip_planes, -1.0f); mmd = sculpt_multires_active(vc.scene, ob); ED_sculpt_mask_layers_ensure(ob, mmd); @@ -311,8 +315,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; - /* gather all nodes! (doing bounding box intersection is more work than needed) */ - BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + /* gather nodes inside lasso's enclosing rectangle (should greatly help with bigger meshes) */ + BKE_pbvh_search_gather(pbvh, BKE_pbvh_node_planes_contain_AABB, clip_planes, &nodes, &totnode); sculpt_undo_push_begin("Mask lasso fill"); |