X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=rigidbody.h;h=d19b7862b174a007efa6df04702a5c518eb3f601;hb=5bfb36032928ba9f8d12e72961af68bfab9ea648;hp=92419991f7b0e6f21c5659a63a2db9f5bfb9700c;hpb=7eba38b8178c82040618a518634d8ff4813e2ff2;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/rigidbody.h b/rigidbody.h index 9241999..d19b786 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -852,7 +852,9 @@ VG_STATIC int rb_sphere__triangle( m4x3f mtxA, rb_sphere *b, v3_copy( tn, ct->n ); if( v3_length2( ct->n ) <= 0.00001f ){ +#ifdef RIGIDBODY_CRY_ABOUT_EVERYTHING vg_error( "Zero area triangle!\n" ); +#endif return 0; } @@ -870,7 +872,8 @@ VG_STATIC int rb_sphere__triangle( m4x3f mtxA, rb_sphere *b, } VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, - m4x3f mtxB, rb_scene *s, rb_ct *buf ){ + m4x3f mtxB, rb_scene *s, rb_ct *buf, + u16 ignore ){ scene_context *sc = s->bh_scene->user; int count = 0; @@ -888,6 +891,8 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, u32 *ptri = &sc->arrindices[ idx*3 ]; v3f tri[3]; + if( sc->arrvertices[ptri[0]].flags & ignore ) continue; + for( int j=0; j<3; j++ ) v3_copy( sc->arrvertices[ptri[j]].co, tri[j] ); @@ -910,7 +915,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, } VG_STATIC int rb_box__scene( m4x3f mtxA, boxf bbx, - m4x3f mtxB, rb_scene *s, rb_ct *buf ){ + m4x3f mtxB, rb_scene *s, rb_ct *buf, u16 ignore ){ scene_context *sc = s->bh_scene->user; v3f tri[3]; @@ -940,6 +945,7 @@ VG_STATIC int rb_box__scene( m4x3f mtxA, boxf bbx, while( bh_next( s->bh_scene, &it, &idx ) ){ u32 *ptri = &sc->arrindices[ idx*3 ]; + if( sc->arrvertices[ptri[0]].flags & ignore ) continue; for( int j=0; j<3; j++ ) v3_copy( sc->arrvertices[ptri[j]].co, tri[j] ); @@ -960,6 +966,14 @@ VG_STATIC int rb_box__scene( m4x3f mtxA, boxf bbx, v3_sub( tri[1], tri[0], v0 ); v3_sub( tri[2], tri[0], v1 ); v3_cross( v0, v1, n ); + + if( v3_length2( n ) <= 0.00001f ){ +#ifdef RIGIDBODY_CRY_ABOUT_EVERYTHING + vg_error( "Zero area triangle!\n" ); +#endif + return 0; + } + v3_normalize( n ); /* find best feature */ @@ -1098,7 +1112,9 @@ VG_STATIC int rb_capsule__triangle( m4x3f mtxA, rb_capsule *c, v3_cross( v0, v1, n ); if( v3_length2( n ) <= 0.00001f ){ +#ifdef RIGIDBODY_CRY_ABOUT_EVERYTHING vg_error( "Zero area triangle!\n" ); +#endif return 0; } @@ -1114,7 +1130,7 @@ VG_STATIC int rb_capsule__triangle( m4x3f mtxA, rb_capsule *c, /* mtxB is defined only for tradition; it is not used currently */ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, m4x3f mtxB, rb_scene *s, - rb_ct *buf ){ + rb_ct *buf, u16 ignore ){ int count = 0; boxf bbx; @@ -1128,8 +1144,9 @@ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, i32 idx; while( bh_next( s->bh_scene, &it, &idx ) ){ u32 *ptri = &sc->arrindices[ idx*3 ]; - v3f tri[3]; + if( sc->arrvertices[ptri[0]].flags & ignore ) continue; + v3f tri[3]; for( int j=0; j<3; j++ ) v3_copy( sc->arrvertices[ptri[j]].co, tri[j] );