mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
funny colours (world)
This commit is contained in:
12
Sources/Voxelotl/Math/IntegerExtensions.swift
Normal file
12
Sources/Voxelotl/Math/IntegerExtensions.swift
Normal file
@ -0,0 +1,12 @@
|
||||
public extension BinaryInteger {
|
||||
@inline(__always) func euclidianMod(_ divisor: Self) -> Self {
|
||||
self.floorMod(divisor < 0 ? divisor * -1 : divisor)
|
||||
}
|
||||
@inline(__always) func floorMod(_ divisor: Self) -> Self {
|
||||
//(self % divisor + divisor) % divisor
|
||||
(self.truncateMod(divisor) + divisor).truncateMod(divisor)
|
||||
}
|
||||
@inline(__always) func truncateMod(_ divisor: Self) -> Self {
|
||||
self.quotientAndRemainder(dividingBy: divisor).remainder
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user