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:
authorClément Foucault <foucault.clem@gmail.com>2019-06-17 21:28:27 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-06-17 21:32:02 +0300
commit28b06b6a05f7e0efb307aa3f4d2d609c9162358c (patch)
treef6872d726eb310b094283fe7b2ff6a7e72109621 /source/blender/editors/uvedit
parentbe52b25d3953696a775be9d2dae32cf713369e7c (diff)
Fix T57650 UVEdit: selection not visible if behind unselected UVs
Use depth buffer to order the uv edges correctly to always draw selected edges on top. We still use the double drawing workaround for points to keep the smooth antialiased display.
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c65
1 files changed, 27 insertions, 38 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 93cef1861d9..fa2a7eb9812 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -52,6 +52,7 @@
#include "DEG_depsgraph_query.h"
#include "GPU_batch.h"
+#include "GPU_framebuffer.h"
#include "GPU_immediate.h"
#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
@@ -300,8 +301,6 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
uvedit_get_batches(eval_ob, sima, ts, &faces, &edges, &verts, &facedots);
bool interpedges;
- bool do_elem_order_fix = (ts->uv_flag & UV_SYNC_SELECTION) && (ts->selectmode & SCE_SELECT_FACE);
- bool do_selected_edges = ((sima->flag & SI_NO_DRAWEDGES) == 0);
bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
if (ts->uv_flag & UV_SYNC_SELECTION) {
interpedges = (ts->selectmode & SCE_SELECT_VERTEX) != 0;
@@ -378,37 +377,28 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
break;
}
case SI_UVDT_OUTLINE: {
- GPU_line_width(3.0f);
- GPU_batch_program_set_builtin(edges, GPU_SHADER_2D_UNIFORM_COLOR);
- GPU_batch_uniform_4f(edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
- GPU_batch_draw(edges);
-
- UI_GetThemeColor4fv(TH_WIRE_EDIT, col1);
- UI_GetThemeColor4fv(TH_EDGE_SELECT, col2);
-
/* We could modify the vbo's data filling
* instead of modifying the provoking vert. */
glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
- GPU_line_width(1.0f);
+ UI_GetThemeColor4fv(TH_WIRE_EDIT, col1);
+ UI_GetThemeColor4fv(TH_EDGE_SELECT, col2);
+
GPU_batch_program_set_builtin(
edges, (interpedges) ? GPU_SHADER_2D_UV_EDGES_SMOOTH : GPU_SHADER_2D_UV_EDGES);
+ /* Black Outline. */
+ GPU_line_width(3.0f);
+ GPU_batch_uniform_4f(edges, "edgeColor", 0.0f, 0.0f, 0.0f, 1.0f);
+ GPU_batch_uniform_4f(edges, "selectColor", 0.0f, 0.0f, 0.0f, 1.0f);
+ GPU_batch_draw(edges);
+ /* Inner Line. Use depth test to insure selection is drawn on top. */
+ GPU_depth_test(true);
+ GPU_line_width(1.0f);
GPU_batch_uniform_4fv(edges, "edgeColor", col1);
- GPU_batch_uniform_4fv(edges, "selectColor", do_selected_edges ? col2 : col1);
+ GPU_batch_uniform_4fv(edges, "selectColor", col2);
GPU_batch_draw(edges);
+ GPU_depth_test(false);
- if (do_elem_order_fix && do_selected_edges) {
- /* We have problem in this mode when face order make some edges
- * appear unselected because an adjacent face is not selected and
- * render after the selected face.
- * So, to avoid sorting edges by state we just render selected edges
- * on top. A bit overkill but it's simple. */
- GPU_blend(true);
- GPU_batch_uniform_4fv(edges, "edgeColor", transparent);
- GPU_batch_uniform_4fv(edges, "selectColor", col2);
- GPU_batch_draw(edges);
- GPU_blend(false);
- }
glProvokingVertex(GL_LAST_VERTEX_CONVENTION);
break;
}
@@ -429,25 +419,20 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
GPU_batch_program_set_builtin(verts, GPU_SHADER_2D_UV_VERTS);
GPU_batch_uniform_4f(verts, "vertColor", col1[0], col1[1], col1[2], 1.0f);
- GPU_batch_uniform_4fv(verts, "selectColor", (do_elem_order_fix) ? transparent : col2);
+ GPU_batch_uniform_4fv(verts, "selectColor", transparent);
GPU_batch_uniform_4fv(verts, "pinnedColor", pinned_col);
GPU_batch_uniform_1f(verts, "pointSize", (pointsize + 1.5f) * M_SQRT2);
GPU_batch_uniform_1f(verts, "outlineWidth", 0.75f);
GPU_batch_draw(verts);
- if (do_elem_order_fix) {
- /* We have problem in this mode when face order make some verts
- * appear unselected because an adjacent face is not selected and
- * render after the selected face.
- * So, to avoid sorting verts by state we just render selected verts
- * on top. A bit overkill but it's simple. */
- GPU_batch_uniform_4fv(verts, "vertColor", transparent);
- GPU_batch_uniform_4fv(verts, "selectColor", col2);
- GPU_batch_uniform_4fv(verts, "pinnedColor", pinned_col);
- GPU_batch_uniform_1f(verts, "pointSize", (pointsize + 1.5f) * M_SQRT2);
- GPU_batch_uniform_1f(verts, "outlineWidth", 0.75f);
- GPU_batch_draw(verts);
- }
+ /* We have problem in this mode when face order make some verts
+ * appear unselected because an adjacent face is not selected and
+ * render after the selected face.
+ * So, to avoid sorting verts by state we just render selected verts
+ * on top. A bit overkill but it's simple. */
+ GPU_batch_uniform_4fv(verts, "vertColor", transparent);
+ GPU_batch_uniform_4fv(verts, "selectColor", col2);
+ GPU_batch_draw(verts);
GPU_blend(false);
GPU_program_point_size(false);
@@ -502,6 +487,10 @@ void ED_uvedit_draw_main(SpaceImage *sima,
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
view_layer, ((View3D *)NULL), &objects_len);
+ if (objects_len > 0) {
+ GPU_clear_depth(1.0f);
+ GPU_clear(GPU_DEPTH_BIT);
+ }
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob_iter = objects[ob_index];
draw_uvs(sima, scene, ob_iter, depsgraph);