medfall

A super great game engine
Log | Files | Refs

commit 1a18a691c6f69a335a68738d4f84dbb09575c368
parent 894dfcb81e3296d0311cfa0f9f050b9b61c1527e
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Jul 15 14:20:36 +0300

Tightly bound quadtree node arrays

Diffstat:
heightmap.cc | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/heightmap.cc b/heightmap.cc @@ -217,9 +217,8 @@ static void heightmap_build_quadtree_node( HeightmapQuadTree * qt, size_t node_i size_t heightmap_quadtree_max_nodes( const Heightmap * hm ) { // with a power of 2 + 1 sized quadtree with a 2x2 bottom level it - // should be exactly 1/3 (1/4 + 1/16 + ...) but with other sizes it - // gets funny. 0.34 seems to work with minimal wasted space - return size_t( 0.34 * ( hm->width - 1 ) * ( hm->width - 1 ) ); + // should be exactly 1/3 (1/4 + 1/16 + ...) + return ( ( hm->width - 1 ) * ( hm->width - 1 ) ) / 3; } HeightmapQuadTree heightmap_build_quadtree( const Heightmap * hm, array< HeightmapQuadTreeNode > & nodes ) { @@ -229,7 +228,6 @@ HeightmapQuadTree heightmap_build_quadtree( const Heightmap * hm, array< Heightm qt.hm = hm; qt.dim = hm->width - 1; qt.nodes = nodes; - memset( qt.nodes.ptr(), 0, qt.nodes.num_bytes() ); AABBu32 aabb( v3u32( 0, 0, 0 ), v3u32( qt.dim, qt.dim, U16_MAX ) ); heightmap_build_quadtree_node( &qt, 0, aabb );