medfall

A super great game engine
Log | Files | Refs

commit b13d658fda0ded9da7f0752c050f8d1ffcee31b8
parent 51bcb8123eaec7034a99c74113ac800a264bcfa8
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri, 10 Nov 2017 21:59:50 +0200

Use bc5_to_heightmap in pp

Diffstat:
make.lua | 4++--
pp.cc | 24++++++++----------------
2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/make.lua b/make.lua @@ -18,7 +18,7 @@ if OS == "macos" then game_ldflags = "-framework Cocoa -framework CoreVideo -framework IOKit" end -bin( "medfall", { "main", "clipmap", "heightmap", "skybox", "decompress_bc", "platform_network", game_objs }, { "lz4", game_libs } ) +bin( "medfall", { "main", "clipmap", "heightmap", "decompress_bc", "skybox", "platform_network", game_objs }, { "lz4", game_libs } ) msvc_bin_ldflags( "medfall", "opengl32.lib gdi32.lib" ) gcc_bin_ldflags( "medfall", game_ldflags ) @@ -60,7 +60,7 @@ if OS == "macos" then bin_ldflags( "sound", "-framework AudioUnit" ) end -bin( "pp", { "pp", "decompress_bc", common_objs }, { "lz4", "squish", "stb_image", "stb_image_write" } ) +bin( "pp", { "pp", "heightmap", "heightmap", "decompress_bc", common_objs }, { "lz4", "squish", "stb_image", "stb_image_write" } ) gcc_obj_cxxflags( "pp", "-O2" ) msvc_obj_cxxflags( "pp", "/O2" ) diff --git a/pp.cc b/pp.cc @@ -357,28 +357,20 @@ int main( int argc, char ** argv ) { MEMARENA_SCOPED_CHECKPOINT( &arena ); printf( "computing quadtree\n" ); - array2d< u16 > heightmap1 = alloc_array2d< u16 >( &arena, heightmap.w + 1, heightmap.h + 1 ); + array2d< u16 > decoded = alloc_array2d< u16 >( &arena, heightmap.w, heightmap.h ); + bc5_to_heightmap( &arena, decoded, bc5_heightmap ); - // TODO: this should just use bc5_to_heightmap once the Heightmap stuff is cleaned up - { - MEMARENA_SCOPED_CHECKPOINT( &arena ); - array2d< v2 > rg = alloc_array2d< v2 >( &arena, heightmap.w, heightmap.h ); - decompress_bc5( rg, bc5_heightmap ); - - v2 zero( 0, 0 ); - for( u32 y = 0; y < heightmap1.h; y++ ) { - for( u32 x = 0; x < heightmap1.w; x++ ) { - float r = rg.try_get( x, y, zero ).x; - float g = rg.try_get( x, y, zero ).y; - heightmap1( x, y ) = u16( ( r * 256.0f + g ) * 255.0f ); - } + array2d< u16 > decoded1 = alloc_array2d< u16 >( &arena, heightmap.w + 1, heightmap.h + 1 ); + for( size_t y = 0; y < decoded1.h; y++ ) { + for( size_t x = 0; x < decoded1.w; x++ ) { + decoded1( x, y ) = decoded.try_get( x, y, 0 ); } } - size_t num_nodes = quadtree_max_nodes( heightmap1.w, heightmap1.h ); + size_t num_nodes = quadtree_max_nodes( decoded1.w, decoded1.h ); array< QuadTreeNode > nodes = alloc_array< QuadTreeNode >( &arena, num_nodes ); - build_quadtree( heightmap1, nodes ); + build_quadtree( decoded1, nodes ); printf( "compressing\n" ); DynamicString quadtree_path( "{}/quadtree.lz4", output_path );