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:
authorCampbell Barton <ideasman42@gmail.com>2019-02-10 03:06:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-10 03:16:31 +0300
commit0b6dbbc306b0a7e60abe36968d154241bb90c1df (patch)
treed22a40e3e73f80bc1150cffe1fde866f1f602865 /source/blender/draw/modes/edit_curve_mode.c
parent16d7967c2b404cbe6719192e073c7685376f6ab1 (diff)
Cleanup: move clipping shader lib & define into struct
Also compare clipping with the draw context instead of accessing the RegionView3D, currently they're matching but this might not always be the case.
Diffstat (limited to 'source/blender/draw/modes/edit_curve_mode.c')
-rw-r--r--source/blender/draw/modes/edit_curve_mode.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c
index 0a2a8ede1d9..2289a583885 100644
--- a/source/blender/draw/modes/edit_curve_mode.c
+++ b/source/blender/draw/modes/edit_curve_mode.c
@@ -38,7 +38,6 @@
* Not needed for constant color. */
extern char datatoc_common_globals_lib_glsl[];
-extern char datatoc_gpu_shader_cfg_world_clip_lib_glsl[];
extern char datatoc_edit_curve_overlay_loosevert_vert_glsl[];
extern char datatoc_edit_curve_overlay_normals_vert_glsl[];
extern char datatoc_edit_curve_overlay_handle_vert_glsl[];
@@ -108,14 +107,12 @@ static void EDIT_CURVE_engine_init(void *UNUSED(vedata))
{
const DRWContextState *draw_ctx = DRW_context_state_get();
EDIT_CURVE_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) {
sh_data->wire_sh = GPU_shader_get_builtin_shader_with_config(
@@ -124,26 +121,26 @@ static void EDIT_CURVE_engine_init(void *UNUSED(vedata))
if (!sh_data->wire_normals_sh) {
sh_data->wire_normals_sh = GPU_shader_create_from_arrays({
- .vert = (const char *[]){world_clip_lib_or_empty, datatoc_edit_curve_overlay_normals_vert_glsl, NULL},
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_edit_curve_overlay_normals_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL},
- .defs = (const char *[]){world_clip_def_or_empty, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
});
}
if (!sh_data->overlay_edge_sh) {
sh_data->overlay_edge_sh = GPU_shader_create_from_arrays({
- .vert = (const char *[]){world_clip_lib_or_empty, datatoc_edit_curve_overlay_handle_vert_glsl, NULL},
- .geom = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_edit_curve_overlay_handle_geom_glsl, NULL},
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_edit_curve_overlay_handle_vert_glsl, NULL},
+ .geom = (const char *[]){sh_cfg_data->lib, datatoc_common_globals_lib_glsl, datatoc_edit_curve_overlay_handle_geom_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL},
- .defs = (const char *[]){world_clip_def_or_empty, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
});
}
if (!sh_data->overlay_vert_sh) {
sh_data->overlay_vert_sh = GPU_shader_create_from_arrays({
- .vert = (const char *[]){world_clip_lib_or_empty, datatoc_common_globals_lib_glsl, datatoc_edit_curve_overlay_loosevert_vert_glsl, NULL},
+ .vert = (const char *[]){sh_cfg_data->lib, datatoc_common_globals_lib_glsl, datatoc_edit_curve_overlay_loosevert_vert_glsl, NULL},
.frag = (const char *[]){datatoc_gpu_shader_point_varying_color_frag_glsl, NULL},
- .defs = (const char *[]){world_clip_def_or_empty, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, NULL},
});
}