medfall

A super great game engine
Log | Files | Refs

commit f56bff1f06655ffdb37fdb4bb9e958d11f105b0d
parent 41a981b19860ac029c2544b2f252623f9b94857a
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat, 23 Dec 2017 19:45:19 +0200

Naming changes

Diffstat:
clipmap.cc | 72++++++++++++++++++++++++++++++++++++------------------------------------
1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/clipmap.cc b/clipmap.cc @@ -72,11 +72,11 @@ static VB trees_instance_data; static u32 num_trees; static Mesh tree_mesh; -static constexpr u32 PATCH_RESOLUTION = 48; -static constexpr u32 PATCH_VERT_RESOLUTION = PATCH_RESOLUTION + 1; -static constexpr u32 CLIPMAP_RESOLUTION = PATCH_RESOLUTION * 4 + 1; +static constexpr u32 TILE_RESOLUTION = 48; +static constexpr u32 PATCH_VERT_RESOLUTION = TILE_RESOLUTION + 1; +static constexpr u32 CLIPMAP_RESOLUTION = TILE_RESOLUTION * 4 + 1; static constexpr u32 CLIPMAP_VERT_RESOLUTION = CLIPMAP_RESOLUTION + 1; -static constexpr u32 NUM_LODS = 7; +static constexpr u32 NUM_CLIPMAP_LEVELS = 7; static void load_trees( MemoryArena * arena ) { MEMARENA_SCOPED_CHECKPOINT( arena ); @@ -209,11 +209,11 @@ GAME_INIT( game_init ) { ASSERT( n == vertices.n ); - array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, PATCH_RESOLUTION * PATCH_RESOLUTION * 6 ); + array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, TILE_RESOLUTION * TILE_RESOLUTION * 6 ); n = 0; - for( u32 y = 0; y < PATCH_RESOLUTION; y++ ) { - for( u32 x = 0; x < PATCH_RESOLUTION; x++ ) { + for( u32 y = 0; y < TILE_RESOLUTION; y++ ) { + for( u32 x = 0; x < TILE_RESOLUTION; x++ ) { indices[ n++ ] = patch2d( x, y ); indices[ n++ ] = patch2d( x + 1, y + 1 ); indices[ n++ ] = patch2d( x, y + 1 ); @@ -237,21 +237,21 @@ GAME_INIT( game_init ) { { MEMARENA_SCOPED_CHECKPOINT( &mem->persistent_arena ); - array< v3 > vertices = alloc_array< v3 >( &mem->persistent_arena, PATCH_RESOLUTION * 4 + 1 ); + array< v3 > vertices = alloc_array< v3 >( &mem->persistent_arena, TILE_RESOLUTION * 4 + 1 ); // vertices[ 0 ] is the centre of the fan - vertices[ 0 ] = v3( v2( PATCH_RESOLUTION / 2.0f ), 0 ); + vertices[ 0 ] = v3( v2( TILE_RESOLUTION / 2.0f ), 0 ); - for( u32 i = 0; i < PATCH_RESOLUTION; i++ ) { - vertices[ i + 1 + 0 * PATCH_RESOLUTION ] = v3( i, 0, 0 ); - vertices[ i + 1 + 1 * PATCH_RESOLUTION ] = v3( PATCH_RESOLUTION, i, 0 ); - vertices[ i + 1 + 2 * PATCH_RESOLUTION ] = v3( PATCH_RESOLUTION - i, PATCH_RESOLUTION, 0 ); - vertices[ i + 1 + 3 * PATCH_RESOLUTION ] = v3( 0, PATCH_RESOLUTION - i, 0 ); + for( u32 i = 0; i < TILE_RESOLUTION; i++ ) { + vertices[ i + 1 + 0 * TILE_RESOLUTION ] = v3( i, 0, 0 ); + vertices[ i + 1 + 1 * TILE_RESOLUTION ] = v3( TILE_RESOLUTION, i, 0 ); + vertices[ i + 1 + 2 * TILE_RESOLUTION ] = v3( TILE_RESOLUTION - i, TILE_RESOLUTION, 0 ); + vertices[ i + 1 + 3 * TILE_RESOLUTION ] = v3( 0, TILE_RESOLUTION - i, 0 ); } - array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, PATCH_RESOLUTION * 12 ); + array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, TILE_RESOLUTION * 12 ); - for( u32 i = 0; i < PATCH_RESOLUTION * 4; i++ ) { + for( u32 i = 0; i < TILE_RESOLUTION * 4; i++ ) { indices[ i * 3 + 0 ] = 0; indices[ i * 3 + 1 ] = i + 1; indices[ i * 3 + 2 ] = i + 2; @@ -273,7 +273,7 @@ GAME_INIT( game_init ) { array< v3 > vertices = alloc_array< v3 >( &mem->persistent_arena, PATCH_VERT_RESOLUTION * 8 ); size_t n = 0; - u32 offset = PATCH_RESOLUTION; + u32 offset = TILE_RESOLUTION; for( u32 i = 0; i < PATCH_VERT_RESOLUTION; i++ ) { vertices[ n++ ] = v3( offset + i + 1, 0, 0 ); @@ -297,12 +297,12 @@ GAME_INIT( game_init ) { ASSERT( n == vertices.n ); - array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, PATCH_RESOLUTION * 24 ); + array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, TILE_RESOLUTION * 24 ); n = 0; - for( u32 i = 0; i < PATCH_RESOLUTION * 4; i++ ) { + for( u32 i = 0; i < TILE_RESOLUTION * 4; i++ ) { // the arms shouldn't be connected to each other - u32 arm = i / PATCH_RESOLUTION; + u32 arm = i / TILE_RESOLUTION; u32 bl = ( arm + i ) * 2 + 0; u32 br = ( arm + i ) * 2 + 1; @@ -404,25 +404,25 @@ GAME_INIT( game_init ) { // horizontal vertices for( u32 i = 0; i < PATCH_VERT_RESOLUTION * 2; i++ ) { - vertices[ n++ ] = v3( i - float( PATCH_RESOLUTION ), 0, 0 ); - vertices[ n++ ] = v3( i - float( PATCH_RESOLUTION ), 1, 0 ); + vertices[ n++ ] = v3( i - float( TILE_RESOLUTION ), 0, 0 ); + vertices[ n++ ] = v3( i - float( TILE_RESOLUTION ), 1, 0 ); } size_t start_of_vertical = n; // vertical vertices for( u32 i = 0; i < PATCH_VERT_RESOLUTION * 2; i++ ) { - vertices[ n++ ] = v3( 0, i - float( PATCH_RESOLUTION ), 0 ); - vertices[ n++ ] = v3( 1, i - float( PATCH_RESOLUTION ), 0 ); + vertices[ n++ ] = v3( 0, i - float( TILE_RESOLUTION ), 0 ); + vertices[ n++ ] = v3( 1, i - float( TILE_RESOLUTION ), 0 ); } ASSERT( n == vertices.n ); - array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, PATCH_RESOLUTION * 24 + 6 ); + array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, TILE_RESOLUTION * 24 + 6 ); n = 0; // horizontal indices - for( u32 i = 0; i < PATCH_RESOLUTION * 2 + 1; i++ ) { + for( u32 i = 0; i < TILE_RESOLUTION * 2 + 1; i++ ) { u32 bl = i * 2 + 0; u32 br = i * 2 + 1; u32 tl = i * 2 + 2; @@ -437,8 +437,8 @@ GAME_INIT( game_init ) { } // vertical indices - for( u32 i = 0; i < PATCH_RESOLUTION * 2 + 1; i++ ) { - if( i == PATCH_RESOLUTION ) + for( u32 i = 0; i < TILE_RESOLUTION * 2 + 1; i++ ) { + if( i == TILE_RESOLUTION ) continue; u32 bl = i * 2 + 0; @@ -499,8 +499,8 @@ GAME_INIT( game_init ) { // generate skirt mesh { - float scale = checked_cast< float >( u32( 1 ) << ( NUM_LODS - 1 ) ); - v2 base = -v2( checked_cast< float >( PATCH_RESOLUTION << NUM_LODS ) ); + float scale = checked_cast< float >( u32( 1 ) << ( NUM_CLIPMAP_LEVELS - 1 ) ); + v2 base = -v2( checked_cast< float >( TILE_RESOLUTION << NUM_CLIPMAP_LEVELS ) ); v2 clipmap_tl = base; v2 clipmap_br = clipmap_tl + v2( CLIPMAP_RESOLUTION * scale ); @@ -798,13 +798,13 @@ GAME_FRAME( game_frame ) { renderer_draw_mesh( clipmap.gpu.cross, render_state ); } - for( u32 l = 0; l < NUM_LODS; l++ ) { + for( u32 l = 0; l < NUM_CLIPMAP_LEVELS; l++ ) { float scale = checked_cast< float >( u32( 1 ) << l ); v2 snapped_pos = floorf( game->frozen_pos.xy() / scale ) * scale; // draw tiles - v2 tile_size = v2( checked_cast< float >( PATCH_RESOLUTION << l ) ); - v2 base = snapped_pos - v2( checked_cast< float >( PATCH_RESOLUTION << ( l + 1 ) ) ); + v2 tile_size = v2( checked_cast< float >( TILE_RESOLUTION << l ) ); + v2 base = snapped_pos - v2( checked_cast< float >( TILE_RESOLUTION << ( l + 1 ) ) ); for( int x = 0; x < 4; x++ ) { for( int y = 0; y < 4; y++ ) { @@ -838,7 +838,7 @@ GAME_FRAME( game_frame ) { renderer_draw_mesh( clipmap.gpu.filler, render_state ); } - if( l != NUM_LODS - 1 ) { + if( l != NUM_CLIPMAP_LEVELS - 1 ) { float next_scale = scale * 2.0f; v2 next_snapped_pos = floorf( game->frozen_pos.xy() / next_scale ) * next_scale; @@ -858,7 +858,7 @@ GAME_FRAME( game_frame ) { // draw seam { - v2 next_base = next_snapped_pos - v2( checked_cast< float >( PATCH_RESOLUTION << ( l + 1 ) ) ); + v2 next_base = next_snapped_pos - v2( checked_cast< float >( TILE_RESOLUTION << ( l + 1 ) ) ); render_state.uniforms[ UNIFORMS_MODEL ] = rotation_uniforms[ 0 ]; render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( next_base, scale ); @@ -870,7 +870,7 @@ GAME_FRAME( game_frame ) { // draw skirts { - float scale = checked_cast< float >( u32( 1 ) << ( NUM_LODS - 1 ) ); + float scale = checked_cast< float >( u32( 1 ) << ( NUM_CLIPMAP_LEVELS - 1 ) ); RenderState skirt_render_state; skirt_render_state.shader = get_shader( SHADER_CLIPMAP_SKIRT );