medfall

A super great game engine
Log | Files | Refs

commit 904de8a998a57bec60569c5462ff31c51f490812
parent 311d02b1b11913a438f7ded4a2a2c51f3c44074f
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Jul  2 16:01:53 +0300

Fix tree planting being slightly off

Diffstat:
pp.cc | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/pp.cc b/pp.cc @@ -58,8 +58,7 @@ static void compute_horizons( MemoryArena * arena, const array2d< u16 > heightmap, array2d< float > horizons ) { - ASSERT( heightmap.w == horizons.w ); - ASSERT( heightmap.h == horizons.h ); + ASSERT( heightmap.w == horizons.w && heightmap.h == horizons.h ); for( size_t y = 0; y < heightmap.h; y++ ) { compute_row_of_horizons( arena, heightmap, horizons, y ); @@ -120,10 +119,10 @@ const size_t MAX_TREES = 262144 / 4; static bool ok_tree_position( RNGWell512 * rng, const array2d< u16 > heightmap, const array2d< v3 > normals, v2 pos, v3 * tree ) { u16 height = bilerp01( heightmap, pos.x, pos.y ); double p = 1; - if( height <= 5 * 5 ) return false; - if( height > 235 * 235 ) return false; - if( height >= 200 * 200 ) { - p *= double( 235 * 235 - height ) / double( 235 * 235 - 200 * 200 ); + if( height <= 5 * 256 ) return false; + if( height > 235 * 256 ) return false; + if( height >= 200 * 256 ) { + p *= double( 235 * 256 - height ) / double( 235 * 256 - 200 * 256 ); } v3 normal = normalize( bilerp01( normals, pos.x, pos.y ) );