From 3494503be52ee50b21e78c8ada30620210db6511 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 21 Jul 2023 23:25:27 +0100 Subject: [PATCH] patch level to not have zero areas --- player_replay.c | 11 +++++------ scene.h | 25 ++++++++++++++++++++++--- world_gate.c | 5 ++--- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/player_replay.c b/player_replay.c index fc57680..5237e5f 100644 --- a/player_replay.c +++ b/player_replay.c @@ -533,13 +533,12 @@ VG_STATIC void skaterift_replay_debug_info(void){ player__debugtext( 1, "head @%u | tail @%u\n", head, tail ); - for( u32 i=0; i<4; i++ ){ - player__debugtext( 1, "[%u]: [%hu, %hu]\n", i, - replay->statehead->data_table[i][0], - replay->statehead->data_table[i][1] ); - } - if( replay->statehead ){ + for( u32 i=0; i<4; i++ ){ + player__debugtext( 1, "[%u]: [%hu, %hu]\n", i, + replay->statehead->data_table[i][0], + replay->statehead->data_table[i][1] ); + } u32 state = (void *)replay->statehead - replay->data; player__debugtext( 1, "gs @%u\n", state ); player__debugtext( 1, "gamestate_size: %hu\n", diff --git a/scene.h b/scene.h index c53c7b3..13de419 100644 --- a/scene.h +++ b/scene.h @@ -133,11 +133,30 @@ VG_STATIC void scene_add_mdl_submesh( scene_context *ctx, mdl_context *mdl, v2_copy( src->uv, pvert->uv ); } - for( u32 i=0; iindice_count; i++ ) - dst_indices[i] = src_indices[i] + ctx->vertex_count; + u32 real_indices = 0; + for( u32 i=0; iindice_count/3; i++ ){ + u32 *tri = &src_indices[i*3]; + + v3f ab, ac, tn; + v3_sub( src_verts[tri[2]].co, src_verts[tri[0]].co, ab ); + v3_sub( src_verts[tri[1]].co, src_verts[tri[0]].co, ac ); + v3_cross( ac, ab, tn ); + + if( v3_length2( tn ) <= 0.00001f ) + continue; + + dst_indices[real_indices+0] = tri[0] + ctx->vertex_count; + dst_indices[real_indices+1] = tri[1] + ctx->vertex_count; + dst_indices[real_indices+2] = tri[2] + ctx->vertex_count; + + real_indices += 3; + } + + if( real_indices != sm->indice_count ) + vg_warn( "Zero area triangles in model\n" ); ctx->vertex_count += sm->vertex_count; - ctx->indice_count += sm->indice_count; + ctx->indice_count += real_indices; } /* diff --git a/world_gate.c b/world_gate.c index 64333da..f757cdf 100644 --- a/world_gate.c +++ b/world_gate.c @@ -151,6 +151,7 @@ VG_STATIC int render_gate( world_instance *world, world_instance *world_inside, m4x3_copy( gate->to_world, mmdl ); if( gate->flags & k_ent_gate_custom_mesh ){ + shader_model_gate_uMdl( mmdl ); mesh_bind( &world->mesh_no_collide ); for( u32 i=0; isubmesh_count; i++ ){ mdl_submesh *sm = mdl_arritm( &world->meta.submeshs, @@ -161,13 +162,11 @@ VG_STATIC int render_gate( world_instance *world, world_instance *world_inside, else { m3x3_scale( mmdl, (v3f){ gate->dimensions[0], gate->dimensions[1], 1.0f } ); - + shader_model_gate_uMdl( mmdl ); mesh_bind( &world_gates.mesh ); mdl_draw_submesh( &world_gates.sm_surface ); } - shader_model_gate_uMdl( mmdl ); - glClear( GL_DEPTH_BUFFER_BIT ); glStencilFunc( GL_EQUAL, 1, 0xFF ); glStencilMask( 0x00 ); -- 2.25.1