mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 13:11:33 +00:00
organise maths helpers
This commit is contained in:
@ -1,33 +1,40 @@
|
|||||||
add_executable(Voxelotl MACOSX_BUNDLE
|
add_executable(Voxelotl MACOSX_BUNDLE
|
||||||
|
# Resources
|
||||||
Assets.xcassets
|
Assets.xcassets
|
||||||
|
|
||||||
test.png
|
test.png
|
||||||
|
|
||||||
|
# Shaders
|
||||||
shadertypes.h
|
shadertypes.h
|
||||||
shader.metal
|
shader.metal
|
||||||
|
|
||||||
FloatExtensions.swift
|
# Maths library
|
||||||
Matrix4x4.swift
|
Math/FloatExtensions.swift
|
||||||
Rectangle.swift
|
Math/VectorExtensions.swift
|
||||||
AABB.swift
|
Math/Matrix4x4.swift
|
||||||
Color.swift
|
Math/Rectangle.swift
|
||||||
|
Math/AABB.swift
|
||||||
|
|
||||||
|
# Random number generator subsystem
|
||||||
Random/RandomProvider.swift
|
Random/RandomProvider.swift
|
||||||
Random/RandomRange.swift
|
Random/RandomRange.swift
|
||||||
Random/Arc4Random.swift
|
Random/Arc4Random.swift
|
||||||
Random/DarwinRandom.swift
|
Random/DarwinRandom.swift
|
||||||
|
|
||||||
|
# Resource classes
|
||||||
NSImageLoader.swift
|
NSImageLoader.swift
|
||||||
|
|
||||||
|
# Core utility classes
|
||||||
|
Color.swift
|
||||||
|
Camera.swift
|
||||||
Renderer.swift
|
Renderer.swift
|
||||||
GameController.swift
|
GameController.swift
|
||||||
FPSCalculator.swift
|
FPSCalculator.swift
|
||||||
|
|
||||||
Chunk.swift
|
|
||||||
Camera.swift
|
|
||||||
Player.swift
|
|
||||||
GameDelegate.swift
|
GameDelegate.swift
|
||||||
Application.swift
|
Application.swift
|
||||||
|
|
||||||
|
# Game logic classes
|
||||||
|
Chunk.swift
|
||||||
|
Player.swift
|
||||||
Game.swift
|
Game.swift
|
||||||
|
|
||||||
main.swift)
|
main.swift)
|
||||||
@ -64,6 +71,8 @@ set_source_files_properties(Assets.xcassets PROPERTIES MACOSX_PACKAGE_LOCATION R
|
|||||||
set_source_files_properties(module.modulemap PROPERTIES MACOSX_PACKAGE_LOCATION Modules)
|
set_source_files_properties(module.modulemap PROPERTIES MACOSX_PACKAGE_LOCATION Modules)
|
||||||
set_source_files_properties(test.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
set_source_files_properties(test.png PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||||
|
|
||||||
|
#TODO: should use TREE mode as documented in https://cmake.org/cmake/help/latest/command/source_group.html
|
||||||
source_group("Resources" FILES Assets.xcassets test.png)
|
source_group("Resources" FILES Assets.xcassets test.png)
|
||||||
source_group("Source Files" REGULAR_EXPRESSION "\\.(swift|metal)$")
|
source_group("Source Files" REGULAR_EXPRESSION "\\.(swift|metal)$")
|
||||||
source_group("Source Files\\Random" REGULAR_EXPRESSION "Random/")
|
source_group("Source Files\\Random" REGULAR_EXPRESSION "Random/")
|
||||||
|
source_group("Source Files\\Math" REGULAR_EXPRESSION "Math/")
|
||||||
|
10
Sources/Voxelotl/Math/FloatExtensions.swift
Normal file
10
Sources/Voxelotl/Math/FloatExtensions.swift
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
public extension FloatingPoint {
|
||||||
|
@inline(__always) var degrees: Self { self * (180 / Self.pi) }
|
||||||
|
@inline(__always) var radians: Self { self * (Self.pi / 180) }
|
||||||
|
|
||||||
|
@inline(__always) func lerp(_ a: Self, _ b: Self) -> Self { b * self + a * (1 - self) }
|
||||||
|
@inline(__always) func mlerp(_ a: Self, _ b: Self) -> Self { a + (b - a) * self }
|
||||||
|
|
||||||
|
@inline(__always) func clamp(_ a: Self, _ b: Self) -> Self { min(max(self, a), b) }
|
||||||
|
@inline(__always) var saturated: Self { self.clamp(0, 1) }
|
||||||
|
}
|
@ -1,14 +1,3 @@
|
|||||||
public extension FloatingPoint {
|
|
||||||
@inline(__always) var degrees: Self { self * (180 / Self.pi) }
|
|
||||||
@inline(__always) var radians: Self { self * (Self.pi / 180) }
|
|
||||||
|
|
||||||
@inline(__always) func lerp(_ a: Self, _ b: Self) -> Self { b * self + a * (1 - self) }
|
|
||||||
@inline(__always) func mlerp(_ a: Self, _ b: Self) -> Self { a + (b - a) * self }
|
|
||||||
|
|
||||||
@inline(__always) func clamp(_ a: Self, _ b: Self) -> Self { min(max(self, a), b) }
|
|
||||||
@inline(__always) var saturated: Self { self.clamp(0, 1) }
|
|
||||||
}
|
|
||||||
|
|
||||||
extension SIMD3 where Scalar: FloatingPoint {
|
extension SIMD3 where Scalar: FloatingPoint {
|
||||||
@inline(__always) static var X: Self { Self(1, 0, 0) }
|
@inline(__always) static var X: Self { Self(1, 0, 0) }
|
||||||
@inline(__always) static var Y: Self { Self(0, 1, 0) }
|
@inline(__always) static var Y: Self { Self(0, 1, 0) }
|
Reference in New Issue
Block a user