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/draw/intern/draw_manager.c
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/draw/intern/draw_manager.c')
-rw-r--r--source/blender/draw/intern/draw_manager.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 070713ad404..1046e0422c1 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2555,20 +2555,11 @@ void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
DRW_opengl_context_disable();
}
-void DRW_draw_select_id(Depsgraph *depsgraph,
- ARegion *ar,
- View3D *v3d,
- Base **bases,
- const uint bases_len,
- short select_mode)
+void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, const rcti *rect)
{
Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
- DRW_select_buffer_context_create(bases, bases_len, select_mode);
-
- DRW_opengl_context_enable();
-
/* Reset before using it. */
drw_state_prepare_clean_for_draw(&DST);
DST.buffer_finish_called = true;
@@ -2584,7 +2575,6 @@ void DRW_draw_select_id(Depsgraph *depsgraph,
.depsgraph = depsgraph,
};
- use_drw_engine(&draw_engine_select_type);
drw_context_state_init();
/* Setup viewport */
@@ -2594,16 +2584,18 @@ void DRW_draw_select_id(Depsgraph *depsgraph,
/* Update ubos */
DRW_globals_update();
- /* Init engines */
- drw_engines_init();
+ /* Init Select Engine */
+ struct SELECTID_Context *sel_ctx = DRW_select_engine_context_get();
+ sel_ctx->last_rect = *rect;
+ use_drw_engine(&draw_engine_select_type);
+ drw_engines_init();
{
drw_engines_cache_init();
- /* Keep `base_index` in sync with `e_data.context.last_base_drawn`.
- * So don't skip objects. */
- for (uint base_index = 0; base_index < bases_len; base_index++) {
- Object *obj_eval = DEG_get_evaluated_object(depsgraph, bases[base_index]->object);
+ Object **obj = &sel_ctx->objects[0];
+ for (uint remaining = sel_ctx->objects_len; remaining--; obj++) {
+ Object *obj_eval = DEG_get_evaluated_object(depsgraph, *obj);
drw_engines_cache_populate(obj_eval);
}
@@ -2621,10 +2613,6 @@ void DRW_draw_select_id(Depsgraph *depsgraph,
/* Avoid accidental reuse. */
drw_state_ensure_not_reused(&DST);
#endif
-
- /* Changin context */
- GPU_framebuffer_restore();
- DRW_opengl_context_disable();
}
/** See #DRW_shgroup_world_clip_planes_from_rv3d. */