Page MenuHome

Mesh: Use cached looptris in draw cache extraction
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Jul 26 2022, 10:19 PM.

Details

Summary

The mesh's triangulation cache is often created for other operations
besides the drawing code, but during the mesh draw cache extraction
it is recalculated on every single time. It is simpler and faster to use
the existing MLoopTri array. It can also save memory if the cache
already exists by avoiding allocating a duplicate array. For a 4 million
face quad mesh, that is already 128 MB.

Also use face normals for mesh triangulation if they aren't dirty,
which should provide a general speedup when they're both necessary.

Recently 54182e4925de made this more reliable, since the triangulation
cache is invalidated properly when the mesh is deformed.

Fixes T98073

This change saves about 20ms on every update in this trivial file:

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Jul 26 2022, 10:19 PM
Hans Goudey (HooglyBoogly) created this revision.
Campbell Barton (campbellbarton) requested changes to this revision.EditedAug 2 2022, 7:38 AM

In general this seems fine however it removes reuse of polygon normals which will add some overhead (in the case they have already been calculated).

We could have a version of BKE_mesh_runtime_looptri_ensure that takes a poly_normals array since the functions it calls accept this data.

This revision now requires changes to proceed.Aug 2 2022, 7:38 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

Use existing face normals for triangulation when they aren't dirty

This revision is now accepted and ready to land.Sep 23 2022, 10:53 AM