Mesh: Optimize vertex to edge attribute domain interpolation

Instead of using `DefaultMixer`, use the simpler `mix2` function.
This just decreases the overhead of computing each value.
In a simple test storing an attribute with the position of each
edge, I observed a 1.7x performance improvement: a change from
16 ms to ~9ms for an 8 million edge mesh.

Resolves #133196.
This commit is contained in:
Hans Goudey
2025-02-12 11:48:17 -05:00
parent 83ec62f6c4
commit 33db2d372f

View File

@@ -414,13 +414,8 @@ static GVArray adapt_mesh_domain_point_to_edge(const Mesh &mesh, const GVArray &
else {
new_varray = VArray<T>::ForFunc(
edges.size(), [edges, varray = varray.typed<T>()](const int edge_index) {
T return_value;
attribute_math::DefaultMixer<T> mixer({&return_value, 1});
const int2 &edge = edges[edge_index];
mixer.mix_in(0, varray[edge[0]]);
mixer.mix_in(0, varray[edge[1]]);
mixer.finalize();
return return_value;
return attribute_math::mix2(0.5f, varray[edge[0]], varray[edge[1]]);
});
}
}