# HG changeset patch # User sam # Date 1723459949 -25200 # Node ID 544709f64ac4f82400bc5b7039e41abee0d010d9 # Parent 27395a38d882e19a03fa76f90c0fd32c38ad17fb add: floorDiv for vec/vec operations diff -r 27395a38d882 -r 544709f64ac4 semicongine/core/vector.nim --- 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]])