increased world loading speed and ui scroll
This commit is contained in:
parent
ac9d0d7993
commit
1938ccc803
@ -61,7 +61,7 @@ void Container::act(float delta) {
|
|||||||
void Container::scrolled(int value) {
|
void Container::scrolled(int value) {
|
||||||
int diff = (actualLength-size().y);
|
int diff = (actualLength-size().y);
|
||||||
if (diff > 0 && scrollable_) {
|
if (diff > 0 && scrollable_) {
|
||||||
scroll += value * 20;
|
scroll += value * 40;
|
||||||
if (scroll > 0)
|
if (scroll > 0)
|
||||||
scroll = 0;
|
scroll = 0;
|
||||||
if (-scroll > diff) {
|
if (-scroll > diff) {
|
||||||
|
|||||||
@ -7,12 +7,11 @@
|
|||||||
#include "../voxels/voxel.h"
|
#include "../voxels/voxel.h"
|
||||||
#include "../voxels/Block.h"
|
#include "../voxels/Block.h"
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using std::shared_ptr;
|
|
||||||
|
|
||||||
Lighting::Lighting(const Content* content, Chunks* chunks)
|
Lighting::Lighting(const Content* content, Chunks* chunks)
|
||||||
: content(content), chunks(chunks) {
|
: content(content), chunks(chunks) {
|
||||||
auto indices = content->getIndices();
|
auto indices = content->getIndices();
|
||||||
@ -31,7 +30,7 @@ Lighting::~Lighting(){
|
|||||||
|
|
||||||
void Lighting::clear(){
|
void Lighting::clear(){
|
||||||
for (unsigned int index = 0; index < chunks->volume; index++){
|
for (unsigned int index = 0; index < chunks->volume; index++){
|
||||||
shared_ptr<Chunk> chunk = chunks->chunks[index];
|
auto chunk = chunks->chunks[index];
|
||||||
if (chunk == nullptr)
|
if (chunk == nullptr)
|
||||||
continue;
|
continue;
|
||||||
Lightmap* lightmap = chunk->lightmap;
|
Lightmap* lightmap = chunk->lightmap;
|
||||||
@ -98,10 +97,10 @@ void Lighting::onChunkLoaded(int cx, int cz){
|
|||||||
const Block* const* blockDefs = content->getIndices()->getBlockDefs();
|
const Block* const* blockDefs = content->getIndices()->getBlockDefs();
|
||||||
const Chunk* chunk = chunks->getChunk(cx, cz);
|
const Chunk* chunk = chunks->getChunk(cx, cz);
|
||||||
|
|
||||||
for (unsigned int y = 0; y < CHUNK_H; y++){
|
for (uint y = 0; y < CHUNK_H; y++){
|
||||||
for (unsigned int z = 0; z < CHUNK_D; z++){
|
for (uint z = 0; z < CHUNK_D; z++){
|
||||||
for (unsigned int x = 0; x < CHUNK_W; x++){
|
for (uint x = 0; x < CHUNK_W; x++){
|
||||||
voxel vox = chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x];
|
voxel& vox = chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x];
|
||||||
const Block* block = blockDefs[vox.id];
|
const Block* block = blockDefs[vox.id];
|
||||||
int gx = x + cx * CHUNK_W;
|
int gx = x + cx * CHUNK_W;
|
||||||
int gz = z + cz * CHUNK_D;
|
int gz = z + cz * CHUNK_D;
|
||||||
|
|||||||
@ -40,11 +40,11 @@ void ChunksController::update(int64_t maxDuration) {
|
|||||||
timeutil::Timer timer;
|
timeutil::Timer timer;
|
||||||
if (loadVisible()) {
|
if (loadVisible()) {
|
||||||
int64_t mcs = timer.stop();
|
int64_t mcs = timer.stop();
|
||||||
avgDurationMcs = mcs * 0.2 + avgDurationMcs * 0.8;
|
if (mcstotal + mcs * 2 < maxDuration * 1000) {
|
||||||
if (mcstotal + max(avgDurationMcs, mcs) * 2 < maxDuration * 1000) {
|
|
||||||
mcstotal += mcs;
|
mcstotal += mcs;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
mcstotal += mcs;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ bool ChunksController::loadVisible(){
|
|||||||
if (surrounding == MIN_SURROUNDING && !chunk->isLighted()) {
|
if (surrounding == MIN_SURROUNDING && !chunk->isLighted()) {
|
||||||
if (!chunk->isLoadedLights()) {
|
if (!chunk->isLoadedLights()) {
|
||||||
lighting->buildSkyLight(chunk->x, chunk->z);
|
lighting->buildSkyLight(chunk->x, chunk->z);
|
||||||
}
|
lighting->onChunkLoaded(chunk->x, chunk->z);
|
||||||
lighting->onChunkLoaded(chunk->x, chunk->z);
|
}
|
||||||
chunk->setLighted(true);
|
chunk->setLighted(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user