commit 486dd04df7da8b617f86dbebe3d23f0218520291
parent de180fdeded5a7f4cac78cc38488a9cee342d8b9
Author: Michael Savage <mikejsavage@gmail.com>
Date: Tue, 21 Nov 2017 21:07:39 +0200
Fix missing triangles at the start of the trim mesh
Diffstat:
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/clipmap.cc b/clipmap.cc
@@ -326,13 +326,16 @@ GAME_INIT( game_init ) {
array< v3 > vertices = alloc_array< v3 >( &mem->persistent_arena, ( CLIPMAP_VERT_RESOLUTION * 2 + 1 ) * 2 );
size_t n = 0;
+
+ // vertical part of L
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 );
+ vertices[ n++ ] = v3( 0, CLIPMAP_VERT_RESOLUTION - i, 0 );
+ vertices[ n++ ] = v3( 1, CLIPMAP_VERT_RESOLUTION - i, 0 );
}
- size_t start_of_second_set = n;
+ size_t start_of_horizontal = n;
+ // horizontal part of L
for( u32 i = 0; i < CLIPMAP_VERT_RESOLUTION; i++ ) {
vertices[ n++ ] = v3( i + 1, 0, 0 );
vertices[ n++ ] = v3( i + 1, 1, 0 );
@@ -358,13 +361,13 @@ GAME_INIT( game_init ) {
}
for( u32 i = 0; i < CLIPMAP_VERT_RESOLUTION - 1; i++ ) {
- indices[ n++ ] = start_of_second_set + ( i + 0 ) * 2 + 1;
- indices[ n++ ] = start_of_second_set + ( i + 0 ) * 2 + 0;
- indices[ n++ ] = start_of_second_set + ( i + 1 ) * 2 + 0;
+ indices[ n++ ] = start_of_horizontal + ( i + 0 ) * 2 + 1;
+ indices[ n++ ] = start_of_horizontal + ( i + 0 ) * 2 + 0;
+ indices[ n++ ] = start_of_horizontal + ( i + 1 ) * 2 + 0;
- indices[ n++ ] = start_of_second_set + ( i + 1 ) * 2 + 1;
- indices[ n++ ] = start_of_second_set + ( i + 0 ) * 2 + 1;
- indices[ n++ ] = start_of_second_set + ( i + 1 ) * 2 + 0;
+ indices[ n++ ] = start_of_horizontal + ( i + 1 ) * 2 + 1;
+ indices[ n++ ] = start_of_horizontal + ( i + 0 ) * 2 + 1;
+ indices[ n++ ] = start_of_horizontal + ( i + 1 ) * 2 + 0;
}
ASSERT( n == indices.n );