medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 2c5071a3ceebad61c9d7a33e4799eab8279beca5
parent 092e1bd68cea7962465f6f45757790825855ad04
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Oct 18 15:24:35 +0100

Small cleanup

Diffstat:
gpubtt.cc | 18++++++++++++------
gpubtt.h | 2+-
heightmap.cc | 12++++++------
heightmap.h | 2+-
terrain_manager.cc | 6+++---
terrain_manager.h | 4++--
6 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/gpubtt.cc b/gpubtt.cc @@ -43,20 +43,26 @@ static void gpubtt_build( } void gpubtt_init( - MemoryArena * const mem, GPUBTT * const gpubtt, + MemoryArena * const arena, GPUBTT * const gpubtt, const OffsetHeightmap * const ohm, const BTTs btts, const GLuint at_position ) { - MEMARENA_SCOPED_CHECKPOINT( mem ); + MEMARENA_SCOPED_CHECKPOINT( arena ); const u32 num_leaves = btt_count_leaves( btts.left_root ) + btt_count_leaves( btts.right_root ); - glm::vec3 * const verts = memarena_push_many( mem, glm::vec3, num_leaves * 3 ); + glm::vec3 * const verts = memarena_push_many( arena, glm::vec3, num_leaves * 3 ); u32 i = 0; - gpubtt_build( verts, &i, ohm, btts.left_root, glm::ivec2( 0, 0 ), glm::ivec2( 0, ohm->hm.height - 1 ), glm::ivec2( ohm->hm.width - 1, ohm->hm.height - 1 ) ); - gpubtt_build( verts, &i, ohm, btts.right_root, glm::ivec2( ohm->hm.width - 1, ohm->hm.height - 1 ), glm::ivec2( ohm->hm.width - 1, 0 ), glm::ivec2( 0, 0 ) ); + // bottom left, bottom right, top left, top right + const glm::ivec2 bl( 0, 0 ); + const glm::ivec2 br( ohm->hm.width - 1, 0 ); + const glm::ivec2 tl( 0, ohm->hm.height - 1 ); + const glm::ivec2 tr( ohm->hm.width - 1, ohm->hm.height - 1 ); + + gpubtt_build( verts, &i, ohm, btts.left_root, bl, tl, tr ); + gpubtt_build( verts, &i, ohm, btts.right_root, tr, br, bl ); glGenVertexArrays( 1, &gpubtt->vao ); glBindVertexArray( gpubtt->vao ); @@ -67,7 +73,7 @@ void gpubtt_init( glEnableVertexAttribArray( at_position ); glVertexAttribPointer( at_position, 3, GL_FLOAT, GL_FALSE, 0, 0 ); - glm::vec3 * const normals = memarena_push_many( mem, glm::vec3, ohm->hm.width * ohm->hm.height ); + glm::vec3 * const normals = memarena_push_many( arena, glm::vec3, ohm->hm.width * ohm->hm.height ); for( u32 y = 0; y < ohm->hm.height; y++ ) { for( u32 x = 0; x < ohm->hm.width; x++ ) { diff --git a/gpubtt.h b/gpubtt.h @@ -13,7 +13,7 @@ struct GPUBTT { u32 num_verts; }; -void gpubtt_init( MemoryArena * const mem, GPUBTT * const gpubtt, +void gpubtt_init( MemoryArena * const arena, GPUBTT * const gpubtt, const OffsetHeightmap * const ohm, const BTTs btts, const GLuint at_position ); diff --git a/heightmap.cc b/heightmap.cc @@ -45,7 +45,7 @@ static glm::vec3 triangle_perp_ccw( const glm::vec3 & a, const glm::vec3 & b, co } void heightmap_init( - Heightmap * const hm, MemoryArena * const mem, + Heightmap * const hm, MemoryArena * const arena, u8 * const pixels, const u32 width, const u32 height, const float ox, const float oy, const GLint at_pos, const GLint at_normal, const GLint at_lit @@ -54,12 +54,12 @@ void heightmap_init( hm->width = width; hm->height = height; - MEMARENA_SCOPED_CHECKPOINT( mem ); + MEMARENA_SCOPED_CHECKPOINT( arena ); - GLfloat * const vertices = memarena_push_many( mem, GLfloat, width * height * 3 ); - GLfloat * const normals = memarena_push_many( mem, GLfloat, width * height * 3 ); - GLuint * const indices = memarena_push_many( mem, GLuint, width * height * 6 ); - GLfloat * const lit = memarena_push_many( mem, GLfloat, width * height ); + GLfloat * const vertices = memarena_push_many( arena, GLfloat, width * height * 3 ); + GLfloat * const normals = memarena_push_many( arena, GLfloat, width * height * 3 ); + GLuint * const indices = memarena_push_many( arena, GLuint, width * height * 6 ); + GLfloat * const lit = memarena_push_many( arena, GLfloat, width * height ); for( u32 i = 0; i < width * height; i++ ) { lit[ i ] = 0; diff --git a/heightmap.h b/heightmap.h @@ -33,7 +33,7 @@ struct OffsetHeightmap { float x_offset, y_offset; }; -void heightmap_init( Heightmap * const hm, MemoryArena * const mem, +void heightmap_init( Heightmap * const hm, MemoryArena * const arena, u8 * const pixels, const u32 width, const u32 height, const float ox, const float oy, // TODO: take rendering out of Heightmap const GLint at_pos, const GLint at_normal, const GLint at_lit ); diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -80,19 +80,19 @@ static void terrain_load_tile( if( !pixels ) err( 1, "stbi_load failed (%s)", stbi_failure_reason() ); - heightmap_init( hm, tm->mem, pixels, width, height, + heightmap_init( hm, tm->arena, pixels, width, height, tx * TILE_SIZE, ty * TILE_SIZE, tm->at_pos, tm->at_normal, tm->at_lit ); } void terrain_init( TerrainManager * const tm, const char * const tiles_dir, - MemoryArena * const mem + MemoryArena * const arena ) { assert( strlen( tiles_dir ) < array_count( tm->dir ) ); strcpy( tm->dir, tiles_dir ); - tm->mem = mem; + tm->arena = arena; char dims_path[ 256 ]; sprintf( dims_path, "%s/dims.txt", tm->dir ); diff --git a/terrain_manager.h b/terrain_manager.h @@ -16,7 +16,7 @@ static const u32 VIEW_HALF = VIEW_SIZE / 2; struct TerrainManager { char dir[ 128 ]; - MemoryArena * mem; + MemoryArena * arena; u32 width, height; @@ -39,7 +39,7 @@ struct TerrainManager { }; void terrain_init( TerrainManager * const tm, const char * const tiles_dir, - MemoryArena * const mem ); + MemoryArena * const arena ); void terrain_teleport( TerrainManager * const tm, const glm::vec3 position ); void terrain_update( TerrainManager * const tm, const glm::vec3 position ); void terrain_render( const TerrainManager * const tm, const glm::mat4 VP, const float sun_slope );