Mercurial > games > semicongine
changeset 1316:544709f64ac4
add: floorDiv for vec/vec operations
author | sam <sam@basx.dev> |
---|---|
date | Mon, 12 Aug 2024 17:52:29 +0700 |
parents | 27395a38d882 |
children | c5a23e910fea |
files | semicongine/core/vector.nim |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/core/vector.nim Sun Aug 11 19:24:47 2024 +0700 +++ b/semicongine/core/vector.nim Mon Aug 12 17:52:29 2024 +0700 @@ -237,8 +237,7 @@ func `/`*[T: SomeFloat](a: SomeFloat, b: TVec2[T]): auto = TVec2([a / b[0], a / b[1]]) func `/`*[T: SomeInteger](a: SomeInteger, b: TVec3[T]): auto = TVec3([a div b[0], a div b[1], a div b[2]]) func `/`*[T: SomeFloat](a: SomeFloat, b: TVec3[T]): auto = TVec3([a / b[0], a / b[1], a / b[2]]) -func `/`*[T: SomeInteger](a: SomeInteger, b: TVec4[T]): auto = TVec4([a div b[ - 0], a div b[1], a div b[2], a div b[3]]) +func `/`*[T: SomeInteger](a: SomeInteger, b: TVec4[T]): auto = TVec4([a div b[0], a div b[1], a div b[2], a div b[3]]) func `/`*[T: SomeFloat](a: SomeFloat, b: TVec4[T]): auto = TVec4([a / b[0], a / b[1], a / b[2], a / b[3]]) @@ -260,15 +259,19 @@ func `*`*(a, b: TVec3): auto = TVec3([a[0] * b[0], a[1] * b[1], a[2] * b[2]]) func `*`*(a, b: TVec4): auto = TVec4([a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]]) func `div`*[T: SomeInteger](a, b: TVec1[T]): auto = TVec1([a[0] div b[0]]) +func `floorDiv`*[T: SomeInteger](a, b: TVec1[T]): auto = TVec1([floorDiv(a[0], b[0])]) func `/`*[T: SomeInteger](a, b: TVec1[T]): auto = TVec1([a[0] / b[0]]) func `/`*[T: SomeFloat](a, b: TVec1[T]): auto = TVec1([a[0] / b[0]]) func `div`*[T: SomeInteger](a, b: TVec2[T]): auto = TVec2([a[0] div b[0], a[1] div b[1]]) +func `floorDiv`*[T: SomeInteger](a, b: TVec2[T]): auto = TVec2([floorDiv(a[0], b[0]), floorDiv(a[1], b[1])]) func `/`*[T: SomeInteger](a, b: TVec2[T]): auto = TVec2([a[0] / b[0], a[1] / b[1]]) func `/`*[T: SomeFloat](a, b: TVec2[T]): auto = TVec2([a[0] / b[0], a[1] / b[1]]) func `div`*[T: SomeInteger](a, b: TVec3[T]): auto = TVec3([a[0] div b[0], a[1] div b[1], a[2] div b[2]]) +func `floorDiv`*[T: SomeInteger](a, b: TVec3[T]): auto = TVec3([floorDiv(a[0], b[0]), floorDiv(a[1], b[1]), floorDiv(a[2], b[2])]) func `/`*[T: SomeInteger](a, b: TVec3[T]): auto = TVec3([a[0] / b[0], a[1] / b[1], a[2] / b[2]]) func `/`*[T: SomeFloat](a, b: TVec3[T]): auto = TVec3([a[0] / b[0], a[1] / b[1], a[2] / b[2]]) func `div`*[T: SomeInteger](a, b: TVec4[T]): auto = TVec4([a[0] div b[0], a[1] div b[1], a[2] div b[2], a[3] div b[3]]) +func `floorDiv`*[T: SomeInteger](a, b: TVec4[T]): auto = TVec4([floorDiv(a[0], b[0]), floorDiv(a[1], b[1]), floorDiv(a[2], b[2]), floorDiv(a[3], b[3])]) func `/`*[T: SomeInteger](a, b: TVec4[T]): auto = TVec4([a[0] / b[0], a[1] / b[1], a[2] / b[2], a[3] / b[3]]) func `/`*[T: SomeFloat](a, b: TVec4[T]): auto = TVec4([a[0] / b[0], a[1] / b[1], a[2] / b[2], a[3] / b[3]])