Edit Mesh: Fix missing loop normal display
authorClément Foucault <foucault.clem@gmail.com>
Mon, 15 Oct 2018 09:51:47 +0000 (11:51 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Mon, 15 Oct 2018 14:04:50 +0000 (16:04 +0200)
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache.h
source/blender/draw/intern/draw_cache_impl.h
source/blender/draw/intern/draw_cache_impl_mesh.c
source/blender/draw/modes/edit_mesh_mode.c

index 20ead73e0f57c7076e03ecf3d99eb9738e1e2796..576d17d5d2e2c6db77bdfee7aaa53d86c2bc9568 100644 (file)
@@ -3001,13 +3001,14 @@ void DRW_cache_mesh_wire_overlay_get(
 
 void DRW_cache_mesh_normals_overlay_get(
         Object *ob,
-        GPUBatch **r_tris, GPUBatch **r_ledges, GPUBatch **r_lverts)
+        GPUBatch **r_tris, GPUBatch **r_tris_lnor, GPUBatch **r_ledges, GPUBatch **r_lverts)
 {
        BLI_assert(ob->type == OB_MESH);
 
        Mesh *me = ob->data;
 
        *r_tris = DRW_mesh_batch_cache_get_overlay_triangles_nor(me);
+       *r_tris_lnor = DRW_mesh_batch_cache_get_overlay_triangles_lnor(me);
        *r_ledges = DRW_mesh_batch_cache_get_overlay_loose_edges_nor(me);
        *r_lverts = DRW_mesh_batch_cache_get_overlay_loose_verts(me);
 }
index 4860b438bb19eed8d8edfa99448d0f62b2396dea..0656783ea2970d13abf7c6efccf566bdb0e220d7 100644 (file)
@@ -132,7 +132,8 @@ void DRW_cache_mesh_wire_overlay_get(
         struct GPUTexture **r_data_tex);
 void DRW_cache_mesh_normals_overlay_get(
         struct Object *ob,
-        struct GPUBatch **r_tris, struct GPUBatch **r_ledges, struct GPUBatch **r_lverts);
+        struct GPUBatch **r_tris, struct GPUBatch **r_tris_lnor,
+        struct GPUBatch **r_ledges, struct GPUBatch **r_lverts);
 struct GPUBatch *DRW_cache_face_centers_get(struct Object *ob);
 struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
 struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
index 575670319d8e1df926345794209645c71b59fea0..3805cccd9c0d3153741c269e8b7ca934b8017c2f 100644 (file)
@@ -143,6 +143,7 @@ struct GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold);
 struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_lnor(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_overlay_verts(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *me);
index 6013c8eef9147fc5afafa6e3ac3c824c4f1171b7..eba3890ef6bb624e807c5fd192ec22c8129e20b0 100644 (file)
@@ -2017,6 +2017,7 @@ typedef struct MeshBatchCache {
 
        GPUBatch *overlay_triangles;
        GPUBatch *overlay_triangles_nor; /* GPU_PRIM_POINTS */
+       GPUBatch *overlay_triangles_lnor; /* GPU_PRIM_POINTS */
        GPUBatch *overlay_loose_edges;
        GPUBatch *overlay_loose_edges_nor; /* GPU_PRIM_POINTS */
        GPUBatch *overlay_loose_verts;
@@ -2243,6 +2244,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
                        GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
                        GPU_BATCH_DISCARD_SAFE(cache->overlay_facedots);
                        GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor);
+                       GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_lnor);
                        GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor);
                        /* Edit mode selection. */
                        GPU_BATCH_DISCARD_SAFE(cache->facedot_with_select_id);
@@ -2343,6 +2345,7 @@ static void mesh_batch_cache_clear(Mesh *me)
        GPU_INDEXBUF_DISCARD_SAFE(cache->ed_tri_verts);
        GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles);
        GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_nor);
+       GPU_BATCH_DISCARD_SAFE(cache->overlay_triangles_lnor);
        GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_verts);
        GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges);
        GPU_BATCH_DISCARD_SAFE(cache->overlay_loose_edges_nor);
