As part of T95966, this patch moves loose edge information out of the
flag on each edge and into a new lazily calculated cache in mesh
runtime data. The number of loose edges is also cached, so further
processing can be skipped completely when there are no loose edges.
Previously the ME_LOOSEEDGE flag was updated on a "best effort"
basis. In order to be sure that it was correct, you had to be sure
to call BKE_mesh_calc_edges_loose first. Now the loose edge tag
is always correct. It also doesn't have to be calculated eagerly
in various places like the screw modifier where the complexity
wasn't worth the theoretical performance benefit.
There is also an API function to eagerly set the number of loose
edges to zero to avoid building the cache. This is used by various
primitive nodes, mainly with the goal of improving drawing performance.
This results in a few ms shaved off extracting draw data for some
large meshes in my tests.
In the Python API, MeshEdge.is_loose is no longer an editable
property. No built-in addons set its value anyway. The upside is that
addons can be sure the data is correct based on the mesh when they
retrieve it.
After this, there are only three more flags to move before we can save
1/3 of the memory usage for edges in most meshes.
Note: This patch has similarities with D16530. Some cleanup can be done if that is committed first.
Tests
There is one test failure in the Python OBJ exporter: export_obj_cube.
However, that happens because of incorrect versioning. Opening the
file, all the edges are set to "loose". This patch fixes that issue.