Files
test2/source/blender/geometry
Hans Goudey f41dc90925 Mesh: Rewrite split edges algorithm
The new split edges code from e83f46ea76 started the use of
Mesh rather than BMesh as a performance improvement. However, the code
contained a complex loop used for de-duplicating edges that gave invalid
indices in some circumstances. That was fixed by b226c115e2,
but in turn that commit caused loose edges to be skipped. That was
fixed by 111e378366, however that caused another crash.

Long story short, the code is quite complex and the existing algorithm,
while an improvement from the original, is fiddly. For example, instead
of working with just the input and output states, it adjusted topology
data for an intermediate state halfway through the change.

Fixes #109236

**Goals**
- Only use topology maps from the input mesh. This should work better
  with future topology caching improvements (See !107816).
- Run de-duplication in a per-edge context to allow parallelization.
- Optimize for real world use cases when there is merging of new edges.
- Improve readability by making each step's inputs clear, improving naming,
  and separating functions.
- Improve handling of loose edges.
- Reuse existing edges for the first new split edges, simplifying
  edge attribute propagation.

**Timing**
I tested performance with a Ryzen 7950x and a grid with 4 million faces
with different random portions of the mesh selected.

| Selection | Before (ms) | After (ms) | Change |
| --------- | ----------- | ---------- | ------ |
| 100%      | 1869.4      | 351.8      | 5.3x  |
| 50%       | 1636.0      | 356.0      | 4.6x  |
| 10%       | 1148.8      | 238.2      | 4.8x  |

| 4 Million Face Grid             | 10%  | 50%  | 100% |
| ------------------------------- | ---- | ---- | ---- |
| `vert_selection_from_edge`      | 2.7  | 4.1  | 4.3  |
| `selection_to_bit_vector`       | 0.7  | 3.9  | 0.2  |
| `vert_to_corner_map`            | 22.3 | 22.5 | 22.4 |
| `edge_to_corner_map`            | 47.7 | 47.6 | 47.6 |
| `corner_to_face_map`            | 3.3  | 3.3  | 3.3  |
| `calc_all_corner_groups`        | 21.0 | 44.1 | 38.3 |
| `calc_vert_ranges_per_old_vert` | 3.0  | 7.4  | 7.9  |
| `update_corner_verts`           | 2.8  | 12.7 | 15.5 |
| `calc_new_edges`                | 28.8 | 44.1 | 35.5 |
| `update_unselected_edges`       | 9.8  | 9.3  | 0.0  |
| `propagate_edge_attributes`     | 35.7 | 51.3 | 61.7 |
| `propagate_vert_attributes`     | 24.0 | 27.0 | 31.7 |
| `propagate_vert_attributes`     | 24.2 | 29.7 | 36.9 |

**Tests**
New regression tests have been committed separately. Existing
tests were updated since the new code gives different indices.
2023-08-30 14:23:42 +02:00
..