SyndicatQuebecoisdelaConstr.../SQCSim2021/chunk.h
MarcEricMartel 97ffc34e24 ÇA SAVE
2021-11-30 19:55:11 -05:00

43 lines
1.3 KiB
C++

#ifndef CHUNK_H__
#define CHUNK_H__
#include "define.h"
#include "array3d.h"
#include "array2d.h"
#include "vertexbuffer.h"
#include "blockinfo.h"
class World;
class Chunk {
private:
Array3d<BlockType> m_blocks = Array3d<BlockType>(CHUNK_SIZE_X, CHUNK_SIZE_Y, CHUNK_SIZE_Z);
VertexBuffer m_vertexBuffer;
bool m_isDirty = true;
bool m_isModified = false;
int m_posX; // Position du chunk dans l'array constituant le monde.
int m_posY;
void AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, float u, float v, float s, World* world);
public:
Chunk(int x, int y);
Chunk(int x, int y, char data[CHUNK_SIZE_X * CHUNK_SIZE_Y * CHUNK_SIZE_Z]);
~Chunk();
void RemoveBlock(int x, int y, int z, World* world);
void SetBlock(int x, int y, int z, BlockType type, World* world);
BlockType GetBlock(int x, int y, int z);
void CheckNeighbors(int x, int z, World* world);
void GetPosition(int& x, int& y) const;
void Update(BlockInfo* blockinfo[BTYPE_LAST], World* world);
void Render() const;
bool IsDirty() const;
void MakeDirty();
void MakeModified();
};
#endif // CHUNK_H__