medfall

A super great game engine
Log | Files | Refs

commit 3abebe1b8f077a106949da5a7520e16ca987d8a4
parent a90e3cb42e4b60af9fdcc7d440b67ab0ef19b579
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed, 15 Nov 2017 23:45:54 +0200

Small optimisation

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

diff --git a/clipmap.cc b/clipmap.cc @@ -514,17 +514,11 @@ GAME_FRAME( game_frame ) { UniformBinding sun_uniforms = renderer_uniforms( sun_dir, game->sun_angle ); v2 clipmap_tl; - v2 clipmap_br; - float max_scale; + float scale = 1.0f; + v2 base = v2( -float( PATCH_RESOLUTION * 2 ) ); // draw terrain for( u32 l = 0; l < NUM_LODS; l++ ) { - float scale = 1.0f; - v2 base = v2( -float( PATCH_RESOLUTION * 2 ) ); - for( u32 i = 0; i < l; i++ ) { - scale *= 2.0f; - base *= 2.0f; - } v2 tile_size = v2( scale * float( PATCH_RESOLUTION ) ); for( int x = 0; x < 4; x++ ) { @@ -562,12 +556,14 @@ GAME_FRAME( game_frame ) { } clipmap_tl = base + game->pos.xy(); - max_scale = scale; + scale *= 2.0f; + base *= 2.0f; } - clipmap_tl.x = floorf( clipmap_tl.x / max_scale ) * max_scale; - clipmap_tl.y = floorf( clipmap_tl.y / max_scale ) * max_scale; - clipmap_br = clipmap_tl + v2( 4 * max_scale * float( PATCH_RESOLUTION ) ); + scale /= 2.0f; + clipmap_tl.x = floorf( clipmap_tl.x / scale ) * scale; + clipmap_tl.y = floorf( clipmap_tl.y / scale ) * scale; + v2 clipmap_br = clipmap_tl + v2( 4 * scale * float( PATCH_RESOLUTION ) ); // draw skirts {