diff options
| author | steven-na <noreply.github@stvnc.dev> | 2026-08-06 02:36:01 -0700 |
|---|---|---|
| committer | steven-na <noreply.github@stvnc.dev> | 2026-08-06 02:36:01 -0700 |
| commit | 5d575f8cd99e9bc064b3d998f17b194a818e3546 (patch) | |
| tree | 8a8e1485dda924aeefb5428e26dbcca74f74721e /src/vec2sw.c | |
| parent | d07b96b9914e706630dc1d2807ecfa9e104945d5 (diff) | |
Sliding window array implementation
Diffstat (limited to 'src/vec2sw.c')
| -rw-r--r-- | src/vec2sw.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/vec2sw.c b/src/vec2sw.c new file mode 100644 index 0000000..0e1aec0 --- /dev/null +++ b/src/vec2sw.c @@ -0,0 +1,23 @@ +#include "vec2sw.h" +#include "slidingwindow.h" +#include "vec2.h" + +vec2d_sw_soa_t vec2d_sw_soa(smrt_arena_t *arena, u64 size) { + vec2d_sw_soa_t vs = { .size=size }; + vs.xs = SMRTA_ALLOC_SLIDINGWINDOW(arena, f64, size); + vs.ys = SMRTA_ALLOC_SLIDINGWINDOW(arena, f64, size); + return vs; +} + +void vec2d_sw_soa_insert(vec2d_sw_soa_t sw_vs, vec2d_t v) { + sw_insert(sw_vs.xs, (void*)&v.x); + sw_insert(sw_vs.ys, (void*)&v.y); +} + +vec2d_soa_t vec2d_sw_soa_get(vec2d_sw_soa_t sw_vs) { + return (vec2d_soa_t){ + .size = sw_vs.xs->num_elements, + .xs = SLIDINGWINDOW_GET(sw_vs.xs, f64), + .ys = SLIDINGWINDOW_GET(sw_vs.ys, f64), + }; +} |