medfall

A super great game engine
Log | Files | Refs

commit 6f10e986be08f0ced46a7d92c457e93f54c05b5d
parent cec7908f2a59fc9531409ad9925ee951a36c251b
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun, 19 Nov 2017 12:28:08 +0200

Simplify clipmap rendering again

Diffstat:
clipmap.cc | 18++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/clipmap.cc b/clipmap.cc @@ -599,7 +599,8 @@ GAME_FRAME( game_frame ) { for( u32 l = 0; l < NUM_LODS; l++ ) { float scale = checked_cast< float >( u32( 1 ) << l ); v2 tile_size = v2( checked_cast< float >( PATCH_RESOLUTION << l ) ); - v2 base = -v2( checked_cast< float >( PATCH_RESOLUTION << ( l + 1 ) ) ); + v2 snapped_pos = floorf( game->pos.xy() / scale ) * scale; + v2 base = snapped_pos - v2( checked_cast< float >( PATCH_RESOLUTION << ( l + 1 ) ) ); // draw tiles for( int x = 0; x < 4; x++ ) { @@ -610,8 +611,7 @@ GAME_FRAME( game_frame ) { } v2 fill = v2( x >= 2 ? 1 : 0, y >= 2 ? 1 : 0 ) * scale; - v2 tile_tl = base + v2( x, y ) * tile_size + fill + game->pos.xy(); - v2 snapped = floorf( tile_tl / scale ) * scale; + v2 tile_tl = base + v2( x, y ) * tile_size + fill; // draw a low poly tile if the tile is entirely outside the world v2 tile_br = tile_tl + tile_size; @@ -622,7 +622,7 @@ GAME_FRAME( game_frame ) { inside = false; Mesh mesh = inside ? clipmap.gpu.tile : clipmap.gpu.empty_tile; - render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( snapped, scale ); + render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( tile_tl, scale ); renderer_draw_mesh( mesh, render_state ); } } @@ -631,19 +631,17 @@ GAME_FRAME( game_frame ) { for( u32 i = 0; i < 2; i++ ) { // horizontal { - v2 tile_tl = base + v2( i * 3, 2 ) * tile_size + v2( i * scale, 0 ) + game->pos.xy(); - v2 snapped = floorf( tile_tl / scale ) * scale; + v2 tile_tl = base + v2( i * 3, 2 ) * tile_size + v2( i * scale, 0 ); - render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( snapped, scale ); + render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( tile_tl, scale ); renderer_draw_mesh( clipmap.gpu.horizontal_filler, render_state ); } // vertical { - v2 tile_tl = base + v2( 2, i * 3 ) * tile_size + v2( 0, i * scale ) + game->pos.xy(); - v2 snapped = floorf( tile_tl / scale ) * scale; + v2 tile_tl = base + v2( 2, i * 3 ) * tile_size + v2( 0, i * scale ); - render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( snapped, scale ); + render_state.uniforms[ UNIFORMS_CLIPMAP ] = renderer_uniforms( tile_tl, scale ); renderer_draw_mesh( clipmap.gpu.vertical_filler, render_state ); } }