From: hgn Date: Fri, 8 Apr 2022 20:27:25 +0000 (+0100) Subject: yet more stability improvements X-Git-Url: https://harrygodden.com/git/?p=convexer.git;a=commitdiff_plain;h=8831b5a7ca44b2865589c4c39a1b5ae9d6a3e129 yet more stability improvements --- diff --git a/__init__.py b/__init__.py index cb37747..624bce0 100644 --- a/__init__.py +++ b/__init__.py @@ -636,6 +636,16 @@ cxr_entities = { "enabled": {"type": "int", "default": 1 }, }) }, + "info_player_terrorist": + { + "gizmo": [], + "allow": ('EMPTY',), + "keyvalues": ent_baseclass([ent_transform],\ + { + "priority": {"type": "int", "default": 0 }, + "enabled": {"type": "int", "default": 1 }, + }) + }, "light": { "keyvalues": ent_lights }, "light_spot": { "keyvalues": ent_lights }, # SUN diff --git a/src/convexer.c b/src/convexer.c index 5fac729..28f7056 100644 --- a/src/convexer.c +++ b/src/convexer.c @@ -762,6 +762,48 @@ static struct cxr_mesh *cxr_pull_island(struct cxr_mesh *mesh) return newmesh; } +// Does some checks to determine if solid is valid or not +static int cxr_valid_solid( struct cxr_mesh *mesh, struct cxr_auto_buffer *abverts, int *solid, int len ) +{ + // Invalid 1: Similar normals + // Invalid 2: Co-planar point, that is not referenced by the polygon. + // + for( int i=0; ipolys,solid[i]); + + v4f plane; + normal_to_plane(polyi->normal, polyi->center, plane); + + for( int j=0; jpolys,solid[j]); + + for( int k=0; kloop_total; k++ ) + { + struct cxr_loop *lpj = cxr_ab_ptr(&mesh->loops, polyj->loop_start+k); + + // Make sure this point isnt in our original poly + for( int l=0; lloop_total; l++ ) + { + struct cxr_loop *lpi = cxr_ab_ptr(&mesh->loops, polyi->loop_start+l); + if( lpi->index == lpj->index ) + goto IL_SKIP_VERTEX; + } + + if( fabs(plane_polarity(plane,cxr_ab_ptr(abverts,lpj->index))) < 0.001 ) + return 0; + +IL_SKIP_VERTEX:; + } + } + } + + return 1; +} + // Return best availible solid from mesh, and patch existing mesh to fill the gap // creted by it. // @@ -912,7 +954,7 @@ IL_TAG_NEXT_VERT:; edge_tagged[i] = 1; } - +#if 0 for( int i=0; icount; i++ ) if( vertex_tagged[i] ) cxr_debug_box( vertices[i], 0.03, (v4f){0.0,0.0,0.0,1.0}); @@ -926,7 +968,7 @@ IL_TAG_NEXT_VERT:; if( hot_edge[i] ) cxr_debug_line( vertices[ edge->i0 ], vertices[ edge->i1 ], (v4f){0.0,1.0,1.0,1.0}); } - +#endif // count regions int *faces_tagged = malloc(mesh->polys.count*sizeof(int)); @@ -1014,9 +1056,17 @@ IL_TAG_NEXT_VERT:; IL_SKIP_SIMILAR_PLANES:; } - solid[ solid_len ++ ] = loop->poly_right; - faces_tagged[ loop->poly_right ] = i; - changed = 1; + // Check for vertices in the new poly that exist on a current plane. + // this condition is an invalid configuration and should not be added. + + solid[ solid_len ] = loop->poly_right; + + if( cxr_valid_solid(mesh,vert_buffer,solid,solid_len+1 ) ) + { + faces_tagged[ loop->poly_right ] = i; + changed = 1; + solid_len ++; + } } IL_SKIP_PLANE_ADD:; @@ -2697,6 +2747,19 @@ CXR_API i32 cxr_convert_mesh_to_vmf(struct cxr_input_mesh *src, struct cxr_vdf * cxr_debug_mesh( solid->pmesh, cxr_ab_ptr(&abverts,0), colours_random[cxr_range(i,8)] ); } } + + if( error ) + { + for( int i=0; ipmesh ); + } + + cxr_ab_free( &abverts ); + cxr_ab_free( &solids ); + return error; + } // Turn all those solids into VMF brushes // --------------------------------------