medfall

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

commit 65ec2591e48f0d4a314f46ed94bc85138338ff57
parent ff5706bf6b3eddf373065d033b46d6566756c7db
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri Dec  9 20:32:28 +0200

heightmap_height

Diffstat:
btt.cc | 4++--
heightmap.h | 1+
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/btt.cc b/btt.cc @@ -71,8 +71,8 @@ static s32 square_distance( v2s32 u, v2s32 v ) { static bool btt_should_split( const Heightmap * hm, v2s32 v0, v2s32 v1, v2s32 v2, v2s32 mid ) { if( square_distance( v0, v2 ) <= 4 ) return false; - const float avg_height = ( hm->point( v0.x, v0.y ).z + hm->point( v2.x, v2.y ).z ) * 0.5f; - const float error = fabsf( avg_height - hm->point( mid.x, mid.y ).z ); + const float avg_height = ( float( heightmap_height( hm, v0.x, v0.y ) ) + float( heightmap_height( hm, v2.x, v2.y ) ) ) * 0.5f; + const float error = fabsf( avg_height - heightmap_height( hm, mid.x, mid.y ) ); if( error > 2.0f ) return true; diff --git a/heightmap.h b/heightmap.h @@ -21,6 +21,7 @@ struct OffsetHeightmap { }; void heightmap_init( Heightmap * hm, u8 * pixels, u32 width, u32 height ); +u8 heightmap_height( const Heightmap * hm, u32 x, u32 y ); void heightmap_destroy( Heightmap * hm ); struct HeightmapQuadTreeNode {