diff --git a/assets/cubyz/shaders/chunks/chunk_vertex.vs b/assets/cubyz/shaders/chunks/chunk_vertex.vs index c67e013e..f6fb2b93 100644 --- a/assets/cubyz/shaders/chunks/chunk_vertex.vs +++ b/assets/cubyz/shaders/chunks/chunk_vertex.vs @@ -47,12 +47,12 @@ const vec3[6] normals = vec3[6]( vec3(0, 0, -1) ); const vec3[6] positionOffset = vec3[6]( + vec3(0, 0, 0), vec3(0, 1, 0), vec3(0, 0, 0), vec3(1, 0, 0), vec3(0, 0, 0), - vec3(0, 0, 1), - vec3(0, 0, 0) + vec3(0, 0, 1) ); const ivec3[6] textureX = ivec3[6]( ivec3(1, 0, 0), diff --git a/src/chunk.zig b/src/chunk.zig index 1dad32f0..667706bb 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -643,7 +643,7 @@ pub const meshing = struct { var isVisible = neighborBlock.typ == 0; // TODO: Transparency if(isVisible) { const normal: u32 = i; - const position: u32 = @as(u32, x) | @as(u32, y)<<5 | @as(u32, z)<<10; + const position: u32 = @intCast(u32, x2) | @intCast(u32, y2)<<5 | @intCast(u32, z2)<<10; const textureNormal = blocks.meshes.textureIndices(block)[i] | normal<<24; try self.faces.append(position); try self.faces.append(textureNormal); @@ -700,21 +700,21 @@ pub const meshing = struct { var otherX = @intCast(u8, x+%Neighbors.relX[neighbor] & chunkMask); var otherY = @intCast(u8, y+%Neighbors.relY[neighbor] & chunkMask); var otherZ = @intCast(u8, z+%Neighbors.relZ[neighbor] & chunkMask); - var block = self.chunk.?.blocks[getIndex(x, y, z)]; - var otherBlock = neighborMesh.chunk.?.blocks[getIndex(otherX, otherY, otherZ)]; + var block = (&self.chunk.?.blocks)[getIndex(x, y, z)]; // ← a little hack that increases speed 100×. TODO: check if this is *that* compiler bug. + var otherBlock = (&neighborMesh.chunk.?.blocks)[getIndex(otherX, otherY, otherZ)]; // ← a little hack that increases speed 100×. TODO: check if this is *that* compiler bug. if(otherBlock.typ == 0 and block.typ != 0) { // TODO: Transparency const normal: u32 = neighbor; - const position: u32 = @as(u32, x) | @as(u32, y)<<5 | @as(u32, z)<<10; + const position: u32 = @as(u32, otherX) | @as(u32, otherY)<<5 | @as(u32, otherZ)<<10; const textureNormal = blocks.meshes.textureIndices(block)[neighbor] | normal<<24; - try self.faces.append(position); - try self.faces.append(textureNormal); + try additionalNeighborFaces.append(position); + try additionalNeighborFaces.append(textureNormal); } if(block.typ == 0 and otherBlock.typ != 0) { // TODO: Transparency const normal: u32 = neighbor ^ 1; - const position: u32 = @as(u32, otherX) | @as(u32, otherY)<<5 | @as(u32, otherZ)<<10; + const position: u32 = @as(u32, x) | @as(u32, y)<<5 | @as(u32, z)<<10; const textureNormal = blocks.meshes.textureIndices(otherBlock)[neighbor] | normal<<24; - try additionalNeighborFaces.append(position); - try additionalNeighborFaces.append(textureNormal); + try self.faces.append(position); + try self.faces.append(textureNormal); } } } diff --git a/src/network.zig b/src/network.zig index d654d464..3997ecd3 100644 --- a/src/network.zig +++ b/src/network.zig @@ -691,7 +691,7 @@ pub const Protocols = blk: { const _inflatedData = try utils.Compression.inflate(main.threadAllocator, data[16..]); data = _inflatedData; defer main.threadAllocator.free(_inflatedData); - if(pos.voxelSize == 1) { + if(pos.voxelSize != 0) { var ch = try renderer.RenderStructure.allocator.create(chunk.Chunk); ch.init(pos); for(ch.blocks) |*block| {