mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 12:01:50 +00:00
Advancec Frustum Culling & fixes
This commit is contained in:
parent
11f004b582
commit
883dcbf168
12 changed files with 178 additions and 53 deletions
|
|
@ -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++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue