44 lines
1.3 KiB
Odin
44 lines
1.3 KiB
Odin
package main
|
|
|
|
import "libraries/fixed_pool"
|
|
|
|
Field :: struct($T: typeid) {
|
|
value: f32,
|
|
input: FieldInput,
|
|
}
|
|
|
|
FIELD_BYTE_COUNT :: 32
|
|
FieldInput :: [FIELD_BYTE_COUNT]byte
|
|
FieldPool :: struct($T: typeid) {
|
|
values: fixed_pool.Pool(T),
|
|
inputs: fixed_pool.Pool(FieldInput),
|
|
}
|
|
|
|
field_input_as_cstring :: proc(field_input: ^FieldInput) -> cstring {
|
|
return cstring(&field_input[0])
|
|
}
|
|
|
|
field_pool_get :: proc(pool: ^FieldPool($T), count: int) -> (values: []T, inputs: []FieldInput) {
|
|
return fixed_pool.get(&pool.values, count), fixed_pool.get(&pool.inputs, count)
|
|
}
|
|
|
|
field_pool_clear :: proc(pool: ^FieldPool($T)) {
|
|
fixed_pool.clear(&pool.values)
|
|
fixed_pool.clear(&pool.inputs)
|
|
}
|
|
|
|
field_pool_init :: proc(pool: ^FieldPool($T), capacity: int, allocator := context.allocator) {
|
|
fixed_pool.init(&pool.values, capacity, allocator)
|
|
fixed_pool.init(&pool.inputs, capacity, allocator)
|
|
}
|
|
|
|
field_pool_free_range :: proc(pool: ^FieldPool($T), from: int, count: int) {
|
|
fixed_pool.free_range(&pool.values, from, count)
|
|
fixed_pool.free_range(&pool.inputs, from, count)
|
|
}
|
|
|
|
field_pool_get_allocated_elems :: proc(pool: ^FieldPool($T)) -> #soa[]Field(T) {
|
|
values := fixed_pool.get_allocated_elems(pool.values)
|
|
fields := fixed_pool.get_allocated_elems(pool.inputs)
|
|
return soa_zip(value = values, input = fields)
|
|
}
|