Fix T57294: Modifiers cage ignore face visibility
This commit is contained in:
parent
60d7740fe6
commit
6add652c38
Notes:
blender-bot
2023-02-14 09:48:23 +01:00
Referenced by issue #57351, Modifiers (skin, armature, hook) not drawing in editmode Referenced by issue #57312, Bevel/Triangulate modifier causes crash in edit mode Referenced by issue #57294, Modifiers cage ignore face visibility
|
@ -4386,7 +4386,9 @@ 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)
|
||||
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)
|
||||
{
|
||||
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_POLY));
|
||||
|
||||
|
@ -4413,13 +4415,26 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
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);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BM_mesh_elem_table_ensure(bm_mapped, BM_FACE);
|
||||
BMFace **ftable = bm_mapped->ftable;
|
||||
for (uint i = 0; i < poly_len; i++) {
|
||||
const int p_orig = p_origindex_mapped[i];
|
||||
if ((p_orig != ORIGINDEX_NONE) && !BM_elem_flag_test(ftable[p_orig], BM_ELEM_HIDDEN)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Init ELBs. */
|
||||
for (int i = 0; i < mat_len; i++) {
|
||||
|
@ -4443,7 +4458,7 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
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;
|
||||
|
@ -4453,6 +4468,23 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material(
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
BMFace **ftable = bm_mapped->ftable;
|
||||
for (uint i = 0; i < poly_len; i++) {
|
||||
const int p_orig = p_origindex_mapped[i];
|
||||
const MPoly *mp = &rdata->mpoly[i]; ;
|
||||
if ((p_orig != ORIGINDEX_NONE) && !BM_elem_flag_test(ftable[p_orig], BM_ELEM_HIDDEN)) {
|
||||
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 += (mp->totloop - 2) * 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Build ELBs. */
|
||||
for (int i = 0; i < mat_len; i++) {
|
||||
|
@ -5181,12 +5213,21 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
|
|||
if (cache->shaded_triangles == NULL) {
|
||||
|
||||
/* Hack to show the final result. */
|
||||
BMesh *bm_mapped = NULL;
|
||||
const int *p_origindex = NULL;
|
||||
const bool use_em_final = (
|
||||
me->edit_btmesh &&
|
||||
me->edit_btmesh->mesh_eval_final &&
|
||||
(me->edit_btmesh->mesh_eval_final->runtime.is_original == false));
|
||||
Mesh me_fake;
|
||||
if (use_em_final) {
|
||||
/* Pass in mapped args. */
|
||||
bm_mapped = me->edit_btmesh->bm;
|
||||
p_origindex = CustomData_get_layer(&me->edit_btmesh->mesh_eval_final->pdata, CD_ORIGINDEX);
|
||||
if (p_origindex == NULL) {
|
||||
bm_mapped = NULL;
|
||||
}
|
||||
|
||||
me_fake = *me->edit_btmesh->mesh_eval_final;
|
||||
me_fake.mat = me->mat;
|
||||
me_fake.totcol = me->totcol;
|
||||
|
@ -5203,7 +5244,9 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
|
|||
|
||||
cache->shaded_triangles = MEM_callocN(sizeof(*cache->shaded_triangles) * mat_len, __func__);
|
||||
|
||||
GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache);
|
||||
GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(
|
||||
rdata, cache,
|
||||
bm_mapped, p_origindex);
|
||||
|
||||
GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
|
||||
GPUVertBuf *vbo_shading = mesh_batch_cache_get_tri_shading_data(rdata, cache);
|
||||
|
@ -5242,7 +5285,7 @@ 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);
|
||||
GPUIndexBuf **el = mesh_batch_cache_get_triangles_in_order_split_by_material(rdata, cache, NULL, NULL);
|
||||
|
||||
GPUVertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
|
||||
for (int i = 0; i < mat_len; i++) {
|
||||
|
|
Loading…
Reference in New Issue