DRW: add ability to lock states from changing
Selection code relies on being able to set the depth functions however passes have their own depth settings. Add DRW_state_lock to ignore passes settings for particular flags. This fixes occlusion queries cycling through objects under the cursor.
This commit is contained in:
@@ -451,6 +451,7 @@ void DRW_draw_region_engine_info(void);
|
|||||||
|
|
||||||
void DRW_state_reset_ex(DRWState state);
|
void DRW_state_reset_ex(DRWState state);
|
||||||
void DRW_state_reset(void);
|
void DRW_state_reset(void);
|
||||||
|
void DRW_state_lock(DRWState state);
|
||||||
|
|
||||||
void DRW_state_invert_facing(void);
|
void DRW_state_invert_facing(void);
|
||||||
|
|
||||||
|
|||||||
@@ -1486,6 +1486,15 @@ void DRW_draw_select_loop(
|
|||||||
DRW_state_reset();
|
DRW_state_reset();
|
||||||
DRW_draw_callbacks_pre_scene();
|
DRW_draw_callbacks_pre_scene();
|
||||||
|
|
||||||
|
|
||||||
|
DRW_state_lock(
|
||||||
|
DRW_STATE_WRITE_DEPTH |
|
||||||
|
DRW_STATE_DEPTH_ALWAYS |
|
||||||
|
DRW_STATE_DEPTH_LESS |
|
||||||
|
DRW_STATE_DEPTH_EQUAL |
|
||||||
|
DRW_STATE_DEPTH_GREATER |
|
||||||
|
DRW_STATE_DEPTH_ALWAYS);
|
||||||
|
|
||||||
/* Only 1-2 passes. */
|
/* Only 1-2 passes. */
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!select_pass_fn(DRW_SELECT_PASS_PRE, select_pass_user_data)) {
|
if (!select_pass_fn(DRW_SELECT_PASS_PRE, select_pass_user_data)) {
|
||||||
@@ -1499,6 +1508,8 @@ void DRW_draw_select_loop(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DRW_state_lock(0);
|
||||||
|
|
||||||
DRW_draw_callbacks_post_scene();
|
DRW_draw_callbacks_post_scene();
|
||||||
|
|
||||||
DRW_state_reset();
|
DRW_state_reset();
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ typedef struct DRWManager {
|
|||||||
|
|
||||||
/* Managed by `DRW_state_set`, `DRW_state_reset` */
|
/* Managed by `DRW_state_set`, `DRW_state_reset` */
|
||||||
DRWState state;
|
DRWState state;
|
||||||
|
DRWState state_lock;
|
||||||
unsigned int stencil_mask;
|
unsigned int stencil_mask;
|
||||||
|
|
||||||
/* Per viewport */
|
/* Per viewport */
|
||||||
|
|||||||
@@ -61,15 +61,18 @@ void drw_state_set(DRWState state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CHANGED_TO(f) \
|
#define CHANGED_TO(f) \
|
||||||
((DST.state & (f)) ? \
|
((((DST.state & (f)) ? \
|
||||||
((state & (f)) ? 0 : -1) : \
|
((state & (f)) ? 0 : -1) : \
|
||||||
((state & (f)) ? 1 : 0))
|
((state & (f)) ? 1 : 0))) && \
|
||||||
|
((DST.state_lock & (f)) == 0))
|
||||||
|
|
||||||
#define CHANGED_ANY(f) \
|
#define CHANGED_ANY(f) \
|
||||||
((DST.state & (f)) != (state & (f)))
|
(((DST.state & (f)) != (state & (f))) && \
|
||||||
|
((DST.state_lock & (f)) == 0))
|
||||||
|
|
||||||
#define CHANGED_ANY_STORE_VAR(f, enabled) \
|
#define CHANGED_ANY_STORE_VAR(f, enabled) \
|
||||||
((DST.state & (f)) != (enabled = (state & (f))))
|
(((DST.state & (f)) != (enabled = (state & (f)))) && \
|
||||||
|
(((DST.state_lock & (f)) == 0)))
|
||||||
|
|
||||||
/* Depth Write */
|
/* Depth Write */
|
||||||
{
|
{
|
||||||
@@ -330,6 +333,17 @@ void DRW_state_reset_ex(DRWState state)
|
|||||||
drw_state_set(state);
|
drw_state_set(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use with care, intended so selection code can override passes depth settings,
|
||||||
|
* which is important for selection to work properly.
|
||||||
|
*
|
||||||
|
* Should be set in main draw loop, cleared afterwards
|
||||||
|
*/
|
||||||
|
void DRW_state_lock(DRWState state)
|
||||||
|
{
|
||||||
|
DST.state_lock = state;
|
||||||
|
}
|
||||||
|
|
||||||
void DRW_state_reset(void)
|
void DRW_state_reset(void)
|
||||||
{
|
{
|
||||||
/* Reset blending function */
|
/* Reset blending function */
|
||||||
|
|||||||
Reference in New Issue
Block a user