diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-06 16:07:30 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-06 16:07:30 +0300 |
commit | e8292466bcb69282798bba5dd701fff514cb0b78 (patch) | |
tree | adfb00123c003b8d984a20b14f1e32c6af8086db /source/blender/draw/intern | |
parent | 3e6ebdd2a6b5b7563e9c45dae3c65ebf7d629544 (diff) |
DRW: Support edit-metaball clipping
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 19 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 01e3264c54e..73371d5bf94 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -696,13 +696,18 @@ DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, bool transp return grp; } -DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass) +DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass, eGPUShaderConfig shader_cfg) { - COMMON_Shaders *sh_data = &g_shaders[GPU_SHADER_CFG_DEFAULT]; + COMMON_Shaders *sh_data = &g_shaders[shader_cfg]; if (sh_data->mball_handles == NULL) { - sh_data->mball_handles = DRW_shader_create( - datatoc_object_mball_handles_vert_glsl, NULL, - datatoc_gpu_shader_flat_color_frag_glsl, NULL); + bool is_clip = (shader_cfg == GPU_SHADER_CFG_CLIPPED); + 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" : ""; + sh_data->mball_handles = GPU_shader_create_from_arrays({ + .vert = (const char *[]){world_clip_lib_or_empty, datatoc_object_mball_handles_vert_glsl, NULL}, + .frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL}, + .defs = (const char *[]){world_clip_def_or_empty, NULL}, + }); } DRW_shgroup_instance_format(g_formats.instance_mball_handles, { @@ -716,7 +721,9 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass) DRW_cache_screenspace_circle_get(), g_formats.instance_mball_handles); DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2); - + if (shader_cfg == GPU_SHADER_CFG_CLIPPED) { + DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); + } return grp; } diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index 3a5237d8af8..af240809ded 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -140,7 +140,7 @@ struct DRWShadingGroup *shgroup_instance_outline(struct DRWPass *pass, struct GP struct DRWShadingGroup *shgroup_camera_instance(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig shader_cfg); struct DRWShadingGroup *shgroup_distance_lines_instance(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig shader_cfg); struct DRWShadingGroup *shgroup_spot_instance(struct DRWPass *pass, struct GPUBatch *geom, eGPUShaderConfig shader_cfg); -struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass); +struct DRWShadingGroup *shgroup_instance_mball_handles(struct DRWPass *pass, eGPUShaderConfig shader_cfg); struct DRWShadingGroup *shgroup_instance_bone_axes(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_distance(struct DRWPass *pass); struct DRWShadingGroup *shgroup_instance_bone_envelope_outline(struct DRWPass *pass); |