Converting vector-backed float columns to Vec3x4?
Opened this issue · 1 comments
Apologies if this is covered in the docs somewhere, I wasn't able to find anything about best practices on this.
Is there a helper function, or some guidance on the best way to store floats in columns, e.g.
struct Entities {
pos_x: Vec<f32>,
pos_y: Vec<f32>,
pos_z: Vec<f32>,
}
but convert them into Vec3x4
chunks (with some possible remaining Vec3
s) for processing?
I'm guessing some use of chunks_exact
and remainder
would work here -- iterate each column in chunks of 4, get an f32x4
from each chunk (is there an easy conversion for this?), convert the three zipped f32x4
s into a Vec3x4
, perform operations, and then break it all apart again to store the result, with some special cases for the remaining <4 f32
s into a regular Vec3
. Is this ever done in practice? Is it worth it? It would be nice to preserve the ability to easily access a single entity's (x, y, z)
from those columns.
Not really. I'm not sure what the best way is and I'm not sure that it would be worth it, either. Lots of random-ish memory access and copying to do this. If you want to process with Vec3x4 then should just store as pos: Vec<Vec3x4>
probably. But I haven't measured, either