Cleanup: move clipping shader lib & define into struct
[blender.git] / source / blender / draw / modes / edit_lattice_mode.c
index 97471ef39e11b70d748024a416ec370266ea28c7..7ac24ac8e77fa0a0505ecd50c292998867ceded0 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "draw_common.h"
 
-extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[];
 extern char datatoc_common_globals_lib_glsl[];
 
 extern char datatoc_edit_lattice_overlay_loosevert_vert_glsl[];
@@ -137,12 +136,10 @@ static void EDIT_LATTICE_engine_init(void *vedata)
 
        const DRWContextState *draw_ctx = DRW_context_state_get();
        EDIT_LATTICE_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
-       const bool is_clip = (draw_ctx->rv3d->rflag & RV3D_CLIPPING) != 0;
-       if (is_clip) {
+       if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
                DRW_state_clip_planes_set_from_rv3d(draw_ctx->rv3d);
        }
-       const char *world_clip_lib_or_empty = is_clip ? datatoc_gpu_shader_cfg_world_clip_lib_glsl : "";
-       const char *world_clip_def_or_empty = is_clip ? "#define USE_WORLD_CLIP_PLANES\n" : "";
+       const GPUShaderConfigData *sh_cfg_data = &GPU_shader_cfg_data[draw_ctx->sh_cfg];
 
        if (!sh_data->wire) {
                sh_data->wire = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_SMOOTH_COLOR, draw_ctx->sh_cfg);
@@ -151,7 +148,7 @@ static void EDIT_LATTICE_engine_init(void *vedata)
        if (!sh_data->overlay_vert) {
                sh_data->overlay_vert = GPU_shader_create_from_arrays({
                        .vert = (const char *[]){
-                           world_clip_lib_or_empty,
+                           sh_cfg_data->lib,
                            datatoc_common_globals_lib_glsl,
                            datatoc_edit_lattice_overlay_loosevert_vert_glsl,
                            NULL},
@@ -159,7 +156,7 @@ static void EDIT_LATTICE_engine_init(void *vedata)
                            datatoc_common_globals_lib_glsl,
                            datatoc_edit_lattice_overlay_frag_glsl,
                            NULL},
-                       .defs = (const char *[]){world_clip_def_or_empty, NULL},
+                       .defs = (const char *[]){sh_cfg_data->def, NULL},
                });
 
        }