Giving Overlay Edges a try
authorClément Foucault <foucault.clem@gmail.com>
Tue, 31 Jan 2017 23:28:16 +0000 (00:28 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 31 Jan 2017 23:28:16 +0000 (00:28 +0100)
source/blender/draw/engines/clay/clay.c
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache.h
source/blender/draw/intern/draw_mode_pass.c

index e187affaedf3e15ba37b563c562c76ed2efc164c..2be3418171d52a79f24b54bd4834c034a53b2f4a 100644 (file)
@@ -565,7 +565,7 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
                }
 
                struct Batch *geom;
-               bool do_outlines, do_wires;
+               bool do_outlines;
 
                switch (ob->type) {
                        case OB_MESH:
@@ -575,9 +575,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
                                DRW_shgroup_call_add(depthbatch, geom, ob->obmat);
                                DRW_shgroup_call_add(default_shgrp, geom, ob->obmat);
 
-                               do_outlines  = ((ob->base_flag & BASE_SELECTED) != 0);
+                               DRW_shgroup_wire_overlay(passes->wire_overlay_pass, ob);
 
-                               DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, do_wires, do_outlines);
+                               do_outlines  = ((ob->base_flag & BASE_SELECTED) != 0);
+                               DRW_shgroup_wire_outline(passes->wire_outline_pass, ob, false, false, do_outlines);
 
                                /* When encountering a new material :
                                 * - Create new Batch
@@ -649,6 +650,7 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *
 
        /* Pass 4 : Overlays */
        DRW_framebuffer_texture_attach(buffers->default_fb, textures->depth, 0);
+       DRW_draw_pass(passes->wire_overlay_pass);
        DRW_draw_pass(passes->wire_outline_pass);
        DRW_draw_pass(passes->non_meshes_pass);
        DRW_draw_pass(passes->ob_center_pass);
index a5a465a145e6f308fbc910be2dc6636c118b0819..5889410db6b54e9e1f806bb49d82360206fd56d8 100644 (file)
@@ -169,6 +169,21 @@ Batch *DRW_cache_single_vert_get(void)
 }
 
 /* Meshes */
+Batch *DRW_cache_wire_overlay_get(Object *ob)
+{
+       Batch *overlay_wire = NULL;
+
+       BLI_assert(ob->type == OB_MESH);
+
+       Mesh *me = ob->data;
+#if 1 /* new version not working */
+       overlay_wire = BKE_mesh_batch_cache_get_overlay_edges(me);
+#else
+       overlay_wire = BKE_mesh_batch_cache_get_all_edges(me);
+#endif
+       return overlay_wire;
+}
+
 Batch *DRW_cache_wire_outline_get(Object *ob)
 {
        Batch *fancy_wire = NULL;
index 13b33931b76d091d4ec2a0ef771687541e5197b7..54abccdd471d0e9c9c6df6682e6244139ab3f795 100644 (file)
@@ -35,6 +35,7 @@ struct Batch *DRW_cache_circle_ball_get(void);
 struct Batch *DRW_cache_single_vert_get(void);
 struct Batch *DRW_cache_plain_axes_get(void);
 /* Meshes */
+struct Batch *DRW_cache_wire_overlay_get(struct Object *ob);
 struct Batch *DRW_cache_wire_outline_get(struct Object *ob);
 struct Batch *DRW_cache_surface_get(struct Object *ob);
 
index 71a9582e70a0766137b6583582eaafef1bf3b201..0d5ea5ea6cdff40815208f9fdf479156087ac239 100644 (file)
@@ -86,7 +86,7 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa
 
        if (wire_overlay) {
                /* This pass can draw mesh edges top of Shaded Meshes without any Z fighting */
-               DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND;
+               DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_BLEND;
                *wire_overlay = DRW_pass_create("Wire Overlays Pass", state);
        }
 
@@ -236,13 +236,24 @@ static int draw_object_wire_theme(Object *ob)
 
 void DRW_shgroup_wire_overlay(DRWPass *wire_overlay, Object *ob)
 {
-       struct Batch *geom = DRW_cache_wire_outline_get(ob);
+#if 1
+       struct Batch *geom = DRW_cache_wire_overlay_get(ob);
        GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_EDGES_OVERLAY);
 
        DRWShadingGroup *grp = DRW_shgroup_create(sh, wire_overlay);
        DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1);
 
        DRW_shgroup_call_add(grp, geom, ob->obmat);
+#else
+       static float col[4] = {0.0f, 0.0f, 0.0f, 1.0f};
+       struct Batch *geom = DRW_cache_wire_overlay_get(ob);
+       GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
+
+       DRWShadingGroup *grp = DRW_shgroup_create(sh, wire_overlay);
+       DRW_shgroup_uniform_vec4(grp, "color", col, 1);
+
+       DRW_shgroup_call_add(grp, geom, ob->obmat);
+#endif
 }
 
 void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob,