mirror of
				https://github.com/GayPizzaSpecifications/voxelotl-engine.git
				synced 2025-11-04 10:59:39 +00:00 
			
		
		
		
	funny colours (world)
This commit is contained in:
		@ -10,4 +10,13 @@ public extension FloatingPoint {
 | 
			
		||||
 | 
			
		||||
  @inline(__always) func smoothStep() -> Self { self * self * (3 - 2 * self) }
 | 
			
		||||
  @inline(__always) func smootherStep() -> Self { self * self * self * (self * (self * 6 - 15) + 10) }
 | 
			
		||||
 | 
			
		||||
  @inline(__always) func euclidianMod(_ divisor: Self) -> Self { self.floorMod(abs(divisor)) }
 | 
			
		||||
  @inline(__always) func floorMod(_ divisor: Self) -> Self {
 | 
			
		||||
    //fmod(fmod(self, divisor) + divisor, divisor)
 | 
			
		||||
    (self.truncateMod(divisor) + divisor).truncateMod(divisor)
 | 
			
		||||
  }
 | 
			
		||||
  @inline(__always) func truncateMod(_ divisor: Self) -> Self {
 | 
			
		||||
    self.truncatingRemainder(dividingBy: divisor)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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