diff --git a/assets/cubyz/blocks/oak_leaves.json b/assets/cubyz/blocks/oak_leaves.json index 60cda3a2..6c1c0343 100644 --- a/assets/cubyz/blocks/oak_leaves.json +++ b/assets/cubyz/blocks/oak_leaves.json @@ -6,7 +6,7 @@ "0.1 cubyz:apple" ], "degradable" : true, - "viewThrough" : true, + "alwaysViewThrough" : true, "absorbedLight" : 0x121012, "model" : "cube", "texture" : "cubyz:oak_leaves_transparent" diff --git a/assets/cubyz/blocks/pine_needles.json b/assets/cubyz/blocks/pine_needles.json index abed5c89..2a3c85f3 100644 --- a/assets/cubyz/blocks/pine_needles.json +++ b/assets/cubyz/blocks/pine_needles.json @@ -6,7 +6,7 @@ "0.1 cubyz:apple" ], "degradable" : true, - "viewThrough" : true, + "alwaysViewThrough" : true, "absorbedLight" : 0x121012, "model" : "cube", "texture" : "cubyz:pine_needles" diff --git a/src/blocks.zig b/src/blocks.zig index 9f233c5b..e9b9a40e 100644 --- a/src/blocks.zig +++ b/src/blocks.zig @@ -70,6 +70,7 @@ var _blockDrops: [maxBlockCount][]BlockDrop = undefined; /// Meaning undegradable parts of trees or other structures can grow through this block. var _degradable: [maxBlockCount]bool = undefined; var _viewThrough: [maxBlockCount]bool = undefined; +var _alwaysViewThrough: [maxBlockCount]bool = undefined; var _hasBackFace: [maxBlockCount]bool = undefined; var _blockClass: [maxBlockCount]BlockClass = undefined; var _light: [maxBlockCount]u32 = undefined; @@ -114,7 +115,8 @@ pub fn register(_: []const u8, id: []const u8, json: JsonElement) u16 { _solid[size] = json.get(bool, "solid", true); _gui[size] = allocator.dupe(u8, json.get([]const u8, "GUI", "")); _transparent[size] = json.get(bool, "transparent", false); - _viewThrough[size] = json.get(bool, "viewThrough", false) or _transparent[size]; + _alwaysViewThrough[size] = json.get(bool, "alwaysViewThrough", false); + _viewThrough[size] = json.get(bool, "viewThrough", false) or _transparent[size] or _alwaysViewThrough[size]; _hasBackFace[size] = json.get(bool, "hasBackFace", false); const oreProperties = json.getChild("ore"); @@ -256,6 +258,11 @@ pub const Block = packed struct { return _viewThrough[self.typ]; } + /// shows backfaces even when next to the same block type + pub inline fn alwaysViewThrough(self: Block) bool { + return _alwaysViewThrough[self.typ]; + } + pub inline fn hasBackFace(self: Block) bool { return _hasBackFace[self.typ]; } diff --git a/src/renderer/chunk_meshing.zig b/src/renderer/chunk_meshing.zig index faab1dcb..07b7e657 100644 --- a/src/renderer/chunk_meshing.zig +++ b/src/renderer/chunk_meshing.zig @@ -606,7 +606,7 @@ pub const ChunkMesh = struct { _ = model; // TODO: Check if the neighbor model occludes this one. (maybe not that relevant) return block.typ != 0 and ( other.typ == 0 - or (!std.meta.eql(block, other) and other.viewThrough()) + or (!std.meta.eql(block, other) and other.viewThrough()) or other.alwaysViewThrough() or !models.models.items[blocks.meshes.model(other)].isNeighborOccluded[neighbor ^ 1] ); }