diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-20 06:21:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-20 07:39:13 +0300 |
commit | 513f566b40a5bde4d89797aecf7c0ad3e4d1a20b (patch) | |
tree | 40949ae61aef858a7e3f8710abdc56f4e7da4f70 /source/blender/draw/intern/draw_cache_extract_mesh_render_data.c | |
parent | b5e5fbcfc81b6ca4968d0788b5e6e330205d298b (diff) |
Mesh: optimize object mode face tessellation
- Multi-thread BKE_mesh_recalc_looptri.
- Add BKE_mesh_recalc_looptri_with_normals,
this skips having to calculate normals for ngons.
Exact performance depends on number of faces, size of ngons and
available CPU cores.
For high poly meshes the isolated improvement to BKE_mesh_recalc_looptri
in my tests was between 6.7x .. 25.0x, with the largest gains seen in
meshes containing ngons with many sides.
The overall speedup for high poly meshes containing quads and triangles
is only ~20% although ngon heavy meshes can be much faster.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_extract_mesh_render_data.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh_render_data.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c index 44026c0167b..b0eb0c8bcb3 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c @@ -349,8 +349,19 @@ void mesh_render_data_update_looptris(MeshRenderData *mr, /* Mesh */ if ((iter_type & MR_ITER_LOOPTRI) || (data_flag & MR_DATA_LOOPTRI)) { mr->mlooptri = MEM_mallocN(sizeof(*mr->mlooptri) * mr->tri_len, "MR_DATATYPE_LOOPTRI"); - BKE_mesh_recalc_looptri( - me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, mr->mlooptri); + if (mr->poly_normals != NULL) { + BKE_mesh_recalc_looptri_with_normals(me->mloop, + me->mpoly, + me->mvert, + me->totloop, + me->totpoly, + mr->mlooptri, + mr->poly_normals); + } + else { + BKE_mesh_recalc_looptri( + me->mloop, me->mpoly, me->mvert, me->totloop, me->totpoly, mr->mlooptri); + } } } else { |