[Block] Draw type 'AllFaces' added for leaves. [ChunkBuilder] Hidden face skipping is now dependent on 'AllFaces' draw type instead of BlockType.
This commit is contained in:
parent
0f05a11bc3
commit
03bbc53cd4
@ -87,7 +87,7 @@ std::array<std::size_t, ChunkBuilder::layers> ChunkBuilder::buildChunk(const Cli
|
||||
{x, y, z + 1},
|
||||
};
|
||||
|
||||
if (block.drawType() == BlockDrawType::Solid) {
|
||||
if (block.drawType() == BlockDrawType::Solid || block.drawType() == BlockDrawType::AllFaces) {
|
||||
for(u8 i = 0 ; i < 6 ; i++) {
|
||||
addFace(x, y, z, i, chunk, &block, surroundingBlocksPos[i]);
|
||||
}
|
||||
@ -122,7 +122,7 @@ inline void ChunkBuilder::addFace(u8 x, u8 y, u8 z, u8 i, const ClientChunk &chu
|
||||
|
||||
// Skip hidden faces
|
||||
if(surroundingBlock && surroundingBlock->id() && surroundingBlock->drawType() == BlockDrawType::Solid
|
||||
&& (surroundingBlock->isOpaque() || (block->id() == surroundingBlock->id() && block->id() != BlockType::Leaves)))
|
||||
&& (surroundingBlock->isOpaque() || block->drawType() != BlockDrawType::AllFaces))
|
||||
return;
|
||||
|
||||
static glm::vec3 a, b, c, v1, v2, normal;
|
||||
|
@ -31,8 +31,9 @@ class Player;
|
||||
class World;
|
||||
|
||||
enum class BlockDrawType {
|
||||
Solid = 0,
|
||||
XShape = 1,
|
||||
Solid = 0,
|
||||
XShape = 1,
|
||||
AllFaces = 2,
|
||||
};
|
||||
|
||||
class Block : public ISerializable {
|
||||
@ -57,7 +58,7 @@ class Block : public ISerializable {
|
||||
s8 selectedFace() const { return m_selectedFace; }
|
||||
void setSelected(bool isSelected, s8 face) { m_isSelected = isSelected; m_selectedFace = face; }
|
||||
|
||||
bool isOpaque() const { return m_id != 0 && m_id != 4 && m_id != 8 && m_id != 9 && m_id != 16 && m_drawType != BlockDrawType::XShape; }
|
||||
bool isOpaque() const { return m_id != 0 && m_id != BlockType::Leaves && m_id != BlockType::Water && m_id != BlockType::Glass && m_drawType != BlockDrawType::XShape; }
|
||||
|
||||
ItemStack getItemDrop() const { return ItemStack{m_itemDrop, m_itemDropAmount}; };
|
||||
void setItemDrop(const std::string &itemDrop, u16 itemDropAmount = 1) { m_itemDrop = itemDrop; m_itemDropAmount = itemDropAmount; }
|
||||
|
@ -27,6 +27,7 @@ mod:block {
|
||||
name = "Leaves",
|
||||
tiles = "oak_leaves.png",
|
||||
hardness = 0.5,
|
||||
draw_type = 2, -- FIXME: Use string instead
|
||||
}
|
||||
|
||||
mod:block {
|
||||
@ -106,7 +107,7 @@ mod:block {
|
||||
name = "Flower",
|
||||
tiles = "dandelion.png",
|
||||
hardness = 0.05,
|
||||
draw_type = 1,
|
||||
draw_type = 1, -- FIXME: Use string instead
|
||||
bounding_box = {0.25, 0.0, 0.25, 0.5, 0.5, 0.5},
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ void LuaMod::registerBlock(const sol::table &table) {
|
||||
});
|
||||
}
|
||||
|
||||
// FIXME: Use string instead
|
||||
sol::optional<BlockDrawType> drawType = table["draw_type"];
|
||||
if (drawType != sol::nullopt) {
|
||||
block.setDrawType(drawType.value());
|
||||
|
Loading…
x
Reference in New Issue
Block a user