[Bf-blender-cvs] [478899dee77] blender2.8: Edit Mesh: Fix missing loop normal display

Clément Foucault noreply at git.blender.org
Mon Oct 15 16:05:26 CEST 2018


Commit: 478899dee771e2421d49077674af4de97b78cd9e
Author: Clément Foucault
Date:   Mon Oct 15 11:51:47 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB478899dee771e2421d49077674af4de97b78cd9e

Edit Mesh: Fix missing loop normal display

===================================================================

M	source/blender/draw/intern/draw_cache.c
M	source/blender/draw/intern/draw_cache.h
M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/draw/modes/edit_mesh_mode.c

===================================================================

diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 20ead73e0f5..576d17d5d2e 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -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);
 }
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 4860b438bb1..0656783ea29 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -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);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 575670319d8..3805cccd9c0 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -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);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 6013c8eef91..eba3890ef6b 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -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);
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index 609d6b2edb6..f5555063480 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -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);
 				}
 			}



More information about the Bf-blender-cvs mailing list