experimental optimizations
This commit is contained in:
@@ -40,7 +40,7 @@ void ChunksController::update(int64_t maxDuration) {
|
||||
timeutil::Timer timer;
|
||||
if (loadVisible()) {
|
||||
int64_t mcs = timer.stop();
|
||||
if (mcstotal + mcs * 2 < maxDuration * 1000) {
|
||||
if (mcstotal + mcs < maxDuration * 1000) {
|
||||
mcstotal += mcs;
|
||||
continue;
|
||||
}
|
||||
@@ -55,13 +55,14 @@ bool ChunksController::loadVisible(){
|
||||
const int d = chunks->d;
|
||||
const int ox = chunks->ox;
|
||||
const int oz = chunks->oz;
|
||||
|
||||
int nearX = 0;
|
||||
int nearZ = 0;
|
||||
int minDistance = ((w-padding*2)/2)*((w-padding*2)/2);
|
||||
for (uint z = padding; z < d-padding; z++){
|
||||
for (uint x = padding; x < w-padding; x++){
|
||||
int index = z * w + x;
|
||||
std::shared_ptr<Chunk> chunk = chunks->chunks[index];
|
||||
auto chunk = chunks->chunks[index];
|
||||
if (chunk != nullptr){
|
||||
int surrounding = 0;
|
||||
for (int oz = -1; oz <= 1; oz++){
|
||||
@@ -72,10 +73,11 @@ bool ChunksController::loadVisible(){
|
||||
}
|
||||
chunk->surrounding = surrounding;
|
||||
if (surrounding == MIN_SURROUNDING && !chunk->isLighted()) {
|
||||
if (!chunk->isLoadedLights()) {
|
||||
bool lightsCache = chunk->isLoadedLights();
|
||||
if (!lightsCache) {
|
||||
lighting->buildSkyLight(chunk->x, chunk->z);
|
||||
}
|
||||
lighting->onChunkLoaded(chunk->x, chunk->z);
|
||||
lighting->onChunkLoaded(chunk->x, chunk->z, !lightsCache);
|
||||
chunk->setLighted(true);
|
||||
return true;
|
||||
}
|
||||
@@ -93,7 +95,7 @@ bool ChunksController::loadVisible(){
|
||||
}
|
||||
|
||||
int index = nearZ * w + nearX;
|
||||
std::shared_ptr<Chunk> chunk = chunks->chunks[index];
|
||||
auto chunk = chunks->chunks[index];
|
||||
if (chunk != nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user