Advancec Frustum Culling & fixes

This commit is contained in:
@clasher113
2023-11-16 16:42:57 +02:00
parent 11f004b582
commit 883dcbf168
12 changed files with 178 additions and 53 deletions
+18
View File
@@ -3,6 +3,8 @@
#include "../lighting/Lightmap.h"
Chunk::Chunk(int xpos, int zpos) : x(xpos), z(zpos){
bottom = 0;
top = CHUNK_H;
voxels = new voxel[CHUNK_VOL];
for (size_t i = 0; i < CHUNK_VOL; i++) {
voxels[i].id = 2;
@@ -30,6 +32,22 @@ bool Chunk::isEmpty(){
return true;
}
void Chunk::updateHeights() {
for (int i = 0; i < CHUNK_VOL; i++) {
if (voxels[i].id != 0) {
bottom = i / (CHUNK_D * CHUNK_W);
break;
}
}
for (int i = CHUNK_VOL - 1; i > -1; i--) {
if (voxels[i].id != 0) {
top = i / (CHUNK_D * CHUNK_W) + 1;
break;
}
}
}
Chunk* Chunk::clone() const {
Chunk* other = new Chunk(x,z);
for (int i = 0; i < CHUNK_VOL; i++)