diff options
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 25 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.h | 9 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl.h | 8 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 127 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 18 |
6 files changed, 119 insertions, 69 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index faba85c9b46..a5e08b4411c 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -512,6 +512,7 @@ DrawData *DRW_drawdata_ensure( bool DRW_object_is_renderable(const struct Object *ob); bool DRW_object_is_visible_in_active_context(const struct Object *ob); bool DRW_object_is_flat_normal(const struct Object *ob); +bool DRW_object_use_hide_faces(const struct Object *ob); bool DRW_object_is_visible_psys_in_active_context(const struct Object *object, const struct ParticleSystem *psys); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 325f607da2e..8fe3ba5e5b3 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -729,9 +729,14 @@ GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob) GPUBatch *DRW_cache_object_surface_get(Object *ob) { + return DRW_cache_object_surface_get_ex(ob, false); +} + +GPUBatch *DRW_cache_object_surface_get_ex(Object *ob, bool use_hide) +{ switch (ob->type) { case OB_MESH: - return DRW_cache_mesh_surface_get(ob); + return DRW_cache_mesh_surface_get(ob, use_hide); case OB_CURVE: return DRW_cache_curve_surface_get(ob); case OB_SURF: @@ -746,7 +751,7 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob) } GPUBatch **DRW_cache_object_surface_material_get( - struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { if (auto_layer_names != NULL) { @@ -757,7 +762,7 @@ GPUBatch **DRW_cache_object_surface_material_get( switch (ob->type) { case OB_MESH: - return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len, + return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len, use_hide, auto_layer_names, auto_layer_is_srgb, auto_layer_count); case OB_CURVE: return DRW_cache_curve_surface_shaded_get(ob, gpumat_array, gpumat_array_len); @@ -3049,12 +3054,12 @@ GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold) return DRW_mesh_batch_cache_get_edge_detection(me, r_is_manifold); } -GPUBatch *DRW_cache_mesh_surface_get(Object *ob) +GPUBatch *DRW_cache_mesh_surface_get(Object *ob, bool use_hide) { BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; - return DRW_mesh_batch_cache_get_triangles_with_normals(me); + return DRW_mesh_batch_cache_get_triangles_with_normals(me, use_hide); } void DRW_cache_mesh_face_wireframe_get( @@ -3127,23 +3132,23 @@ GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob) /* Return list of batches */ GPUBatch **DRW_cache_mesh_surface_shaded_get( - Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; - return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len, + return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len, use_hide, auto_layer_names, auto_layer_is_srgb, auto_layer_count); } /* Return list of batches */ -GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob) +GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob, bool use_hide) { BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; - return DRW_mesh_batch_cache_get_surface_texpaint(me); + return DRW_mesh_batch_cache_get_surface_texpaint(me, use_hide); } GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob) @@ -3183,7 +3188,7 @@ GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(Object *ob, bool use_wire, bool BLI_assert(ob->type == OB_MESH); Mesh *me = ob->data; - return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel); + return DRW_mesh_batch_cache_get_weight_overlay_edges(me, use_wire, use_sel, use_sel); } GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob) diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index d2aa2622246..207bc6ec5de 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -53,9 +53,10 @@ struct GPUBatch *DRW_cache_screenspace_circle_get(void); struct GPUBatch *DRW_cache_object_wire_outline_get(struct Object *ob); struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold); struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob); +struct GPUBatch *DRW_cache_object_surface_get_ex(struct Object *ob, bool use_hide); struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob); struct GPUBatch **DRW_cache_object_surface_material_get( - struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); void DRW_cache_object_face_wireframe_get( Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count); @@ -137,7 +138,7 @@ void DRW_cache_mesh_normals_overlay_get( 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); -struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob); +struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob, bool use_hide); struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob); struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob, struct ToolSettings *ts, bool paint_mode); struct GPUBatch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob); @@ -148,9 +149,9 @@ struct GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool struct GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(struct Object *ob); struct GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(struct Object *ob); struct GPUBatch **DRW_cache_mesh_surface_shaded_get( - struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); -struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob); +struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob, bool use_hide); struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob); void DRW_cache_mesh_face_wireframe_get( Object *ob, struct GPUTexture **r_vert_tx, struct GPUTexture **r_faceid_tx, int *r_tri_count); diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 9dc735807c0..a9a6093529e 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -128,16 +128,16 @@ bool DRW_mesh_weight_state_compare(const struct DRW_MeshWeightState *a, const st /* Mesh */ struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( - struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count); -struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me); +struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me, bool use_hide); struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me); -struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel); +struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(struct Mesh *me, bool use_wire, bool use_sel, bool use_hide); struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me); struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(struct Mesh *me); struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me); struct GPUBatch *DRW_mesh_batch_cache_get_all_triangles(struct Mesh *me); -struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me); +struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me, bool use_hide); struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me, const struct DRW_MeshWeightState *wstate); struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(struct Mesh *me); struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index a24702368de..fbd2420b7a4 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -247,6 +247,7 @@ typedef struct MeshRenderData { GPUPackedNormal *poly_normals_pack; GPUPackedNormal *vert_normals_pack; bool *edge_select_bool; + bool *edge_visible_bool; } MeshRenderData; enum { @@ -967,6 +968,7 @@ static void mesh_render_data_free(MeshRenderData *rdata) MEM_SAFE_FREE(rdata->vert_normals_pack); MEM_SAFE_FREE(rdata->vert_weight); MEM_SAFE_FREE(rdata->edge_select_bool); + MEM_SAFE_FREE(rdata->edge_visible_bool); MEM_SAFE_FREE(rdata->vert_color); MEM_SAFE_FREE(rdata->mapped.loose_verts); @@ -1350,6 +1352,27 @@ static void mesh_render_data_ensure_edge_select_bool(MeshRenderData *rdata, bool } } +/** Ensure #MeshRenderData.edge_visible_bool */ +static void mesh_render_data_ensure_edge_visible_bool(MeshRenderData *rdata) +{ + bool *edge_visible_bool = rdata->edge_visible_bool; + if (edge_visible_bool == NULL) { + edge_visible_bool = rdata->edge_visible_bool = + MEM_callocN(sizeof(*edge_visible_bool) * rdata->edge_len, __func__); + + for (int i = 0; i < rdata->poly_len; i++) { + const MPoly *poly = &rdata->mpoly[i]; + + if (!(poly->flag & ME_HIDE)) { + for (int j = 0; j < poly->totloop; j++) { + const MLoop *loop = &rdata->mloop[poly->loopstart + j]; + edge_visible_bool[loop->e] = true; + } + } + } + } +} + /** \} */ /* ---------------------------------------------------------------------- */ @@ -1949,6 +1972,7 @@ typedef struct MeshBatchCache { GPUBatch *all_triangles; GPUVertBuf *pos_with_normals; + GPUVertBuf *pos_with_normals_visible_only; GPUVertBuf *tri_aligned_uv; /* Active UV layer (mloopuv) */ /** @@ -2298,7 +2322,7 @@ static void mesh_batch_cache_clear_selective(Mesh *me, GPUVertBuf *vert) BLI_assert(vert != NULL); - if (cache->pos_with_normals == vert) { + if (ELEM(vert, cache->pos_with_normals, cache->pos_with_normals_visible_only)) { GPU_BATCH_DISCARD_SAFE(cache->triangles_with_normals); GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights); GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); @@ -2371,6 +2395,7 @@ static void mesh_batch_cache_clear(Mesh *me) GPU_BATCH_DISCARD_SAFE(cache->points_with_normals); GPU_BATCH_DISCARD_SAFE(cache->ledges_with_normals); GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals); + GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals_visible_only); GPU_BATCH_DISCARD_SAFE(cache->triangles_with_weights); GPU_BATCH_DISCARD_SAFE(cache->triangles_with_vert_colors); GPU_VERTBUF_DISCARD_SAFE(cache->tri_aligned_uv); @@ -2923,19 +2948,11 @@ static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals_ex( } static GPUVertBuf *mesh_batch_cache_get_tri_pos_and_normals( - MeshRenderData *rdata, MeshBatchCache *cache) -{ - return mesh_batch_cache_get_tri_pos_and_normals_ex( - rdata, false, - &cache->pos_with_normals); -} -static GPUVertBuf *mesh_create_tri_pos_and_normals_visible_only( - MeshRenderData *rdata) + MeshRenderData *rdata, MeshBatchCache *cache, bool use_hide) { - GPUVertBuf *vbo_dummy = NULL; return mesh_batch_cache_get_tri_pos_and_normals_ex( - rdata, true, - &vbo_dummy); + rdata, use_hide, + use_hide ? &cache->pos_with_normals_visible_only : &cache->pos_with_normals); } static GPUVertBuf *mesh_batch_cache_get_facedot_pos_with_normals_and_flag( @@ -4402,7 +4419,7 @@ static GPUIndexBuf *mesh_batch_cache_get_loose_edges(MeshRenderData *rdata, Mesh static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( MeshRenderData *rdata, MeshBatchCache *cache, /* Special case when drawing final evaluated mesh in editmode, so hidden faces are ignored. */ - BMesh *bm_mapped, const int *p_origindex_mapped) + BMesh *bm_mapped, const int *p_origindex_mapped, bool use_hide) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY)); @@ -4431,9 +4448,11 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( } else if (bm_mapped == NULL) { for (uint i = 0; i < poly_len; i++) { - const MPoly *mp = &rdata->mpoly[i]; ; - const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; - mat_tri_len[ma_id] += (mp->totloop - 2); + const MPoly *mp = &rdata->mpoly[i]; + if (!use_hide || !(mp->flag & ME_HIDE)) { + const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; + mat_tri_len[ma_id] += (mp->totloop - 2); + } } } else { @@ -4475,11 +4494,16 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( } else if (bm_mapped == NULL) { for (uint i = 0; i < poly_len; i++) { - const MPoly *mp = &rdata->mpoly[i]; ; - const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; - for (int j = 2; j < mp->totloop; j++) { - GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); - nidx += 3; + const MPoly *mp = &rdata->mpoly[i]; + if (!use_hide || !(mp->flag & ME_HIDE)) { + const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; + for (int j = 2; j < mp->totloop; j++) { + GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); + nidx += 3; + } + } + else { + nidx += 3 * (mp->totloop - 2); } } } @@ -4515,7 +4539,7 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( } static GPUVertBuf *mesh_create_edge_pos_with_sel( - MeshRenderData *rdata, bool use_wire, bool use_select_bool) + MeshRenderData *rdata, bool use_wire, bool use_select_bool, bool use_visible_bool) { BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_POLY | MR_DATATYPE_LOOP)); BLI_assert(rdata->edit_bmesh == NULL); @@ -4543,10 +4567,18 @@ static GPUVertBuf *mesh_create_edge_pos_with_sel( mesh_render_data_ensure_edge_select_bool(rdata, use_wire); } bool *edge_select_bool = use_select_bool ? rdata->edge_select_bool : NULL; + if (use_visible_bool) { + mesh_render_data_ensure_edge_visible_bool(rdata); + } + bool *edge_visible_bool = use_visible_bool ? rdata->edge_visible_bool : NULL; for (int i = 0; i < edge_len; i++) { const MEdge *ed = &rdata->medge[i]; + if (use_visible_bool && !edge_visible_bool[i]) { + continue; + } + uchar edge_vert_sel; if (use_select_bool && edge_select_bool[i]) { edge_vert_sel = true; @@ -4685,7 +4717,7 @@ GPUBatch *DRW_mesh_batch_cache_get_all_triangles(Mesh *me) return cache->all_triangles; } -GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me, bool use_hide) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -4694,7 +4726,7 @@ GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me) MeshRenderData *rdata = mesh_render_data_create(me, datatype); cache->triangles_with_normals = GPU_batch_create( - GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); + GPU_PRIM_TRIS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, use_hide), NULL); mesh_render_data_free(rdata); } @@ -4741,11 +4773,9 @@ GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights( DRW_mesh_weight_state_copy(&cache->weight_state, wstate); - GPUVertBuf *vbo_tris = use_hide ? - mesh_create_tri_pos_and_normals_visible_only(rdata) : - mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, use_hide); - GPU_batch_vertbuf_add_ex(cache->triangles_with_weights, vbo_tris, use_hide); + GPU_batch_vertbuf_add(cache->triangles_with_weights, vbo_tris); mesh_render_data_free(rdata); } @@ -4766,10 +4796,8 @@ GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(Mesh * cache->triangles_with_vert_colors = GPU_batch_create_ex( GPU_PRIM_TRIS, mesh_create_tri_vert_colors(rdata, use_hide), NULL, GPU_BATCH_OWNS_VBO); - GPUVertBuf *vbo_tris = use_hide ? - mesh_create_tri_pos_and_normals_visible_only(rdata) : - mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GPU_batch_vertbuf_add_ex(cache->triangles_with_vert_colors, vbo_tris, use_hide); + GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, use_hide); + GPU_batch_vertbuf_add(cache->triangles_with_vert_colors, vbo_tris); mesh_render_data_free(rdata); } @@ -4799,10 +4827,8 @@ struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id( cache->triangles_with_select_id = GPU_batch_create_ex( GPU_PRIM_TRIS, mesh_create_tri_select_id(rdata, use_hide, select_id_offset), NULL, GPU_BATCH_OWNS_VBO); - GPUVertBuf *vbo_tris = use_hide ? - mesh_create_tri_pos_and_normals_visible_only(rdata) : - mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); - GPU_batch_vertbuf_add_ex(cache->triangles_with_select_id, vbo_tris, use_hide); + GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, use_hide); + GPU_batch_vertbuf_add(cache->triangles_with_select_id, vbo_tris); mesh_render_data_free(rdata); } @@ -4825,12 +4851,10 @@ struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh rdata->mapped.use = true; } - GPUVertBuf *vbo_tris = use_hide ? - mesh_create_tri_pos_and_normals_visible_only(rdata) : - mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo_tris = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, use_hide); - cache->triangles_with_select_mask = GPU_batch_create_ex( - GPU_PRIM_TRIS, vbo_tris, NULL, use_hide ? GPU_BATCH_OWNS_VBO : 0); + cache->triangles_with_select_mask = GPU_batch_create( + GPU_PRIM_TRIS, vbo_tris, NULL); mesh_render_data_free(rdata); } @@ -4847,7 +4871,7 @@ GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me) MeshRenderData *rdata = mesh_render_data_create(me, datatype); cache->points_with_normals = GPU_batch_create( - GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache), NULL); + GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, false), NULL); mesh_render_data_free(rdata); } @@ -5221,7 +5245,7 @@ GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me, uint select_id } GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( - Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, + Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len, bool use_hide, char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -5262,9 +5286,9 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material( rdata, cache, - bm_mapped, p_origindex); + bm_mapped, p_origindex, use_hide); - GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, false); GPUVertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache); for (int i = 0; i < mat_len; i++) { @@ -5287,7 +5311,7 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( return cache->shaded_triangles; } -GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) +GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me, bool use_hide) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -5301,9 +5325,10 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(Mesh *me) cache->texpaint_triangles = MEM_callocN(sizeof(*cache->texpaint_triangles) * mat_len, __func__); - GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache, NULL, NULL); + GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache, NULL, NULL, use_hide); + + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, false); - GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); for (int i = 0; i < mat_len; i++) { cache->texpaint_triangles[i] = GPU_batch_create( GPU_PRIM_TRIS, vbo, el[i]); @@ -5328,7 +5353,7 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(Mesh *me) MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_POLY | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOPUV; MeshRenderData *rdata = mesh_render_data_create(me, datatype); - GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache); + GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache, false); cache->texpaint_triangles_single = GPU_batch_create( GPU_PRIM_TRIS, vbo, NULL); @@ -5392,7 +5417,7 @@ GPUBatch *DRW_mesh_batch_cache_get_texpaint_loop_wire(Mesh *me) return cache->texpaint_uv_loops; } -GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel) +GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, bool use_sel, bool use_hide) { MeshBatchCache *cache = mesh_batch_cache_get(me); @@ -5402,7 +5427,7 @@ GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_edges(Mesh *me, bool use_wire, MeshRenderData *rdata = mesh_render_data_create(me, datatype); cache->overlay_paint_edges = GPU_batch_create_ex( - GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel), NULL, GPU_BATCH_OWNS_VBO); + GPU_PRIM_LINES, mesh_create_edge_pos_with_sel(rdata, use_wire, use_sel, use_hide), NULL, GPU_BATCH_OWNS_VBO); mesh_render_data_free(rdata); } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index bc3e8c9f716..71365cac470 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -189,6 +189,24 @@ bool DRW_object_is_flat_normal(const Object *ob) return true; } +bool DRW_object_use_hide_faces(const struct Object *ob) +{ + if (ob->type == OB_MESH) { + const Mesh *me = ob->data; + + switch (ob->mode) { + case OB_MODE_TEXTURE_PAINT: + case OB_MODE_VERTEX_PAINT: + return (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; + + case OB_MODE_WEIGHT_PAINT: + return (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0; + } + } + + return false; +} + bool DRW_object_is_visible_psys_in_active_context( const Object *object, const ParticleSystem *psys) |