mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
Add files via upload
This commit is contained in:
commit
e1cdcf01e9
49 changed files with 2866 additions and 0 deletions
29
src/voxels/Chunk.cpp
Normal file
29
src/voxels/Chunk.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "Chunk.h"
|
||||
#include "voxel.h"
|
||||
#include "../lighting/Lightmap.h"
|
||||
|
||||
|
||||
Chunk::Chunk(int xpos, int ypos, int zpos) : x(xpos), y(ypos), z(zpos){
|
||||
voxels = new voxel[CHUNK_VOL];
|
||||
for (unsigned int i = 0; i < CHUNK_VOL; i++)
|
||||
voxels[i].id = 1;
|
||||
lightmap = new Lightmap();
|
||||
}
|
||||
|
||||
Chunk::~Chunk(){
|
||||
delete lightmap;
|
||||
delete[] voxels;
|
||||
}
|
||||
|
||||
bool Chunk::isEmpty(){
|
||||
int id = -1;
|
||||
for (int i = 0; i < CHUNK_VOL; i++){
|
||||
if (voxels[i].id != id){
|
||||
if (id != -1)
|
||||
return false;
|
||||
else
|
||||
id = voxels[i].id;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue