Bad collisions
This commit is contained in:
@@ -110,13 +110,13 @@ pub fn refresh(self: *Chunk, engine: *Engine, blocks: *const Blocks, neighbors:
|
||||
for (row, 0..) |id, ix| {
|
||||
const fx: f32 = @floatFromInt(ix);
|
||||
const block: *const Blocks.Definition = &blocks.array.items[id.toInt()];
|
||||
const center = Vector3.add(self.origin, .init(fx, fy, fz));
|
||||
const origin = Vector3.add(self.origin, .init(fx, fy, fz));
|
||||
|
||||
inline for (@typeInfo(voxels.Orientation).@"enum".fields) |field| {
|
||||
const side = @field(voxels.Orientation, field.name);
|
||||
const material = @field(block.walls, field.name).material;
|
||||
if (material != .empty and self.getOpposite(side, ix, iy, iz, blocks, neighbors) == .empty) {
|
||||
const matrix = getMatrix(side, center);
|
||||
const matrix = getMatrix(side, origin);
|
||||
try uniforms.append(temp_allocator, .init(matrix, matrix, material));
|
||||
}
|
||||
}
|
||||
@@ -209,44 +209,44 @@ fn getOpposite(self: *const Chunk, comptime side: voxels.Orientation, x: usize,
|
||||
};
|
||||
}
|
||||
|
||||
fn getMatrix(comptime side: voxels.Orientation, center: Vector3) Matrix4x4 {
|
||||
fn getMatrix(comptime side: voxels.Orientation, origin: Vector3) Matrix4x4 {
|
||||
return switch (side) {
|
||||
// zig fmt: off
|
||||
.positive_x => .init(
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
1, 0, 0, 0,
|
||||
center.getX() + 0.5, center.getY(), center.getZ(), 1,
|
||||
origin.getX() + 1, origin.getY(), origin.getZ(), 1,
|
||||
),
|
||||
.negative_x => .init(
|
||||
0, -1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
-1, 0, 0, 0,
|
||||
center.getX() - 0.5, center.getY(), center.getZ(), 1,
|
||||
origin.getX(), origin.getY() + 1, origin.getZ(), 1,
|
||||
),
|
||||
.positive_y => .init(
|
||||
-1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 1, 0, 0,
|
||||
center.getX(), center.getY() + 0.5, center.getZ(), 1,
|
||||
origin.getX() + 1, origin.getY() + 1, origin.getZ(), 1,
|
||||
),
|
||||
.negative_y => .init(
|
||||
1, 0, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, -1, 0, 0,
|
||||
center.getX(), center.getY() - 0.5, center.getZ(), 1,
|
||||
origin.getX(), origin.getY(), origin.getZ(), 1,
|
||||
),
|
||||
.positive_z => .init(
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
center.getX(), center.getY(), center.getZ() + 0.5, 1,
|
||||
origin.getX(), origin.getY(), origin.getZ() + 1, 1,
|
||||
),
|
||||
.negative_z => .init(
|
||||
1, 0, 0, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, -1, 0,
|
||||
center.getX(), center.getY(), center.getZ() - 0.5, 1,
|
||||
origin.getX() + 1, origin.getY() + 1, origin.getZ(), 1,
|
||||
),
|
||||
// zig fmt: on
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user