increased world loading speed and ui scroll

This commit is contained in:
MihailRis
2024-01-19 03:53:30 +03:00
parent ac9d0d7993
commit 1938ccc803
3 changed files with 11 additions and 12 deletions
+6 -7
View File
@@ -7,12 +7,11 @@
#include "../voxels/voxel.h"
#include "../voxels/Block.h"
#include "../constants.h"
#include "../typedefs.h"
#include <memory>
#include <iostream>
using std::shared_ptr;
Lighting::Lighting(const Content* content, Chunks* chunks)
: content(content), chunks(chunks) {
auto indices = content->getIndices();
@@ -31,7 +30,7 @@ Lighting::~Lighting(){
void Lighting::clear(){
for (unsigned int index = 0; index < chunks->volume; index++){
shared_ptr<Chunk> chunk = chunks->chunks[index];
auto chunk = chunks->chunks[index];
if (chunk == nullptr)
continue;
Lightmap* lightmap = chunk->lightmap;
@@ -98,10 +97,10 @@ void Lighting::onChunkLoaded(int cx, int cz){
const Block* const* blockDefs = content->getIndices()->getBlockDefs();
const Chunk* chunk = chunks->getChunk(cx, cz);
for (unsigned int y = 0; y < CHUNK_H; y++){
for (unsigned int z = 0; z < CHUNK_D; z++){
for (unsigned int x = 0; x < CHUNK_W; x++){
voxel vox = chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x];
for (uint y = 0; y < CHUNK_H; y++){
for (uint z = 0; z < CHUNK_D; z++){
for (uint x = 0; x < CHUNK_W; x++){
voxel& vox = chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x];
const Block* block = blockDefs[vox.id];
int gx = x + cx * CHUNK_W;
int gz = z + cz * CHUNK_D;