~jb55/polyadvent

b1a46d36e722165b16cd948a1169d0da9194e62d — William Casarin 1 year, 7 months ago e584a50
fix terrain collision index oob issues

Signed-off-by: William Casarin <jb55@jb55.com>
2 files changed, 5 insertions(+), 4 deletions(-)

M src/game.c
M src/terrain.c
M src/game.c => src/game.c +4 -3
@@ 106,7 106,7 @@ void game_init(struct game *game, int width, int height) {
    game->quit = 0;
    game->frame = 0;

    const double size = 10000.0;
    const double size = 5000.0;
    double scale = 0.03;

    terrain->settings = (struct perlin_settings){


@@ 127,9 127,10 @@ void game_init(struct game *game, int width, int height) {

    init_terrain(terrain, size);
    int seed;
    terrain->samples = load_samples(&seed, &terrain->n_samples);
    /* terrain->samples = load_samples(&seed, &terrain->n_samples); */
    terrain->n_samples = 0;
    create_terrain(terrain, size, game->seed);
    /* update_terrain(terrain); */
    /* update_terrain(terrain, terrain->cell_size); */

    /* get_entity(&terrain->entity_id)->flags |= ENT_INVISIBLE; */


M src/terrain.c => src/terrain.c +1 -1
@@ 213,7 213,7 @@ void create_terrain(struct terrain *terrain, float scale, int seed) {
    del_point2d_t *points = calloc(terrain->n_samples, sizeof(*points));
    float *verts = calloc(terrain->n_samples * 3, sizeof(*verts));
    terrain->cell_size = pdist;
    terrain->n_cells = round(size / terrain->cell_size);
    terrain->n_cells = round(size / terrain->cell_size) + 1;
    debug("n_cells %d\n", terrain->n_cells);

    struct terrain_cell *grid =