changeset 1297:4403569112b5

add: better support for integer divison
author sam <sam@basx.dev>
date Tue, 06 Aug 2024 14:31:59 +0700
parents da3bbd587fe1
children 1feaa8a97acf
files semicongine/core/vector.nim
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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]])