Add abs and sign to int vectors

This commit is contained in:
2025-12-30 20:33:07 +01:00
parent 9b7155d39d
commit 8858e0c53e
2 changed files with 16 additions and 0 deletions

View File

@@ -162,6 +162,14 @@ pub const Vector2Int = extern struct {
return .{ .vector = @mod(self.vector, scalar_vector) };
}
pub inline fn abs(self: Vector2Int) Vector2Int {
return .{ .vector = @intCast(@abs(self.vector)) };
}
pub inline fn sign(self: Vector2Int) Vector2Int {
return .{ .vector = std.math.sign(self.vector) };
}
// --- SWIZZLE ---
pub inline fn swizzle2(self: Vector2Int, comptime mask: [2]Mask) Vector2Int {

View File

@@ -174,6 +174,14 @@ pub const Vector3Int = extern struct {
return .{ .vector = @mod(self.vector, scalar_vector) };
}
pub inline fn abs(self: Vector3Int) Vector3Int {
return .{ .vector = @intCast(@abs(self.vector)) };
}
pub inline fn sign(self: Vector3Int) Vector3Int {
return .{ .vector = std.math.sign(self.vector) };
}
// --- SWIZZLE ---
pub inline fn swizzle2(self: Vector3Int, comptime mask: [2]Mask) Vector2Int {