diff options
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 8 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 32 |
2 files changed, 35 insertions, 5 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 835f0808d44..f6585550842 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2409,24 +2409,22 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, DRW_hair_update(); - DRW_state_lock(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_DEPTH_LESS_EQUAL | - DRW_STATE_DEPTH_EQUAL | DRW_STATE_DEPTH_GREATER | DRW_STATE_DEPTH_ALWAYS); - /* Only 1-2 passes. */ while (true) { if (!select_pass_fn(DRW_SELECT_PASS_PRE, select_pass_user_data)) { break; } + DRW_state_lock(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_TEST_ENABLED); drw_engines_draw_scene(); + DRW_state_lock(0); + if (!select_pass_fn(DRW_SELECT_PASS_POST, select_pass_user_data)) { break; } } - DRW_state_lock(0); - DRW_state_reset(); drw_engines_disable(); diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 84f618c1c15..444ecbc1e54 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -294,6 +294,38 @@ static void drw_state_validate(void) void DRW_state_lock(DRWState state) { DST.state_lock = state; + + /* We must get the current state to avoid overriding it. */ + /* Not complete, but that just what we need for now. */ + if (state & DRW_STATE_WRITE_DEPTH) { + SET_FLAG_FROM_TEST(DST.state, GPU_depth_mask_get(), DRW_STATE_WRITE_DEPTH); + } + if (state & DRW_STATE_DEPTH_TEST_ENABLED) { + DST.state &= ~DRW_STATE_DEPTH_TEST_ENABLED; + + switch (GPU_depth_test_get()) { + case GPU_DEPTH_ALWAYS: + DST.state |= DRW_STATE_DEPTH_ALWAYS; + break; + case GPU_DEPTH_LESS: + DST.state |= DRW_STATE_DEPTH_LESS; + break; + case GPU_DEPTH_LESS_EQUAL: + DST.state |= DRW_STATE_DEPTH_LESS_EQUAL; + break; + case GPU_DEPTH_EQUAL: + DST.state |= DRW_STATE_DEPTH_EQUAL; + break; + case GPU_DEPTH_GREATER: + DST.state |= DRW_STATE_DEPTH_GREATER; + break; + case GPU_DEPTH_GREATER_EQUAL: + DST.state |= DRW_STATE_DEPTH_GREATER_EQUAL; + break; + default: + break; + } + } } void DRW_state_reset(void) |