[ChunkBuilder] Cactus draw type added.
This commit is contained in:
parent
90e51241e0
commit
b851b41dad
@ -118,6 +118,20 @@ void InventoryCube::updateVertexBuffer(const Block &block) {
|
||||
vertices[i][j].coord3d[1] = vertices[i][j].coord3d[1] * block.boundingBox().sizeY + block.boundingBox().y;
|
||||
vertices[i][j].coord3d[2] = vertices[i][j].coord3d[2] * block.boundingBox().sizeZ + block.boundingBox().z;
|
||||
}
|
||||
else if (block.drawType() == BlockDrawType::Cactus) {
|
||||
static constexpr s8 normals[6][3] = {
|
||||
{-1, 0, 0},
|
||||
{1, 0, 0},
|
||||
{0, -1, 0},
|
||||
{0, 1, 0},
|
||||
{0, 0, -1},
|
||||
{0, 0, 1}
|
||||
};
|
||||
|
||||
vertices[i][j].coord3d[0] = vertices[i][j].coord3d[0] + block.boundingBox().x * -normals[i][0] * m_size;
|
||||
vertices[i][j].coord3d[1] = vertices[i][j].coord3d[1] + block.boundingBox().y * -normals[i][1] * m_size;
|
||||
vertices[i][j].coord3d[2] = vertices[i][j].coord3d[2] + block.boundingBox().z * -normals[i][2] * m_size;
|
||||
}
|
||||
|
||||
vertices[i][j].texCoord[0] = faceTexCoords[j * 2];
|
||||
vertices[i][j].texCoord[1] = faceTexCoords[j * 2 + 1];
|
||||
|
@ -144,6 +144,7 @@ std::array<std::size_t, ChunkBuilder::layers> ChunkBuilder::buildChunk(const Cli
|
||||
|| block.drawType() == BlockDrawType::Leaves
|
||||
|| block.drawType() == BlockDrawType::Liquid
|
||||
|| block.drawType() == BlockDrawType::Glass
|
||||
|| block.drawType() == BlockDrawType::Cactus
|
||||
|| block.drawType() == BlockDrawType::BoundingBox) {
|
||||
for (s8f i = 0 ; i < nFaces ; i++) {
|
||||
addFace(x, y, z, i, chunk, &block);
|
||||
@ -186,7 +187,8 @@ inline void ChunkBuilder::addFace(s8f x, s8f y, s8f z, s8f f, const ClientChunk
|
||||
if (surroundingBlock && surroundingBlock->id()
|
||||
&& ((block->drawType() == BlockDrawType::Solid && surroundingBlock->drawType() == BlockDrawType::Solid && surroundingBlock->isOpaque())
|
||||
|| (block->id() == surroundingBlock->id() && (block->drawType() == BlockDrawType::Liquid || block->drawType() == BlockDrawType::Glass))
|
||||
|| (block->drawType() == BlockDrawType::Liquid && surroundingBlock->drawType() == BlockDrawType::Solid)))
|
||||
|| (block->drawType() == BlockDrawType::Liquid && surroundingBlock->drawType() == BlockDrawType::Solid)
|
||||
|| (block->drawType() == BlockDrawType::Cactus && surroundingBlock->id() == block->id())))
|
||||
return;
|
||||
|
||||
const BlockData *blockData = chunk.getBlockData(x, y, z);
|
||||
@ -210,6 +212,11 @@ inline void ChunkBuilder::addFace(s8f x, s8f y, s8f z, s8f f, const ClientChunk
|
||||
vertices[v].coord3d[1] = y + vertexPosPtr[1] * boundingBox.sizeY + boundingBox.y;
|
||||
vertices[v].coord3d[2] = z + vertexPosPtr[2] * boundingBox.sizeZ + boundingBox.z;
|
||||
}
|
||||
else if (block->drawType() == BlockDrawType::Cactus) {
|
||||
vertices[v].coord3d[0] = x + vertexPosPtr[0] + boundingBox.x * -normal.x;
|
||||
vertices[v].coord3d[1] = y + vertexPosPtr[1] + boundingBox.y * -normal.y;
|
||||
vertices[v].coord3d[2] = z + vertexPosPtr[2] + boundingBox.z * -normal.z;
|
||||
}
|
||||
else {
|
||||
vertices[v].coord3d[0] = x + vertexPosPtr[0];
|
||||
vertices[v].coord3d[1] = y + vertexPosPtr[1];
|
||||
@ -231,7 +238,6 @@ inline void ChunkBuilder::addFace(s8f x, s8f y, s8f z, s8f f, const ClientChunk
|
||||
vertices[v].texCoord[0] = faceTexCoords[v][0];
|
||||
vertices[v].texCoord[1] = faceTexCoords[v][1];
|
||||
|
||||
|
||||
if (Config::isSunSmoothLightingEnabled && block->drawType() != BlockDrawType::Liquid)
|
||||
vertices[v].lightValue[0] = getLightForVertex(Light::Sun, x, y, z, vertexPosPtr, normal, chunk);
|
||||
else
|
||||
|
@ -49,7 +49,8 @@ enum class BlockDrawType {
|
||||
Leaves = 2,
|
||||
Liquid = 3,
|
||||
Glass = 4,
|
||||
BoundingBox = 5, // FIXME: Temporary
|
||||
Cactus = 5,
|
||||
BoundingBox = 6, // FIXME: Temporary
|
||||
};
|
||||
|
||||
class Block : public ISerializable {
|
||||
|
@ -238,6 +238,9 @@ mod:block {
|
||||
id = "cactus",
|
||||
name = "Cactus",
|
||||
tiles = {"cactus_top.png", "cactus_side.png"},
|
||||
|
||||
draw_type = "cactus",
|
||||
bounding_box = {1/16, 1/16, 0, 14/16, 14/16, 1};
|
||||
}
|
||||
|
||||
mod:block {
|
||||
|
@ -84,7 +84,8 @@ inline void LuaBlockLoader::loadDrawType(ServerBlock &block, const sol::table &t
|
||||
{"leaves", BlockDrawType::Leaves},
|
||||
{"liquid", BlockDrawType::Liquid},
|
||||
{"glass", BlockDrawType::Glass},
|
||||
{"boundingbox", BlockDrawType::BoundingBox} // FIXME: Temporary
|
||||
{"cactus", BlockDrawType::Cactus},
|
||||
{"boundingbox", BlockDrawType::BoundingBox}, // FIXME: Temporary
|
||||
};
|
||||
|
||||
auto it = drawTypes.find(drawTypeObject.as<std::string>());
|
||||
|
Loading…
x
Reference in New Issue
Block a user