Mesh: Calculate edges with VectorSet instead of Map
commit6bafe65d289cb61f3897e848dcfe01dff28ea4ea
authorIliya Katueshenock <modormoder@gmail.com>
Thu, 11 Apr 2024 02:33:25 +0000 (11 04:33 +0200)
committerHans Goudey <hooglyboogly@noreply.localhost>
Thu, 11 Apr 2024 02:33:25 +0000 (11 04:33 +0200)
treea611c16dbf5a1c68645d7edceafd0cbfa96fb15b
parent7642a5452a99c4ba7deae51fbeb1c0ce6386643b
Mesh: Calculate edges with VectorSet instead of Map

Due to legacy reasons (`MEdge`), edge calculation was being done with
idea that edges cannot be temporarily copied. But today, edges are just
`int2`, so using `edge *` instead of `edge` actually made things worse.
And since `OrderedEdge` itself is the same thing as `int2`, it does not
make sense to use `Map` for edges. So, now edges are in a hash set.
To be able to take index of edges, `VectorSet` is used.

The only functional change now is that original edges will be reordered
as well. This should be okay just like an unintentional but stable
indices change.

For 2'000 x 2'000 x 2'000 cube edges calculation, change is around
`3703.47` -> `2911.18` ms.

In order to reduce memory usage, a template parameter is added to
`VectorSet` slots, so they can use a 32 instead of 64 bit index type.
Without that, the performance change is not consistent and might not be
better on a computer with more memory bandwidth.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/120224
source/blender/blenkernel/intern/mesh_calc_edges.cc
source/blender/blenlib/BLI_vector_set_slots.hh
tests/data