Preparing to add matrices to the list
This commit is contained in:
parent
88dee75f7d
commit
4987f1b0d2
4 changed files with 127 additions and 82 deletions
44
field_pool.odin
Normal file
44
field_pool.odin
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue