break up gameplay stuff

This commit is contained in:
2024-08-13 08:38:21 +10:00
parent 5b97a02288
commit dc88042a36
13 changed files with 448 additions and 132 deletions

View File

@ -68,20 +68,20 @@ public extension simd_float4x4 {
let x = 2 * invWidth, y = 2 * invHeight, z = invDepth
return .init(
.init( x, 0, 0, 0),
.init( 0, y, 0, 0),
.init( 0, 0, z, 0),
.init(tx, ty, tz, 1))
.init( x, 0, 0, 0),
.init( 0, y, 0, 0),
.init( 0, 0, z, 0),
.init(tx, ty, tz, 1))
}
static func perspective(verticalFov fovY: T, aspect: T, near: T, far: T) -> Self {
static func perspective(verticalFov fovY: T, aspect: T, near zNear: T, far zFar: T) -> Self {
let tanHalfFovY = tan(fovY * T(0.5))
let invClipRange = 1 / (near - far)
let invClipRange = 1 / (zNear - zFar)
let y = 1 / tanHalfFovY
let x = y / aspect
let z = far * invClipRange
let w = near * z // (far * near) * invClipRange
let z = zFar * invClipRange
let w = zNear * z
return .init(
.init(x, 0, 0, 0),
.init(0, y, 0, 0),
@ -89,3 +89,7 @@ public extension simd_float4x4 {
.init(0, 0, w, 0))
}
}
extension simd_quatf {
static var identity: Self { .init(real: 1, imag: .zero) }
}