From ff826b1806a6e13a98f67b44549bcfe080784de6 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Wed, 18 Sep 2024 23:11:15 -0400 Subject: [PATCH] Fixed realloc causing segfault (it wasn't realloc) --- terrain.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/terrain.c b/terrain.c index ca77825..29e1aa0 100644 --- a/terrain.c +++ b/terrain.c @@ -43,7 +43,7 @@ #define INIT_MINLIGHT 0.2 #define INIT_PLAYERSPEED \ - { .x = 0, .y = 0, .z = -0.5 } + { .x = 0, .y = 0, .z = -40.5 } // Some globals you can mess around with potentially int fps = 60; @@ -65,7 +65,9 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model) { // Don't allow the model to have more than some amount of faces/vertices. haloo3d_obj_resetfixed(model, CHUNKSIZE * CHUNKSIZE * 4, CHUNKSIZE * CHUNKSIZE * 4); - // Generate the "ocean" floor + // Generate the "ocean" floor. + // TODO: You need to change this to be a large plane that follows the player + // so you can use lighting on the islands but not on the water // haloo3d_gen_paletteuv(0xF26F, model->vtexture[model->numvtextures++].v); struct vec3 seacol = haloo3d_gen_paletteuv(0xF000 | (rand() & 0xFFF)); int seauv = haloo3d_obj_addvtexture(model, seacol); @@ -83,8 +85,7 @@ void gen_terrain(struct vec3i pos, haloo3d_obj *model) { haloo3d_obj_addface(model, face); fastface(face, seauv, br, tr, tl); haloo3d_obj_addface(model, face); - model->numfaces += 2; - // haloo3d_obj_shrinktofit(model); + haloo3d_obj_shrinktofit(model); } // Generate the entity/components/terrain for the chunk at the given