Does anybody know about an automatic SOA-builder library in Nim? Ideally I would like something like this:

type
  Thing[T] = object
    position: Vec3d[T]
    orientation: Quaternion[T]
  
  ThingArrAos[N: static[int], T] = array[N, Thing[T]]
  ThingArrSoa[N: static[int], T] = arraySoa[N, Thing[T]]

...

let a = newGridArrAos(Thing(...), 4)
# in memory: Vec3d[T], Quaternion[T], Vec3d[T], Quaternion[T], Vec3d[T], Quaternion[T], Vec3d[T], Quaternion[T]

let s = newGridArrSoa(Thing(...), 4)
# in memory: Vec3d[T], Vec3d[T], Vec3d[T], Vec3d[T], Quaternion[T], Quaternion[T], Quaternion[T], Quaternion[T]

Of course things like:

# generates ThingArrSoa type
defSoa type ThingArrSoa[N: static[int], T] = arraySoa[N, Thing[T]]

# generates array, dynamic array (casual seq is a little pointless) and similar types (handy!)
defSoa Thing[T]
Would ok too.

2017-09-08 20:08:55
Not exactly what you want but there is a port of GLM to Nim: https://github.com/stavenko/nim-glm
2017-09-08 21:13:56