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:
authorRohan Rathi <rohanrathi08@gmail.com>2018-05-29 08:40:54 +0300
committerRohan Rathi <rohanrathi08@gmail.com>2018-05-29 08:40:54 +0300
commit842245ac55ceca67863cdad252d8959cefb789c5 (patch)
tree3301dd7fc5324ccd8b2ceea0d389f7d55b413fa8 /source/blender/draw/intern/draw_cache_impl_mesh.c
parent5d2d36b0686d7253f9d61c00a63d273aba17677a (diff)
parent6946c413402c05a838e98a3823bf926df8cfe8d1 (diff)
Merge branch 'blender2.8' into soc-2018-bevel
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_mesh.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index e8add4890d8..cf972434ba5 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -1633,6 +1633,9 @@ typedef struct MeshBatchCache {
/* XXX, only keep for as long as sculpt mode uses shaded drawing. */
bool is_sculpt_points_tag;
+
+ /* Valid only if edges_adjacency is up to date. */
+ bool is_manifold;
} MeshBatchCache;
/* Gwn_Batch cache management. */
@@ -1953,7 +1956,8 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
GWN_vertformat_alias_add(format, attrib_name);
/* +1 include null terminator. */
- auto_ofs += 1 + BLI_snprintf_rlen(cache->auto_layer_names + auto_ofs, auto_names_len - auto_ofs, "b%s", attrib_name);
+ auto_ofs += 1 + BLI_snprintf_rlen(
+ cache->auto_layer_names + auto_ofs, auto_names_len - auto_ofs, "b%s", attrib_name);
cache->auto_layer_is_srgb[auto_id++] = 0; /* tag as not srgb */
if (i == rdata->cd.layers.uv_active) {
@@ -1988,7 +1992,8 @@ static Gwn_VertBuf *mesh_batch_cache_get_tri_shading_data(MeshRenderData *rdata,
GWN_vertformat_alias_add(format, attrib_name);
/* +1 include null terminator. */
- auto_ofs += 1 + BLI_snprintf_rlen(cache->auto_layer_names + auto_ofs, auto_names_len - auto_ofs, "b%s", attrib_name);
+ auto_ofs += 1 + BLI_snprintf_rlen(
+ cache->auto_layer_names + auto_ofs, auto_names_len - auto_ofs, "b%s", attrib_name);
cache->auto_layer_is_srgb[auto_id++] = 1; /* tag as srgb */
}
@@ -3232,6 +3237,8 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
const int vert_len = mesh_render_data_verts_len_get(rdata);
const int tri_len = mesh_render_data_looptri_len_get(rdata);
+ cache->is_manifold = true;
+
/* Allocate max but only used indices are sent to GPU. */
Gwn_IndexBufBuilder elb;
GWN_indexbuf_init(&elb, GWN_PRIM_LINES_ADJ, tri_len * 3, vert_len);
@@ -3277,6 +3284,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
/* Don't share edge if triangles have non matching winding. */
GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
GWN_indexbuf_add_line_adj_verts(&elb, v_opposite, v1, v2, v_opposite);
+ cache->is_manifold = false;
}
else {
GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v_opposite);
@@ -3301,6 +3309,7 @@ static Gwn_IndexBuf *mesh_batch_cache_get_edges_adjacency(MeshRenderData *rdata,
SWAP(unsigned int, v1, v2);
}
GWN_indexbuf_add_line_adj_verts(&elb, v0, v1, v2, v0);
+ cache->is_manifold = false;
}
BLI_edgehashIterator_free(ehi);
BLI_edgehash_free(eh, NULL);
@@ -3820,7 +3829,7 @@ Gwn_Batch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
return cache->fancy_edges;
}
-Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me)
+Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold)
{
MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -3829,12 +3838,17 @@ Gwn_Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me)
MeshRenderData *rdata = mesh_render_data_create(me, options);
- cache->edge_detection = GWN_batch_create_ex(GWN_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
- mesh_batch_cache_get_edges_adjacency(rdata, cache), 0);
+ cache->edge_detection = GWN_batch_create_ex(
+ GWN_PRIM_LINES_ADJ, mesh_batch_cache_get_vert_pos_and_nor_in_order(rdata, cache),
+ mesh_batch_cache_get_edges_adjacency(rdata, cache), 0);
mesh_render_data_free(rdata);
}
+ if (r_is_manifold) {
+ *r_is_manifold = cache->is_manifold;
+ }
+
return cache->edge_detection;
}