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-06 02:33:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-06 02:34:09 +0300
commit8996e26116f063ce28a9784899fc36d87f31dabe (patch)
tree5085a8fdfec51ef1c807142859393d963efe10d3 /source/blender/gpu
parentdbd7f36da8ec3ac1c2898aee346beecb86aac8a2 (diff)
Fix T61196: Mesh select ignores clipping
Select clipping now works when x-ray is disabled.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_batch.h6
-rw-r--r--source/blender/gpu/intern/gpu_batch.c15
-rw-r--r--source/blender/gpu/intern/gpu_shader.c4
-rw-r--r--source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl8
4 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 4311b73d1ef..9637ef74b8c 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -122,7 +122,11 @@ int GPU_batch_vertbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo);
void GPU_batch_program_set_no_use(GPUBatch *, uint32_t program, const GPUShaderInterface *);
void GPU_batch_program_set(GPUBatch *, uint32_t program, const GPUShaderInterface *);
-void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id);
+void GPU_batch_program_set_shader(GPUBatch *, GPUShader *shader);
+void GPU_batch_program_set_builtin(
+ GPUBatch *batch, eGPUBuiltinShader shader_id);
+void GPU_batch_program_set_builtin_with_config(
+ GPUBatch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig shader_cfg);
/* Entire batch draws with one shader program, but can be redrawn later with another program. */
/* Vertex shader's inputs must be compatible with the batch's vertex format. */
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 66b17fa9704..a095f85d883 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -664,12 +664,23 @@ void GPU_draw_primitive(GPUPrimType prim_type, int v_count)
/** \name Utilities
* \{ */
-void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
+void GPU_batch_program_set_shader(GPUBatch *batch, GPUShader *shader)
+{
+ GPU_batch_program_set(batch, shader->program, shader->interface);
+}
+
+void GPU_batch_program_set_builtin_with_config(
+ GPUBatch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig shader_cfg)
{
- GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
+ GPUShader *shader = GPU_shader_get_builtin_shader_with_config(shader_id, shader_cfg);
GPU_batch_program_set(batch, shader->program, shader->interface);
}
+void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
+{
+ GPU_batch_program_set_builtin_with_config(batch, shader_id, GPU_SHADER_CFG_DEFAULT);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 99f4df29418..2236ea33842 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -1219,7 +1219,9 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(
GPU_SHADER_3D_GROUNDLINE,
GPU_SHADER_3D_GROUNDPOINT,
GPU_SHADER_DISTANCE_LINES,
- GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR));
+ GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR,
+ GPU_SHADER_3D_FLAT_SELECT_ID,
+ GPU_SHADER_3D_UNIFORM_SELECT_ID));
const char *world_clip_lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl;
const char *world_clip_def = "#define USE_WORLD_CLIP_PLANES\n";
/* In rare cases geometry shaders calculate clipping themselves. */
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
index 9c6be69efce..aa544ea82ee 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_selection_id_vert.glsl
@@ -20,5 +20,11 @@ void main()
(((color + offset) >> 24) ) * (1.0f / 255.0f));
#endif
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ vec4 pos_4d = vec4(pos, 1.0);
+ gl_Position = ModelViewProjectionMatrix * pos_4d;
+
+#ifdef USE_WORLD_CLIP_PLANES
+ /* Warning: ModelMatrix is typically used but select drawing is different. */
+ world_clip_planes_calc_clip_distance(pos);
+#endif
}