The Skung Rockification of Ziggy Skungdust and the SIMD's

This commit is contained in:
2024-05-13 01:11:03 +10:00
parent b62cd056b5
commit 6c44476062
40 changed files with 2066 additions and 386 deletions

View File

@ -1,4 +1,6 @@
import JolkEngine
import Maths
protocol Actor
{

View File

@ -1,4 +1,5 @@
import SDL2
import Maths
import simd
import OpenGL.GL
import JolkEngine
@ -13,7 +14,19 @@ struct Colin: Actor
{
//.rotate(yaw: angle.x, pitch: angle.y, roll: sin(time)) *
//.scale(Vec3f(1.0 + 0.25 * cos(time), 1.0 + 0.25 * sin(time), 1.0)) *
.rotate(yawPitch: angle) * .translate(-position - Vec3f(0, 1, 0))
.rotate(yawPitch: angle)
//.rotate(x: angle.y) * .rotate(y: angle.x)
//.rotate(axis: .left, angle: angle.y) * .rotate(y: angle.x)
//.rotate(axis: .left, angle: angle.y) * .rotate(axis: .up, angle: angle.x)
//Mat4f(quat: Quatf(axis: .X, angle: angle.y) * Quatf(axis: .Y, angle: angle.x))
//simd_matrix4x4(simd_quatf(angle: angle.y, axis: .X) * simd_quatf(angle: angle.x, axis: .Y))
//.lookAt(to: Mat4f.rotate(yawPitch: angle) * -Vec3f.Z * 20.0)
//Mat4f(quat: Quatf.lookAt(to: .rotate(yawPitch: angle).transpose * -Vec3f.Z)).transpose
//Mat4f(Mat3f.lookAt(to: .rotate(yawPitch: angle) * -Vec3f.Z))
//.lookAt(from: _pos, to: .zero)
* .translate(-position - Vec3f(0, 1, 0))
}
var angle: Vec2f { return Vec2f(ofsAngle.x + _angle, ofsAngle.y) }
@ -45,13 +58,13 @@ struct Colin: Actor
for edge in edges
{
let diff = _pos2D - lastPos
if simd_dot(edge.n, diff) > 0 && simd_dot(edge.n, velocity) > 0 { continue }
if edge.n.dot(diff) > 0 && edge.n.dot(velocity) > 0 { continue }
let deltaPos = _pos2D - edge.p
let something = deltaPos.cross(edge.n)
if abs(something) * 2.0 < edge.w
{
let dot = simd_dot(edge.n, deltaPos)
let dot = edge.n.dot(deltaPos)
if dot > 0 && dot < colinWidth
{
lastPos = _pos2D
@ -246,5 +259,10 @@ struct Colin: Actor
// jumpVel = max(jumpVel, 0.0)
// _pos.y = 0.0
//}
//let piss = Quatf(axis: .X, angle: angle.y) * Quatf(axis: .Y, angle: angle.x)
//let shit = simd_quatf(angle: angle.y, axis: .X) * simd_quatf(angle: angle.x, axis: .Y)
//print(piss.w - shit.real, piss.x - shit.imag.x, piss.y - shit.imag.y, piss.z - shit.imag.z)
}
}

View File

@ -1,4 +1,5 @@
import Foundation
import Maths
import simd
import JolkEngine