As part of the overall sculpt brush refactor project, the `corner_tris`
attribute was removed from the PBVH and accessed directly from the mesh
runtime data.
A new set of methods was introduced to the `TrianglesCache` `struct` to
prevent tagging the cache as dirty and requiring a subsequent evaluation
because the performance hit while in sculpt mode was significant. This
was enabled upon entering sculpt mode and disabled upon exiting it.
Unfortunately, there are some operations inside Sculpt mode which can
cause either the Mesh object itself or the MeshRuntime object to be
recreated, effectively unfreezing the cache. A few examples that cause
this are:
* Undoing the first brush operation on file load
* Performing a remesh operation
To fix this issue, this commit checks and re-freezes the cache if it
is detected to be in a bad state prior to tagging the cache as dirty.
Further changes to fix this on a more fundamental level are well
outside of the scope of a fix needed for 4.3.1.
Pull Request: https://projects.blender.org/blender/blender/pulls/130709