Skip to content

Commit 90574a1

Browse files
committed
Even more optimization
1 parent f41b72b commit 90574a1

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ else
3434
CFLAGS += -s -O2 -Wl,--subsystem,windows
3535
endif
3636

37-
INCLUDE_PATHS = -I$(DIR_INC) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
37+
INCLUDE_PATHS = -I$(DIR_INC) -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external -I$(RAYLIB_PATH)/src/extras
3838
LDFLAGS = -L. -L$(RAYLIB_PATH)/src
3939
LDLIBS = -static -lraylib -lopengl32 -lgdi32 -lwinmm -lpthread -lws2_32 -lwinmm
4040

client/src/chunk/chunkLightning.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <stdio.h>
1111
#include "chunkLightning.h"
1212
#include "../block/block.h"
13+
#include "world.h"
14+
#include "player.h"
1315

1416
Vector3 lightDirections[6] = {
1517
{-1, 0, 0},
@@ -145,7 +147,7 @@ void Chunk_DoSunlight(Chunk *srcChunk) {
145147
}
146148
}
147149
} else {
148-
if(srcChunk->position.y >= 5) {
150+
if(srcChunk->position.y >= fmax(floorf(player.position.y / CHUNK_SIZE_X) + fmin(world.drawDistance, 4), 5)) {
149151
for(int i = CHUNK_SIZE - CHUNK_SIZE_XZ; i < CHUNK_SIZE; i++) {
150152
Block blockDefinition = Block_GetDefinition(srcChunk->data[i]);
151153

client/src/gui/screens.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void Screen_MakeOptions(void) {
151151
//Draw distance Button
152152
if(GuiButton((Rectangle) {offsetX, offsetY - 15, 200, 30 }, drawDistanceTxt)) {
153153
world.drawDistance += 1;
154-
if(world.drawDistance > 6) {
154+
if(world.drawDistance > 8) {
155155
world.drawDistance = 2;
156156
World_Reload();
157157
} else {

client/src/world.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pthread_t chunkThread_id;
2626
void World_Init(void) {
2727
world.mat = LoadMaterialDefault();
2828
world.loadChunks = false;
29-
world.drawDistance = 3;
29+
world.drawDistance = 4;
3030
world.chunks = NULL;
3131

3232
world.entities = MemAlloc(WORLD_MAX_ENTITIES * sizeof(Entity));
@@ -180,7 +180,7 @@ void World_UpdateChunks(void) {
180180
QueuedChunk* curQueued = world.buildChunksQueue;
181181
QueuedChunk* prevQueued = world.buildChunksQueue;
182182

183-
int meshUpdatesCount = 16;
183+
int meshUpdatesCount = 4;
184184

185185
while(curQueued != NULL) {
186186
QueuedChunk *nextQueued = curQueued->next;
@@ -191,7 +191,7 @@ void World_UpdateChunks(void) {
191191
chunk->isBuilding = false;
192192
world.buildChunksQueue = Chunk_RemoveFromQueue(world.buildChunksQueue, prevQueued, curQueued);
193193

194-
if(meshUpdatesCount-- == 0) return;
194+
if(--meshUpdatesCount == 0) return;
195195

196196
curQueued = nextQueued;
197197
continue;
@@ -212,7 +212,7 @@ void World_LoadChunks(void) {
212212
int loadingHeight = fmin(world.drawDistance, 4);
213213
for(int x = -world.drawDistance ; x <= world.drawDistance; x++) {
214214
for(int z = -world.drawDistance ; z <= world.drawDistance; z++) {
215-
for(int y = loadingHeight ; y >= -loadingHeight; y--) {
215+
for(int y = -loadingHeight ; y <= loadingHeight; y++) {
216216
World_AddChunk((Vector3) {pos.x + x, pos.y + y, pos.z + z});
217217
}
218218
}

0 commit comments

Comments
 (0)