2018-06-19 23:00:50 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: ChunkBuilder.hpp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Created: 19/06/2018 22:26:07
|
|
|
|
*
|
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef CHUNKBUILDER_HPP_
|
|
|
|
#define CHUNKBUILDER_HPP_
|
|
|
|
|
2018-06-20 03:45:30 +02:00
|
|
|
#include <vector>
|
2018-06-19 23:00:50 +02:00
|
|
|
|
2018-06-25 18:42:50 +02:00
|
|
|
#include "IntTypes.hpp"
|
2018-06-20 03:45:30 +02:00
|
|
|
#include "Vertex.hpp"
|
|
|
|
|
|
|
|
class Block;
|
2018-06-19 23:00:50 +02:00
|
|
|
class Chunk;
|
|
|
|
class VertexBuffer;
|
|
|
|
|
|
|
|
class ChunkBuilder {
|
|
|
|
public:
|
2018-06-20 00:57:27 +02:00
|
|
|
std::size_t buildChunk(const Chunk &chunk, const VertexBuffer &vbo);
|
2018-06-20 03:45:30 +02:00
|
|
|
|
|
|
|
private:
|
2018-06-25 00:05:21 +02:00
|
|
|
void addFace(u8 x, u8 y, u8 z, u8 i, const Chunk &chunk, const Block *block, const Block *surroundingBlock);
|
2018-06-20 03:45:30 +02:00
|
|
|
|
2018-07-06 11:58:34 +02:00
|
|
|
float getAverageTorchlight(u8 x, u8 y, u8 z, s8 offsetX, s8 offsetY, s8 offsetZ, const Chunk &chunk);
|
|
|
|
float getAverageSunlight(u8 x, u8 y, u8 z, s8 offsetX, s8 offsetY, s8 offsetZ, const Chunk &chunk);
|
|
|
|
|
|
|
|
float getSunlightForVertex(u8 x, u8 y, u8 z, u8 i, u8 j, const Chunk &chunk);
|
|
|
|
float getTorchlightForVertex(u8 x, u8 y, u8 z, u8 i, u8 j, const Chunk &chunk);
|
|
|
|
|
2018-06-20 03:45:30 +02:00
|
|
|
std::vector<Vertex> m_vertices;
|
2018-07-06 11:58:34 +02:00
|
|
|
|
|
|
|
enum Face {
|
|
|
|
Left,
|
|
|
|
Right,
|
|
|
|
Bottom,
|
|
|
|
Top,
|
|
|
|
Front,
|
|
|
|
Back
|
|
|
|
};
|
2018-06-19 23:00:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CHUNKBUILDER_HPP_
|