From 14d947dcadea7c9debe6c8a078a571eba6cb828c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Jan 2019 13:21:49 +1100 Subject: DRW: generalize selecting between regular/clipped shaders Each engine was doing this on its own. Move to DRWContextState, use an enum. --- source/blender/draw/modes/paint_weight_mode.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'source/blender/draw/modes/paint_weight_mode.c') diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 5d8b02d872d..7d4b3cac41b 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -86,7 +86,7 @@ typedef struct PAINT_WEIGHT_Shaders { /* *********** STATIC *********** */ static struct { - PAINT_WEIGHT_Shaders sh_data[2]; + PAINT_WEIGHT_Shaders sh_data[DRW_SHADER_SLOT_LEN]; int actdef; } e_data = {NULL}; /* Engine data */ @@ -100,18 +100,10 @@ typedef struct PAINT_WEIGHT_PrivateData { /* *********** FUNCTIONS *********** */ -static int PAINT_WEIGHT_sh_data_index_from_rv3d(const RegionView3D *rv3d) -{ - if (rv3d->rflag & RV3D_CLIPPING) { - return 1; - } - return 0; -} - static void PAINT_WEIGHT_engine_init(void *UNUSED(vedata)) { const DRWContextState *draw_ctx = DRW_context_state_get(); - PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[PAINT_WEIGHT_sh_data_index_from_rv3d(draw_ctx->rv3d)]; + PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0; if (is_clip) { @@ -151,7 +143,7 @@ static void PAINT_WEIGHT_cache_init(void *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); const View3D *v3d = draw_ctx->v3d; RegionView3D *rv3d = draw_ctx->rv3d; - PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[PAINT_WEIGHT_sh_data_index_from_rv3d(rv3d)]; + PAINT_WEIGHT_Shaders *sh_data = &e_data.sh_data[draw_ctx->shader_slot]; if (!stl->g_data) { /* Alloc transient pointers */ -- cgit v1.2.3