# HG changeset patch # User sam # Date 1722790357 -25200 # Node ID 9ff18be62a1eb26289d3ebca6160a28f23e34537 # Parent b94b648df33c7299739da2c5eb40d500e5d1f745 add: some more vector helpers diff -r b94b648df33c -r 9ff18be62a1e semicongine/core/vector.nim --- a/semicongine/core/vector.nim Sun Aug 04 20:50:38 2024 +0700 +++ b/semicongine/core/vector.nim Sun Aug 04 23:52:37 2024 +0700 @@ -96,12 +96,25 @@ R* = vec4(1, 0, 0, 1) G* = vec4(1, 0, 0, 1) B* = vec4(1, 0, 0, 1) + Xi* = vec3i(1, 0, 0) + Yi* = vec3i(0, 1, 0) + Zi* = vec3i(0, 0, 1) func to*[T](v: TVec1): auto = TVec1([T(v[0])]) func to*[T](v: TVec2): auto = TVec2([T(v[0]), T(v[1])]) func to*[T](v: TVec3): auto = TVec3([T(v[0]), T(v[1]), T(v[2])]) func to*[T](v: TVec4): auto = TVec4([T(v[0]), T(v[1]), T(v[2]), T(v[3])]) +func f32*(v: TVec1): auto = to[float32](v) +func f32*(v: TVec2): auto = to[float32](v) +func f32*(v: TVec3): auto = to[float32](v) +func f32*(v: TVec4): auto = to[float32](v) + +func i32*(v: TVec1): auto = to[int32](v) +func i32*(v: TVec2): auto = to[int32](v) +func i32*(v: TVec3): auto = to[int32](v) +func i32*(v: TVec4): auto = to[int32](v) + func toVecString[T: TVec](value: T): string = var items: seq[string] for item in value: