medfall

A super great game engine
Log | Files | Refs

commit e2fb4d86ff3579d48ec7564a367148aeb8a95e83
parent c44b3af3425d6f8db8737a037e7cf6933213a954
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Tue, 21 Nov 2017 00:39:09 +0200

Small clipmap cleanup

Diffstat:
clipmap.cc | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/clipmap.cc b/clipmap.cc @@ -208,6 +208,8 @@ GAME_INIT( game_init ) { } } + ASSERT( n == vertices.n ); + array< u32 > indices = alloc_array< u32 >( &mem->persistent_arena, PATCH_RESOLUTION * PATCH_RESOLUTION * 6 ); n = 0; @@ -223,6 +225,8 @@ GAME_INIT( game_init ) { } } + ASSERT( n == indices.n ); + MeshConfig mesh_config; mesh_config.positions = renderer_new_vb( vertices ); mesh_config.indices = renderer_new_ib( indices ); @@ -320,20 +324,22 @@ GAME_INIT( game_init ) { { MEMARENA_SCOPED_CHECKPOINT( &mem->persistent_arena ); - array< v3 > vertices = alloc_array< v3 >( &mem->persistent_arena, ( PATCH_RESOLUTION * 4 + 2 ) * 4 - 2 ); + array< v3 > vertices = alloc_array< v3 >( &mem->persistent_arena, ( CLIPMAP_VERT_RESOLUTION * 2 + 1 ) * 2 ); size_t n = 0; - for( u32 i = 0; i < CLIPMAP_VERT_RESOLUTION; i++ ) { + for( u32 i = 0; i < CLIPMAP_VERT_RESOLUTION + 1; i++ ) { vertices[ n++ ] = v3( 0, PATCH_RESOLUTION * 4 + 1 - i, 0 ); vertices[ n++ ] = v3( 1, PATCH_RESOLUTION * 4 + 1 - i, 0 ); } size_t start_of_second_set = n; - for( u32 i = 0; i < CLIPMAP_VERT_RESOLUTION - 1; i++ ) { + for( u32 i = 0; i < CLIPMAP_VERT_RESOLUTION; i++ ) { vertices[ n++ ] = v3( i + 1, 0, 0 ); vertices[ n++ ] = v3( i + 1, 1, 0 ); } + ASSERT( n == vertices.n ); + for( v3 & v : vertices ) { v -= v3( 0.5f * v2( CLIPMAP_VERT_RESOLUTION + 1 ), 0 ); } @@ -361,6 +367,8 @@ GAME_INIT( game_init ) { indices[ n++ ] = start_of_second_set + ( i + 1 ) * 2 + 0; } + ASSERT( n == indices.n ); + MeshConfig mesh_config; mesh_config.positions = renderer_new_vb( vertices ); mesh_config.indices = renderer_new_ib( indices );