Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting vector-backed float columns to Vec3x4? #147

Open
recatek opened this issue Jul 8, 2022 · 1 comment
Open

Converting vector-backed float columns to Vec3x4? #147

recatek opened this issue Jul 8, 2022 · 1 comment

Comments

@recatek
Copy link

recatek commented Jul 8, 2022

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 Vec3s) 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 f32x4s into a Vec3x4, perform operations, and then break it all apart again to store the result, with some special cases for the remaining <4 f32s 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.

@fu5ha
Copy link
Owner

fu5ha commented Jul 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants