Camera controls, fix some math; lighting probably broken

This commit is contained in:
2025-11-13 17:01:10 +01:00
parent 4cbf151fd9
commit a011603195
10 changed files with 394 additions and 169 deletions

View File

@@ -31,11 +31,11 @@ pub const Vector4 = extern struct {
}
pub inline fn asVector2(self: Vector4) Vector2 {
return .{ .vector = @shuffle(f32, self.vector, undefined, .{ 0, 1 }) };
return .{ .vector = @shuffle(f32, self.vector, undefined, [_]i32{ 0, 1 }) };
}
pub inline fn asVector3(self: Vector4) Vector3 {
return .{ .vector = @shuffle(f32, self.vector, undefined, .{ 0, 1, 2 }) };
return .{ .vector = @shuffle(f32, self.vector, undefined, [_]i32{ 0, 1, 2 }) };
}
// --- ACCESSORS ---
@@ -58,22 +58,22 @@ pub const Vector4 = extern struct {
pub inline fn setX(self: Vector4, x: f32) Vector4 {
const x_vector: Vector = @splat(x);
return .{ .vector = @shuffle(f32, self, x_vector, .{ ~@as(i32, 0), 1, 2, 3 }) };
return .{ .vector = @shuffle(f32, self.vector, x_vector, [_]i32{ ~@as(i32, 0), 1, 2, 3 }) };
}
pub inline fn setY(self: Vector4, y: f32) Vector4 {
const y_vector: Vector = @splat(y);
return .{ .vector = @shuffle(f32, self, y_vector, .{ 0, ~@as(i32, 1), 2, 3 }) };
return .{ .vector = @shuffle(f32, self.vector, y_vector, [_]i32{ 0, ~@as(i32, 1), 2, 3 }) };
}
pub inline fn setZ(self: Vector4, z: f32) Vector4 {
const z_vector: Vector = @splat(z);
return .{ .vector = @shuffle(f32, self, z_vector, .{ 0, 1, ~@as(i32, 2), 3 }) };
return .{ .vector = @shuffle(f32, self.vector, z_vector, [_]i32{ 0, 1, ~@as(i32, 2), 3 }) };
}
pub inline fn setW(self: Vector4, w: f32) Vector4 {
const w_vector: Vector = @splat(w);
return .{ .vector = @shuffle(f32, self, w_vector, .{ 0, 1, 2, ~@as(i32, 3) }) };
return .{ .vector = @shuffle(f32, self.vector, w_vector, [_]i32{ 0, 1, 2, ~@as(i32, 3) }) };
}
// --- COMPONENT-WISE ---