treeform/vmath

lookAt broken on any generic type that's not made of float32

heysokam opened this issue · 2 comments

There is a typo in this line:

return mat4[T]()

It should be GMat4[T]() or gmat4[T](), but not mat4[T]()
There is no proc mat4[T]() :GMat4[T]= .... at all, so this is trying resolve as a float32 with mat4() instead, and therefore breaks for every other type that's not based on f32

Minimal reproduction example:

import vmath

when on:
  let pos :GVec3[float]= gvec3[float](0'f, 0, 0)
  let dir :GVec3[float]= gvec3[float](1'f, 1, 1)
  let up  :GVec3[float]= gvec3[float](0'f, 1, 0)
else:
  let pos :GVec3[float32]= gvec3[float32](0'f, 0, 0)
  let dir :GVec3[float32]= gvec3[float32](1'f, 1, 1)
  let up  :GVec3[float32]= gvec3[float32](0'f, 1, 0)

let rot = pos.lookAt(dir, up)
echo rot

You are right, i'll fix it.

I think this has been merged and fixed. Feel free to reopen if you still have issues.