Skip to content

Commit a0ebe8c

Browse files
Fix inflexible chunk size
Chunk size should now be customizable depending on use case.
1 parent e769860 commit a0ebe8c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

engine/chunk_globals.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
//#define WORLD_SIZE_X 12 //amount of chunks in x orientation
77
//#define WORLD_SIZE_Y 12 //amount of chunks in y orientation
88

9-
#define CHUNK_SIZE (FIXED_POINT_FACTOR * 10) //10 meter size per chunk
9+
#define CHUNK_UNITS 10 //10 meter size per chunk (max is around 64)
10+
11+
#define CHUNK_SIZE (FIXED_POINT_FACTOR * CHUNK_UNITS) //Total fixed point representation of one chunk
1012
//starting location of chunks in world coordinates
1113
#define CHUNK_OFFSET_X (-(WORLD_SIZE_X * CHUNK_SIZE) / 2)
1214
#define CHUNK_OFFSET_Y (-(WORLD_SIZE_Y * CHUNK_SIZE) / 2)

engine/render_camera.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "render_globals.h"
2+
#include "chunk_globals.h"
23
#include "render_math.h"
34

45
float camera_position[3] = {0.0, 0.0, 0.0};
@@ -120,12 +121,12 @@ void render_view_projection() {
120121
float old_position_z = camera_position[2];
121122

122123
//calculate and update needed global offsets
123-
global_offset_x = camera_position[0] / 10;
124-
global_offset_z = camera_position[2] / 10;
124+
global_offset_x = camera_position[0] / CHUNK_UNITS;
125+
global_offset_z = camera_position[2] / CHUNK_UNITS;
125126

126127
//we update the camera position to the new one and move the camera
127-
camera_position[0] -= global_offset_x * 10;
128-
camera_position[2] -= global_offset_z * 10;
128+
camera_position[0] -= global_offset_x * CHUNK_UNITS;
129+
camera_position[2] -= global_offset_z * CHUNK_UNITS;
129130

130131
update_camera();
131132

game/logic_menu.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ void display_menu() {
6969
#else
7070
if (demo_progress < 2500) {
7171
text("Pico3D Engine", 28, 20);
72-
text("by: Bernhard Strobl", 10, 30);
7372
}
7473

7574
if ((demo_progress / 32) % 2 == 0) {

0 commit comments

Comments
 (0)