Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-08-15 16:31:54 +0300
committermano-wii <germano.costa@ig.com.br>2019-08-15 16:31:54 +0300
commit4d320f43133b02a43212b017eecdb390476189f2 (patch)
tree33ce479a4f9185724dcce31f4b70b335161c2b32 /source/blender/editors/mesh
parent261a02fc596db0e91667d4e3af9204b165ec4006 (diff)
Edit Mesh Selection: Refactor: Redraw idmap buffer at runtime with only objects inside the rect
But in the future the selection code may also be used in object mode (eg for snapping). So to avoid using too much VRAM resources, it is good to avoid drawing all objects in the viewport. The solution was to create an array with only objects that are detected within the selection area. If the selection operator is modal, objects already detected are not removed from the array until view3d is moved or orbited. To detect the object, its BoundBox is tested. Since the Select Engine does not have a dedicated depth texture, whenever a new object is "found" the depth of the objects in the array already drawn is redrawn. Reviewers: campbellbarton, fclem Reviewed By: fclem Differential Revision: https://developer.blender.org/D5435
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/editmesh_select.c14
-rw-r--r--source/blender/editors/mesh/meshtools.c10
2 files changed, 14 insertions, 10 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 2f4688e2de7..94ffd9a34d6 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -317,9 +317,10 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc,
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
{
- DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, SCE_SELECT_VERTEX);
+ DRW_select_buffer_context_create(bases, bases_len, SCE_SELECT_VERTEX);
- index = DRW_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px);
+ index = DRW_select_buffer_find_nearest_to_point(
+ vc->depsgraph, vc->ar, vc->v3d, vc->mval, 1, UINT_MAX, &dist_px);
if (index) {
eve = (BMVert *)edbm_select_id_bm_elem_get(bases, index, &base_index);
@@ -539,9 +540,10 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc,
/* No afterqueue (yet), so we check it now, otherwise the bm_xxxofs indices are bad. */
{
- DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, SCE_SELECT_EDGE);
+ DRW_select_buffer_context_create(bases, bases_len, SCE_SELECT_EDGE);
- index = DRW_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px);
+ index = DRW_select_buffer_find_nearest_to_point(
+ vc->depsgraph, vc->ar, vc->v3d, vc->mval, 1, UINT_MAX, &dist_px);
if (index) {
eed = (BMEdge *)edbm_select_id_bm_elem_get(bases, index, &base_index);
@@ -745,9 +747,9 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc,
BMFace *efa;
{
- DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, SCE_SELECT_FACE);
+ DRW_select_buffer_context_create(bases, bases_len, SCE_SELECT_FACE);
- index = DRW_select_buffer_sample_point(vc->mval);
+ index = DRW_select_buffer_sample_point(vc->depsgraph, vc->ar, vc->v3d, vc->mval);
if (index) {
efa = (BMFace *)edbm_select_id_bm_elem_get(bases, index, &base_index);
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 0bdc59c7185..8d9d0e40f44 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -1116,11 +1116,12 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px,
if (dist_px) {
/* sample rect to increase chances of selecting, so that when clicking
* on an edge in the backbuf, we can still select a face */
- *r_index = DRW_select_buffer_find_nearest_to_point(mval, 1, me->totpoly + 1, &dist_px);
+ *r_index = DRW_select_buffer_find_nearest_to_point(
+ vc.depsgraph, vc.ar, vc.v3d, mval, 1, me->totpoly + 1, &dist_px);
}
else {
/* sample only on the exact position */
- *r_index = DRW_select_buffer_sample_point(mval);
+ *r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.ar, vc.v3d, mval);
}
if ((*r_index) == 0 || (*r_index) > (unsigned int)me->totpoly) {
@@ -1297,11 +1298,12 @@ bool ED_mesh_pick_vert(
if (dist_px > 0) {
/* sample rect to increase chances of selecting, so that when clicking
* on an face in the backbuf, we can still select a vert */
- *r_index = DRW_select_buffer_find_nearest_to_point(mval, 1, me->totvert + 1, &dist_px);
+ *r_index = DRW_select_buffer_find_nearest_to_point(
+ vc.depsgraph, vc.ar, vc.v3d, mval, 1, me->totvert + 1, &dist_px);
}
else {
/* sample only on the exact position */
- *r_index = DRW_select_buffer_sample_point(mval);
+ *r_index = DRW_select_buffer_sample_point(vc.depsgraph, vc.ar, vc.v3d, mval);
}
if ((*r_index) == 0 || (*r_index) > (uint)me->totvert) {