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
..
2025-01-28 15:27:34 +01:00
2025-09-08 14:09:21 +02:00
2025-07-24 22:18:15 +10:00
2025-10-07 19:59:36 +02:00
2025-07-09 20:59:26 +02:00
2025-06-10 17:46:55 +02:00
2025-05-09 16:13:25 +02:00
2025-09-30 10:23:20 +02:00
2025-07-09 20:59:26 +02:00
2025-07-09 20:59:26 +02:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-10-02 12:55:42 -04:00
2025-07-07 15:50:38 +02:00
2025-07-17 09:42:39 +02:00
2025-10-07 19:59:36 +02:00
2025-04-21 17:59:41 +02:00
2025-06-23 18:11:33 +02:00
2025-10-02 12:55:42 -04:00
2025-10-07 16:11:47 +02:00
2025-05-17 10:17:37 +10:00
2025-03-05 16:35:09 +01:00
2025-03-20 11:25:19 +01:00
2025-07-01 22:14:26 +02:00
2025-10-13 15:38:26 +02:00
2025-10-10 19:40:26 +02:00
2025-01-30 17:19:16 +01:00
2025-08-17 18:08:18 +02:00
2025-08-17 18:08:18 +02:00
2025-05-09 17:27:07 +02:00
2025-10-16 17:16:05 +02:00
2025-10-09 03:24:57 +02:00
2025-01-31 17:03:17 +01:00
2025-01-28 15:27:34 +01:00
2025-10-06 16:19:18 +02:00
2025-02-12 23:01:08 +01:00
2025-01-29 12:12:27 +01:00
2025-10-03 11:43:33 +02:00
2025-08-12 16:03:09 +02:00
2025-08-05 06:25:20 +02:00
2025-05-29 21:21:18 +02:00
2025-01-28 15:27:34 +01:00
2025-03-05 16:35:09 +01:00
2025-03-20 11:25:19 +01:00
2025-07-26 12:33:15 +00:00
2025-10-02 16:20:08 +02:00
2025-10-07 23:55:12 +00:00
2025-07-26 12:33:15 +00:00
2025-05-20 04:33:43 +00:00
2025-07-09 20:59:26 +02:00
2025-07-13 21:58:53 +10:00
2025-10-14 19:38:41 +02:00
2025-02-19 17:11:08 +01:00
2025-09-10 16:39:01 +02:00
2025-01-28 15:27:34 +01:00
2025-10-13 01:07:13 +02:00
2025-10-02 12:55:42 -04:00
2025-09-05 19:03:32 +02:00
2025-06-02 17:13:56 -04:00
2025-10-02 12:55:42 -04:00
2025-10-07 19:47:42 +02:00
2025-08-07 12:18:06 +02:00
2025-09-09 16:15:43 +02:00
2025-10-07 15:14:22 +02:00
2025-09-19 06:48:07 +00:00
2025-10-13 18:23:50 +02:00
2025-10-02 12:55:42 -04:00
2025-03-20 11:25:19 +01:00
2025-09-03 10:48:00 +02:00
2025-03-20 11:25:19 +01:00
2024-10-31 11:25:41 +01:00
2025-05-20 10:11:56 +00:00
2025-10-02 12:55:42 -04:00
2025-01-31 17:03:17 +01:00
2025-05-12 16:51:21 +02:00
2025-09-05 16:25:32 +02:00
2025-09-29 17:15:04 +02:00
2025-07-01 22:14:26 +02:00
2025-10-02 12:55:42 -04:00
2025-08-08 07:37:33 +10:00
2025-09-29 18:47:51 +02:00
2025-08-25 18:22:36 +02:00
2025-09-03 04:29:08 +02:00
2025-08-25 23:37:12 +02:00
2025-10-16 17:16:05 +02:00
2025-06-12 10:37:47 +02:00
2025-10-16 17:16:05 +02:00
2025-07-16 22:53:21 +02:00
2025-10-13 15:38:26 +02:00
2025-07-10 14:51:50 +02:00
2025-08-28 14:24:25 +02:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-04-21 17:59:41 +02:00
2025-04-21 17:59:41 +02:00
2025-01-28 15:27:34 +01:00
2025-10-02 12:55:42 -04:00
2025-05-02 15:08:29 +02:00
2025-06-09 11:35:19 +02:00
2025-05-29 21:21:18 +02:00
2025-10-02 12:55:42 -04:00
2025-01-31 17:03:17 +01:00
2025-09-02 16:08:38 +02:00
2025-08-08 07:37:33 +10:00
2025-01-31 17:03:17 +01:00
2025-09-29 14:47:22 +02:00
2025-07-09 20:59:26 +02:00
2025-07-26 12:33:15 +00:00
2025-10-08 15:05:20 +11:00
2025-07-17 09:09:16 +02:00
2025-07-08 12:11:42 +02:00
2024-11-19 14:28:01 +01:00
2025-01-14 19:55:11 +01:00
2025-07-17 09:09:16 +02:00
2024-11-19 14:28:01 +01:00
2025-10-08 19:26:12 +02:00
2025-08-04 16:04:04 +02:00
2025-09-10 11:29:43 +02:00
2025-10-02 12:55:42 -04:00
2025-10-16 17:45:26 +02:00
2025-07-30 14:22:06 +10:00
2025-07-10 22:18:06 +02:00
2025-09-12 10:19:56 +10:00
2025-07-01 16:30:00 +02:00
2025-03-05 16:35:09 +01:00
2025-10-02 12:55:42 -04:00
2025-10-16 17:45:26 +02:00
2025-10-16 17:45:26 +02:00
2025-10-02 16:26:03 +02:00
2025-09-12 06:29:42 +00:00
2025-09-12 06:29:42 +00:00
2025-09-12 06:29:42 +00:00
2025-10-15 07:46:58 +00:00
2025-10-15 07:46:58 +00:00
2025-09-23 12:10:28 +02:00
2025-09-08 14:09:21 +02:00
2025-09-25 22:58:11 +02:00
2025-09-22 19:06:32 +02:00
2025-08-11 21:18:38 +02:00
2025-01-31 17:03:17 +01:00
2025-08-01 21:41:24 +10:00
2025-09-25 23:27:14 +02:00
2025-03-27 22:07:50 +01:00
2025-10-16 17:45:26 +02:00
2025-09-29 18:47:51 +02:00
2025-09-05 16:25:32 +02:00
2025-01-31 17:03:17 +01:00
2025-10-02 12:55:42 -04:00
2025-09-12 06:29:42 +00:00
2025-03-20 11:25:19 +01:00
2025-07-10 16:17:05 +02:00
2025-09-08 14:09:21 +02:00
2025-09-25 18:04:14 +02:00
2025-10-08 17:16:23 +02:00
2025-10-08 17:16:23 +02:00
2025-09-26 10:53:40 +02:00
2025-01-31 17:03:17 +01:00
2025-01-31 17:03:17 +01:00
2025-06-19 16:39:20 +02:00
2025-10-09 14:36:34 +02:00
2024-11-02 17:27:09 +11:00
2025-07-09 20:59:26 +02:00
2025-10-12 12:12:46 +11:00
2025-10-01 15:05:16 +02:00
2025-07-09 20:59:26 +02:00
2025-10-01 15:05:16 +02:00
2025-09-22 18:02:32 +02:00
2025-10-16 19:19:40 +02:00
2025-10-01 23:22:44 +00:00
2025-10-16 17:45:26 +02:00
2025-09-05 19:03:32 +02:00
2025-09-05 19:03:32 +02:00
2025-03-20 11:25:19 +01:00
2025-01-14 16:26:54 +01:00
2025-07-09 20:59:26 +02:00
2025-05-09 16:13:25 +02:00
2025-09-26 10:53:40 +02:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-09-05 19:03:32 +02:00
2025-10-16 17:45:26 +02:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-09-29 18:47:51 +02:00
2025-10-15 16:14:19 +02:00
2025-09-03 16:17:49 +02:00
2025-08-04 15:34:18 -04:00
2025-01-31 17:03:17 +01:00
2025-10-02 12:55:42 -04:00
2025-01-28 15:27:34 +01:00
2025-07-17 02:24:09 +02:00
2025-10-13 15:38:26 +02:00
2025-10-02 12:55:42 -04:00
2025-08-27 17:44:08 +02:00
2025-10-02 12:55:42 -04:00
2025-10-03 01:57:51 +02:00
2025-10-02 12:55:42 -04:00
2025-10-13 15:38:26 +02:00
2025-10-16 19:55:24 +02:00
2025-01-28 15:27:34 +01:00
2025-07-25 18:12:08 -04:00
2025-10-02 12:55:42 -04:00
2025-07-17 09:09:16 +02:00
2025-10-16 19:55:24 +02:00
2025-08-06 15:52:47 +02:00
2025-10-16 17:16:05 +02:00
2025-08-22 17:59:27 +02:00
2025-09-25 22:58:09 +02:00
2025-06-16 23:42:05 +02:00
2025-09-06 23:55:16 +02:00
2025-07-15 00:01:12 +02:00
2025-09-06 23:55:16 +02:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-07-15 00:01:12 +02:00
2025-08-27 01:39:23 +02:00
2025-10-09 21:16:13 +02:00
2025-01-28 15:27:34 +01:00
2025-10-02 12:55:42 -04:00
2025-07-10 16:17:05 +02:00
2025-08-22 17:15:06 +02:00
2025-10-02 12:55:42 -04:00
2025-01-31 17:03:17 +01:00
2025-09-29 11:07:03 +02:00
2025-01-28 15:27:34 +01:00
2025-10-07 10:46:59 +02:00
2025-08-13 15:43:37 +02:00
2025-03-23 13:34:07 +01:00
2025-06-02 13:50:07 +02:00
2025-10-15 16:54:08 +02:00
2025-08-02 10:17:39 +02:00
2025-10-03 13:56:38 +02:00
2025-10-09 11:02:00 +02:00
2025-09-30 10:49:20 +02:00
2025-10-12 16:33:50 +02:00
2025-10-07 19:59:36 +02:00
2025-10-02 12:55:42 -04:00
2025-07-16 18:26:26 +02:00
2025-10-07 19:59:36 +02:00
2025-02-13 18:58:08 +01:00
2025-08-12 21:26:38 +02:00
2025-05-08 15:37:28 +02:00
2025-01-28 15:27:34 +01:00
2025-10-16 17:16:05 +02:00
2025-02-12 23:01:08 +01:00
2025-07-07 16:53:12 +02:00
2025-10-13 15:38:26 +02:00
2025-01-31 17:03:17 +01:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-07-22 14:47:56 +02:00
2025-08-07 06:26:50 +10:00
2025-07-09 20:59:26 +02:00
2024-11-01 17:27:07 +01:00
2025-01-31 17:03:17 +01:00
2025-01-07 12:39:13 +01:00
2025-05-23 15:34:26 +02:00
2025-05-23 15:34:26 +02:00
2025-04-25 21:47:08 +02:00
2025-09-11 01:20:10 +02:00
2025-09-26 15:55:47 +02:00
2025-07-10 22:18:06 +02:00
2025-09-05 19:03:32 +02:00
2025-10-07 19:59:36 +02:00
2025-10-02 13:27:13 +02:00
2025-10-16 17:45:26 +02:00
2025-07-09 20:59:26 +02:00
2025-10-02 12:55:42 -04:00
2025-10-15 12:54:36 +02:00
2025-10-15 15:20:17 +02:00
2025-09-05 19:03:32 +02:00
2025-02-12 23:01:08 +01:00
2025-10-02 12:55:42 -04:00
2025-10-02 12:55:42 -04:00
2025-10-10 10:22:55 +02:00
2025-09-05 19:03:32 +02:00
2025-10-16 17:45:26 +02:00
2025-03-20 11:25:19 +01:00
2025-08-22 17:59:27 +02:00
2025-08-29 21:52:19 +02:00
2025-07-21 16:11:37 +02:00
2025-08-24 19:50:40 +10:00
2025-08-29 21:52:19 +02:00
2025-10-02 12:55:42 -04:00
2025-08-29 21:52:19 +02:00
2025-08-22 17:59:27 +02:00
2025-10-02 12:55:42 -04:00
2025-07-01 22:14:26 +02:00
2024-11-07 10:36:53 +01:00
2025-08-29 21:52:19 +02:00
2025-09-05 19:03:32 +02:00
2025-10-16 17:45:26 +02:00
2025-03-05 16:35:09 +01:00
2025-01-28 15:27:34 +01:00
2025-03-05 16:35:09 +01:00
2025-03-05 16:35:09 +01:00
2025-07-27 16:39:57 +10:00
2025-10-02 12:55:42 -04:00
2025-06-02 17:13:56 -04:00
2025-10-02 12:55:42 -04:00
2025-09-05 11:11:32 +02:00
2025-07-09 20:59:26 +02:00
2025-09-25 13:55:21 +10:00
2025-08-08 07:37:33 +10:00
2025-09-22 11:50:19 +02:00
2025-09-05 19:03:32 +02:00
2025-07-30 21:25:18 +02:00
2025-05-23 06:07:04 +02:00
2025-10-03 14:25:14 +02:00
2025-08-06 00:20:39 +00:00
2025-10-02 20:53:42 +02:00
2025-10-02 12:55:42 -04:00
2025-05-09 16:13:25 +02:00
2025-08-26 12:27:20 +02:00
2025-09-05 19:03:32 +02:00
2025-08-18 20:44:44 +02:00
2025-09-22 17:40:38 +02:00
2025-10-16 17:45:26 +02:00