Files
test/tests/python
Hans Goudey 6a829d78fa Mesh: Rewrite validation code
Rewrite the "mesh is valid" and "validate mesh" functions to be more
agnostic of the custom data storage system, align with the changes to
topology storage in the last 5 years, be much clearer overall, more
reusable.

Each check is implemented as a separate pass over the remaining
valid geometry in the mesh, producing an IndexMask of the invalid
elements it finds. At the cost of some extra iteration over mesh elements,
this should make each requirement clearer and make it easier to
optimize and reuse each check if needed.

The code is roughly twice as fast as it was before. I measured 92ms
instead of 200ms for a 1 million vertex cube on a Ryzen 7950X.
There's a bit of low hanging fruit for further optimization too.

There are now automated tests just for the validation code as well.
For now they are very basic but they could be extended in the future.

Some non-obvious points:
- The new face offsets storage (replacing `MPoly`) upholds more
  invariants by itself. Previously faces could easily overlap or leave
  corners unreferenced. That doesn't really happen anymore, but
  bad offset values are a more "global" problem.
- The validation code for the old "MFace" storage was removed. It is
  just rebuilt when it's needed at runtime anyway, so there isn't much
  point in validating it.
- The versioning code for 2.90.1 was calling the mesh validation code
  to fix an issue where the extrude manifold tool could generate bad faces.
  Unfortunately keeping that would mean being unable to remove the old
  code, so now there's a warning to open and save the file in a previous
  version instead.
- One of the main goals of the new code is better const correctness, and
  working better with implicit sharing. The code now only requests mutable
  copies of the mesh data if it has to change.

Part of #122398

Pull Request: https://projects.blender.org/blender/blender/pulls/148063
2025-10-16 19:55:24 +02:00
..
2024-10-16 21:09:25 +11:00
2025-10-16 19:55:24 +02:00
2025-10-16 19:55:24 +02:00