JUMBO vecmath completion update

This commit is contained in:
2026-01-04 15:43:10 +01:00
parent b09200b7ab
commit ed6391e97a
24 changed files with 3141 additions and 878 deletions

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const vm = @import("root");
const vm = @import("../root.zig");
pub const Vector4 = extern struct {
x: f32,
@@ -20,7 +20,7 @@ pub const Vector4 = extern struct {
pub const unit_nz = init(0, 0, -1, 0);
pub const unit_nw = init(0, 0, 0, -1);
// --- INIT ----
// --- INIT ----------------------------------------------------------------
pub inline fn init(x: f32, y: f32, z: f32, w: f32) Vector4 {
return .{ .x = x, .y = y, .z = z, .w = w };
@@ -34,21 +34,13 @@ pub const Vector4 = extern struct {
return @bitCast(array);
}
// --- CONVERSION ---
// --- CONVERSION ----------------------------------------------------------
pub inline fn asArray(self: Vector4) Array {
return @bitCast(self);
}
pub inline fn asArrayPtr(self: *Vector4) *Array {
return @ptrCast(self);
}
pub inline fn asArrayConstPtr(self: *const Vector4) *const Array {
return @ptrCast(self);
}
// --- COMPONENT-WISE ---
// --- COMPONENT-WISE ------------------------------------------------------
pub inline fn add(self: Vector4, other: Vector4) Vector4 {
return .{ .x = self.x + other.x, .y = self.y + other.y, .z = self.z + other.z, .w = self.w + other.w };
@@ -102,7 +94,7 @@ pub const Vector4 = extern struct {
return .{ .x = @max(self.x, other.x), .y = @max(self.y, other.y), .z = @max(self.z, other.z), .w = @max(self.w, other.w) };
}
// --- OTHER ---
// --- OTHER ---------------------------------------------------------------
pub inline fn len(self: Vector4) f32 {
return @sqrt(self.x * self.x + self.y * self.y + self.z * self.z + self.w * self.w);