Add widening/shortening vector dimensions
This commit is contained in:
@@ -37,6 +37,14 @@ pub const Vector3Int = extern struct {
|
||||
return @bitCast(self);
|
||||
}
|
||||
|
||||
pub inline fn dropZ(self: Vector3Int) vm.Vector2Int {
|
||||
return .{ .x = self.x, .y = self.y };
|
||||
}
|
||||
|
||||
pub inline fn withW(self: Vector3Int, w: i32) vm.Vector4Int {
|
||||
return .{ .x = self.x, .y = self.y, .z = self.z, .w = w };
|
||||
}
|
||||
|
||||
// --- COMPONENT-WISE ------------------------------------------------------
|
||||
|
||||
pub inline fn add(self: Vector3Int, other: Vector3Int) Vector3Int {
|
||||
@@ -51,7 +59,7 @@ pub const Vector3Int = extern struct {
|
||||
return .{ .x = self.x * other.x, .y = self.y * other.y, .z = self.z * other.z };
|
||||
}
|
||||
|
||||
pub inline fn mulScalar(self: Vector3Int, scalar: f32) Vector3Int {
|
||||
pub inline fn mulScalar(self: Vector3Int, scalar: i32) Vector3Int {
|
||||
return .{ .x = self.x * scalar, .y = self.y * scalar, .z = self.z * scalar };
|
||||
}
|
||||
|
||||
@@ -59,7 +67,7 @@ pub const Vector3Int = extern struct {
|
||||
return .{ .x = @divFloor(self.x, other.x), .y = @divFloor(self.y, other.y), .z = @divFloor(self.z, other.z) };
|
||||
}
|
||||
|
||||
pub inline fn divScalar(self: Vector3Int, scalar: f32) Vector3Int {
|
||||
pub inline fn divScalar(self: Vector3Int, scalar: i32) Vector3Int {
|
||||
return .{ .x = @divFloor(self.x, scalar), .y = @divFloor(self.y, scalar), .z = @divFloor(self.z, scalar) };
|
||||
}
|
||||
|
||||
@@ -67,7 +75,7 @@ pub const Vector3Int = extern struct {
|
||||
return .{ .x = @mod(self.x, other.x), .y = @mod(self.y, other.y), .z = @mod(self.z, other.z) };
|
||||
}
|
||||
|
||||
pub inline fn modScalar(self: Vector3Int, scalar: f32) Vector3Int {
|
||||
pub inline fn modScalar(self: Vector3Int, scalar: i32) Vector3Int {
|
||||
return .{ .x = @mod(self.x, scalar), .y = @mod(self.y, scalar), .z = @mod(self.z, scalar) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user