introduce ChunkMesh

This commit is contained in:
MihailRis
2024-11-16 04:13:00 +03:00
parent 5793c52ac6
commit 5b6256e0fa
5 changed files with 172 additions and 42 deletions
+8 -4
View File
@@ -12,6 +12,7 @@
#include "voxels/VoxelsVolume.hpp"
#include "graphics/core/MeshData.hpp"
#include "maths/util.hpp"
#include "commons.hpp"
class Content;
class Mesh;
@@ -45,6 +46,8 @@ class BlocksRenderer {
util::PseudoRandom randomizer;
SortingMeshData sortingMesh;
void vertex(const glm::vec3& coord, float u, float v, const glm::vec4& light);
void index(int a, int b, int c, int d, int e, int f);
@@ -115,7 +118,6 @@ class BlocksRenderer {
bool isOpenForLight(int x, int y, int z) const;
// Does block allow to see other blocks sides (is it transparent)
inline bool isOpen(const glm::ivec3& pos, ubyte group) const {
auto id = voxelsBuffer->pickBlockId(
@@ -135,7 +137,9 @@ class BlocksRenderer {
glm::vec4 pickLight(const glm::ivec3& coord) const;
glm::vec4 pickSoftLight(const glm::ivec3& coord, const glm::ivec3& right, const glm::ivec3& up) const;
glm::vec4 pickSoftLight(float x, float y, float z, const glm::ivec3& right, const glm::ivec3& up) const;
void render(const voxel* voxels);
void render(const voxel* voxels, int beginEnds[256][2]);
SortingMeshData renderTranslucent(const voxel* voxels, int beginEnds[256][2]);
public:
BlocksRenderer(
size_t capacity,
@@ -146,8 +150,8 @@ public:
virtual ~BlocksRenderer();
void build(const Chunk* chunk, const Chunks* chunks);
std::shared_ptr<Mesh> render(const Chunk* chunk, const Chunks* chunks);
MeshData createMesh();
ChunkMesh render(const Chunk* chunk, const Chunks* chunks);
ChunkMeshData createMesh();
VoxelsVolume* getVoxelsBuffer() const;
bool isCancelled() const {