# HG changeset patch # User sam # Date 1722929519 -25200 # Node ID 4403569112b51ad9b8f70e477fffbde6a9f47403 # Parent da3bbd587fe10b85ba37ebcd8d3d1e4669fd1ecc add: better support for integer divison diff -r da3bbd587fe1 -r 4403569112b5 semicongine/core/vector.nim --- a/semicongine/core/vector.nim Tue Aug 06 14:06:51 2024 +0700 +++ b/semicongine/core/vector.nim Tue Aug 06 14:31:59 2024 +0700 @@ -180,14 +180,14 @@ func `*`*(a: TVec3, b: SomeNumber): auto = TVec3([a[0] * b, a[1] * b, a[2] * b]) func `*`*(a: TVec4, b: SomeNumber): auto = TVec4([a[0] * b, a[1] * b, a[2] * b, a[3] * b]) -func `/`*[T: SomeInteger](a: TVec1[T], b: SomeInteger): auto = TVec1([a[0] div b]) -func `/`*[T: SomeFloat](a: TVec1[T], b: SomeFloat): auto = TVec1([a[0] / b]) -func `/`*[T: SomeInteger](a: TVec2[T], b: SomeInteger): auto = TVec2([a[0] div b, a[1] div b]) -func `/`*[T: SomeFloat](a: TVec2[T], b: SomeFloat): auto = TVec2([a[0] / b, a[1] / b]) -func `/`*[T: SomeInteger](a: TVec3[T], b: SomeInteger): auto = TVec3([a[0] div b, a[1] div b, a[2] div b]) -func `/`*[T: SomeFloat](a: TVec3[T], b: SomeFloat): auto = TVec3([a[0] / b, a[1] / b, a[2] / b]) -func `/`*[T: SomeInteger](a: TVec4[T], b: SomeInteger): auto = TVec4([a[0] div b, a[1] div b, a[2] div b, a[3] div b]) -func `/`*[T: SomeFloat](a: TVec4[T], b: SomeFloat): auto = TVec4([a[0] / b, a[1] / b, a[2] / b, a[3] / b]) +func `div`*[T, S: SomeInteger](a: TVec1[T], b: S): auto = TVec1[T]([a[0] div T(b)]) +func `/`*[T, S: SomeFloat](a: TVec1[T], b: S): auto = TVec1[T]([a[0] / T(b)]) +func `div`*[T, S: SomeInteger](a: TVec2[T], b: S): auto = TVec2([a[0] div T(b), a[1] div T(b)]) +func `/`*[T, S: SomeFloat](a: TVec2[T], b: S): auto = TVec2[T]([a[0] / T(b), a[1] / T(b)]) +func `div`*[T, S: SomeInteger](a: TVec3[T], b: S): auto = TVec3([a[0] div T(b), a[1] div T(b), a[2] div T(b)]) +func `/`*[T, S: SomeFloat](a: TVec3[T], b: S): auto = TVec3[T]([a[0] / T(b), a[1] / T(b), a[2] / T(b)]) +func `div`*[T, S: SomeInteger](a: TVec4[T], b: S): auto = TVec4([a[0] div T(b), a[1] div T(b), a[2] div T(b), a[3] div T(b)]) +func `/`*[T, S: SomeFloat](a: TVec4[T], b: S): auto = TVec4[T]([a[0] / T(b), a[1] / T(b), a[2] / T(b), a[3] / T(b)]) func `+`*(a: SomeNumber, b: TVec1): auto = TVec1([a + b[0]]) func `+`*(a: SomeNumber, b: TVec2): auto = TVec2([a + b[0], a + b[1]])