Change order of enum BlockFace for consistency with Chunk.hpp

This commit is contained in:
Pedro Gimeno 2020-02-20 19:07:45 +01:00
parent 14de0d8e9f
commit 7c8c77d7b9
4 changed files with 45 additions and 45 deletions

View File

@ -47,22 +47,6 @@ void InventoryCube::updateVertexBuffer(const Block &block) {
// Same order as enum BlockFace in TilesDef.hpp
gk::Vertex vertices[6][4] = {
// Top
{
{{m_size, m_size, 0, 3}},
{{0, m_size, 0, 3}},
{{0, m_size, m_size, 3}},
{{m_size, m_size, m_size, 3}},
},
// Bottom
{
{{0, 0, 0, -1}},
{{m_size, 0, 0, -1}},
{{m_size, 0, m_size, -1}},
{{0, 0, m_size, -1}},
},
// West
{
{{0, 0, 0, 2}},
@ -94,6 +78,22 @@ void InventoryCube::updateVertexBuffer(const Block &block) {
{{m_size, m_size, m_size, -1}},
{{0, m_size, m_size, -1}},
},
// Bottom
{
{{0, 0, 0, -1}},
{{m_size, 0, 0, -1}},
{{m_size, 0, m_size, -1}},
{{0, 0, m_size, -1}},
},
// Top
{
{{m_size, m_size, 0, 3}},
{{0, m_size, 0, 3}},
{{0, m_size, m_size, 3}},
{{m_size, m_size, m_size, 3}},
},
};
for (u8 i = 0 ; i < 6 ; ++i) {
@ -144,11 +144,11 @@ void InventoryCube::draw(gk::RenderTarget &target, gk::RenderStates states) cons
glCheck(glDisable(GL_CULL_FACE));
glCheck(glDisable(GL_DEPTH_TEST));
target.draw(m_vbo, GL_QUADS, 4 * 0, 4, states);
target.draw(m_vbo, GL_QUADS, 4 * BlockFace::Top, 4, states);
// target.draw(m_vbo, GL_QUADS, 4 * 1, 4, states);
target.draw(m_vbo, GL_QUADS, 4 * 2, 4, states);
target.draw(m_vbo, GL_QUADS, 4 * BlockFace::West, 4, states);
// target.draw(m_vbo, GL_QUADS, 4 * 3, 4, states);
target.draw(m_vbo, GL_QUADS, 4 * 4, 4, states);
target.draw(m_vbo, GL_QUADS, 4 * BlockFace::South, 4, states);
// target.draw(m_vbo, GL_QUADS, 4 * 5, 4, states);
glCheck(glEnable(GL_DEPTH_TEST));

View File

@ -28,18 +28,6 @@
static const float cubeCoords[6 * 4 * 3] = {
// Same order as enum BlockFace in TilesDef.hpp
// Top
1, 1, 1,
0, 1, 1,
0, 0, 1,
1, 0, 1,
// Bottom
1, 0, 0,
0, 0, 0,
0, 1, 0,
1, 1, 0,
// West
0, 1, 0,
0, 0, 0,
@ -63,6 +51,18 @@ static const float cubeCoords[6 * 4 * 3] = {
0, 1, 0,
0, 1, 1,
1, 1, 1,
// Bottom
1, 0, 0,
0, 0, 0,
0, 1, 0,
1, 1, 0,
// Top
1, 1, 1,
0, 1, 1,
0, 0, 1,
1, 0, 1,
};
static const float crossCoords[2 * 4 * 3] = {
@ -91,12 +91,12 @@ std::array<std::size_t, ChunkBuilder::layers> ChunkBuilder::buildChunk(const Cli
const int surroundingBlocksPos[6][3] = {
// Same order as enum BlockFace in TilesDef.hpp
{x, y, z + 1},
{x, y, z - 1},
{x - 1, y, z},
{x + 1, y, z},
{x, y - 1, z},
{x, y + 1, z},
{x, y, z - 1},
{x, y, z + 1},
};
if (block.drawType() == BlockDrawType::Solid

View File

@ -35,12 +35,12 @@
#include "ISerializable.hpp"
enum BlockFace : u8 {
Top = 0,
Bottom = 1,
West = 2,
East = 3,
South = 4,
North = 5
West = 0,
East = 1,
South = 2,
North = 3,
Bottom = 4,
Top = 5,
};
class TilesDef : public ISerializable {

View File

@ -35,13 +35,13 @@ const std::string &TilesDef::getTextureForFace(u8 face, bool useAltTiles) const
// textures were specified
static constexpr u8 faceToIndex[nSizes][nFaces] = {
// Same order as enum BlockFace in TilesDef.hpp,
// namely: Top, Bottom, West, East, South, North
// namely: West, East, South, North, Bottom, Top
{ 0, 0, 0, 0, 0, 0, }, // for size = 1
{ 0, 0, 1, 1, 1, 1, }, // for size = 2
{ 0, 1, 2, 2, 2, 2, }, // for size = 3
{ 0, 1, 2, 3, 3, 3, }, // for size = 4
{ 0, 1, 2, 3, 4, 4, }, // for size = 5
{ 0, 1, 2, 3, 4, 5, }, // for size = 6
{ 1, 1, 1, 1, 0, 0, }, // for size = 2
{ 2, 2, 2, 2, 1, 0, }, // for size = 3
{ 2, 3, 3, 3, 1, 0, }, // for size = 4
{ 2, 3, 4, 4, 1, 0, }, // for size = 5
{ 2, 3, 4, 5, 1, 0, }, // for size = 6
};
u8 index = faceToIndex[size <= nSizes ? size - 1 : nSizes - 1][face];