@@ -4976,6 +4979,13 @@ static void mesh_batch_cache_create_overlay_batches(Mesh *me)
                GPU_batch_vertbuf_add(cache->overlay_triangles_nor, mesh_batch_cache_get_edit_tri_data(rdata, cache));
        }
 
+       if (cache->overlay_triangles_lnor == NULL) {
+               cache->overlay_triangles_lnor = GPU_batch_create(
+                       GPU_PRIM_POINTS, mesh_batch_cache_get_edit_tri_pos(rdata, cache), NULL);
+               GPU_batch_vertbuf_add(cache->overlay_triangles_lnor, mesh_batch_cache_get_edit_tri_nor(rdata, cache));
+               GPU_batch_vertbuf_add(cache->overlay_triangles_lnor, mesh_batch_cache_get_edit_tri_data(rdata, cache));
+       }
+
        if (cache->overlay_loose_edges_nor == NULL) {
                cache->overlay_loose_edges_nor = GPU_batch_create(
                        GPU_PRIM_POINTS, mesh_batch_cache_get_edit_ledge_pos(rdata, cache), NULL);
@@ -5041,6 +5051,17 @@ GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_nor(Mesh *me)
        return cache->overlay_triangles_nor;
 }
 
+GPUBatch *DRW_mesh_batch_cache_get_overlay_triangles_lnor(Mesh *me)
+{
+       MeshBatchCache *cache = mesh_batch_cache_get(me);
+
+       if (cache->overlay_triangles_lnor == NULL) {
+               mesh_batch_cache_create_overlay_batches(me);
+       }
+
+       return cache->overlay_triangles_lnor;
+}
+
 GPUBatch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(Mesh *me)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
index 609d6b2edb69835fcdc0bcf90329c4f8ec7c7ed7..f5555063480ae93a552c9aefaa1af799cba7ca4f 100644 (file)
@@ -564,7 +564,7 @@ static void edit_mesh_add_ob_to_pass(
         DRWShadingGroup *facedot_shgrp,
         DRWShadingGroup *facefill_shgrp)
 {
-       struct GPUBatch *geo_ovl_tris, *geo_ovl_verts, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
+       struct GPUBatch *geo_ovl_tris, *geo_ovl_verts, *geo_ovl_lnor, *geo_ovl_ledges, *geo_ovl_lverts, *geo_ovl_fcenter;
        struct GPUTexture *data_texture;
        ToolSettings *tsettings = scene->toolsettings;
 
@@ -582,7 +582,7 @@ static void edit_mesh_add_ob_to_pass(
 
        if ((tsettings->selectmode & SCE_SELECT_VERTEX) != 0) {
                /* Thoses are point batches. */
-               DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_verts, &geo_ovl_ledges, &geo_ovl_lverts);
+               DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_verts, &geo_ovl_lnor, &geo_ovl_ledges, &geo_ovl_lverts);
                DRW_shgroup_call_add(verts_shgrp, geo_ovl_verts, ob->obmat);
                DRW_shgroup_call_add(lverts_shgrp, geo_ovl_ledges, ob->obmat);
                DRW_shgroup_call_add(lverts_shgrp, geo_ovl_lverts, ob->obmat);
@@ -648,8 +648,8 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
                        }
 
                        if (vnormals_do || lnormals_do) {
-                               struct GPUBatch *geo_ovl_tris, *geo_ovl_ledges, *geo_ovl_lverts;
-                               DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_tris, &geo_ovl_ledges, &geo_ovl_lverts);
+                               struct GPUBatch *geo_ovl_tris, *geo_ovl_lnor, *geo_ovl_ledges, *geo_ovl_lverts;
+                               DRW_cache_mesh_normals_overlay_get(ob, &geo_ovl_tris, &geo_ovl_lnor, &geo_ovl_ledges, &geo_ovl_lverts);
 
                                if (vnormals_do) {
                                        DRW_shgroup_call_add(stl->g_data->vnormals_shgrp, geo_ovl_tris, ob->obmat);
@@ -658,7 +658,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
                                }
 
                                if (lnormals_do) {
-                                       DRW_shgroup_call_add(stl->g_data->lnormals_shgrp, geo_ovl_tris, ob->obmat);
+                                       DRW_shgroup_call_add(stl->g_data->lnormals_shgrp, geo_ovl_lnor, ob->obmat);
                                }
                        }