medfall

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

commit 7d10a3911e6d018dd6b2648c340190088ada0342
parent 47de7b9ee031d53a3e7542d143d05b7781c9f0bc
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue Feb  2 18:56:20 +0000

Less const

Diffstat:
terrain_manager.cc | 44++++++++++++++++++++++----------------------
terrain_manager.h | 11+++++------
2 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -12,7 +12,7 @@ #include "work_queue.h" #include "stb_image.h" -static const GLchar * const vert_src = GLSL( +static const GLchar * vert_src = GLSL( in vec3 position; in vec3 normal; in float lit; @@ -61,13 +61,13 @@ static const GLchar * frag_src = GLSL( ); static void terrain_load_tile( - TerrainManager * const tm, const u32 tx, const u32 ty, - const u32 vx, const u32 vy + TerrainManager * tm, u32 tx, u32 ty, + u32 vx, u32 vy ) { char path[ 256 ]; sprintf( path, "%s/%d_%d.tga", tm->dir, tx, ty ); - Heightmap * const hm = &tm->tiles[ vx ][ vy ]; + Heightmap * hm = &tm->tiles[ vx ][ vy ]; if( hm->vbo_verts != 0 ) heightmap_destroy( hm ); @@ -87,8 +87,8 @@ static void terrain_load_tile( } void terrain_init( - TerrainManager * const tm, const char * const tiles_dir, - MemoryArena * const arena + TerrainManager * tm, const char * tiles_dir, + MemoryArena * arena ) { assert( strlen( tiles_dir ) < array_count( tm->dir ) ); strcpy( tm->dir, tiles_dir ); @@ -116,7 +116,7 @@ void terrain_init( tm->view_left = tm->view_top = 0; } -void terrain_teleport( TerrainManager * const tm, const glm::vec3 position ) { +void terrain_teleport( TerrainManager * tm, glm::vec3 position ) { if( !tm->first_teleport ) { for( u32 vy = 0; vy < VIEW_SIZE; vy++ ) { for( u32 vx = 0; vx < VIEW_SIZE; vx++ ) { @@ -127,8 +127,8 @@ void terrain_teleport( TerrainManager * const tm, const glm::vec3 position ) { tm->first_teleport = false; - const u32 player_tile_x = position.x / TILE_SIZE; - const u32 player_tile_y = position.y / TILE_SIZE; + u32 player_tile_x = position.x / TILE_SIZE; + u32 player_tile_y = position.y / TILE_SIZE; tm->tile_x = player_tile_x; tm->tile_y = player_tile_y; @@ -151,9 +151,9 @@ static u32 view_add( u32 v, u32 o ) { return ( v + o ) % VIEW_SIZE; } -void terrain_update( TerrainManager * const tm, const glm::vec3 position ) { - const u32 player_tile_x = position.x / TILE_SIZE; - const u32 player_tile_y = position.y / TILE_SIZE; +void terrain_update( TerrainManager * tm, glm::vec3 position ) { + u32 player_tile_x = position.x / TILE_SIZE; + u32 player_tile_y = position.y / TILE_SIZE; if( player_tile_x != tm->tile_x ) { if( player_tile_x > tm->tile_x ) { @@ -210,8 +210,8 @@ 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 ) { - const glm::vec3 sun = glm::normalize( glm::vec3( 1, 0, -sun_slope ) ); +void terrain_render( const TerrainManager * tm, glm::mat4 VP, float sun_slope ) { + glm::vec3 sun = glm::normalize( glm::vec3( 1, 0, -sun_slope ) ); glUseProgram( tm->shader ); @@ -231,23 +231,23 @@ void terrain_render( const TerrainManager * const tm, const glm::mat4 VP, const // it's probably worth using view_x/y instead of view_left/top // and using signed arithmetic to make this less annoying // also implement the bounded arithmetic class -float terrain_height( const TerrainManager * const tm, const glm::vec3 position ) { +float terrain_height( const TerrainManager * tm, glm::vec3 position ) { // see doodles/tile_coords_to_view_coords.png for docs - const u32 player_tile_x = position.x / TILE_SIZE; - const u32 player_tile_y = position.y / TILE_SIZE; + u32 player_tile_x = position.x / TILE_SIZE; + u32 player_tile_y = position.y / TILE_SIZE; if( player_tile_x < tm->tile_x ) assert( tm->tile_x - player_tile_x <= VIEW_HALF ); else assert( player_tile_x - tm->tile_x <= VIEW_HALF ); if( player_tile_y < tm->tile_y ) assert( tm->tile_y - player_tile_y <= VIEW_HALF ); else assert( player_tile_y - tm->tile_y <= VIEW_HALF ); - const u32 dx = player_tile_x - tm->tile_x; - const u32 dy = player_tile_y - tm->tile_y; + u32 dx = player_tile_x - tm->tile_x; + u32 dy = player_tile_y - tm->tile_y; - const u32 vx = view_add( tm->view_left, VIEW_HALF + dx ); - const u32 vy = view_add( tm->view_top, VIEW_HALF + dy ); + u32 vx = view_add( tm->view_left, VIEW_HALF + dx ); + u32 vy = view_add( tm->view_top, VIEW_HALF + dy ); - const Heightmap * const hm = &tm->tiles[ vx ][ vy ]; + const Heightmap * hm = &tm->tiles[ vx ][ vy ]; return hm->bilerp_height( position.x - player_tile_x * TILE_SIZE, position.y - player_tile_y * TILE_SIZE ); diff --git a/terrain_manager.h b/terrain_manager.h @@ -38,11 +38,10 @@ struct TerrainManager { Heightmap tiles[ VIEW_SIZE ][ VIEW_SIZE ]; }; -void terrain_init( TerrainManager * const tm, const char * const tiles_dir, - 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 ); -float terrain_height( const TerrainManager * const tm, const glm::vec3 position ); +void terrain_init( TerrainManager * tm, const char * tiles_dir, MemoryArena * arena ); +void terrain_teleport( TerrainManager * tm, glm::vec3 position ); +void terrain_update( TerrainManager * tm, glm::vec3 position ); +void terrain_render( const TerrainManager * tm, glm::mat4 VP, float sun_slope ); +float terrain_height( const TerrainManager * tm, glm::vec3 position ); #endif // _TERRAIN_MANAGER_H_