X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=rigidbody.h;h=1c1e8c8cd48f991ee642c65ab7023840b90ad29c;hb=188685bc8454ff40b733d9e9df8da45e3c2e2c39;hp=8489dbccf830ed1a527d1b17906e27bbe5a63f6d;hpb=73adac381b2c72f08293416a960942dc40db3c7f;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/rigidbody.h b/rigidbody.h index 8489dbc..1c1e8c8 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -191,10 +191,9 @@ VG_STATIC void rb_object_debug( rb_object *obj, u32 colour ){ /* * Update world space bounding box based on local one */ -VG_STATIC void rb_update_bounds( rigidbody *rb ) -{ - box_copy( rb->bbx, rb->bbx_world ); - m4x3_transform_aabb( rb->to_world, rb->bbx_world ); +VG_STATIC void rb_update_bounds( rigidbody *rb ){ + box_init_inf( rb->bbx_world ); + m4x3_expand_aabb_aabb( rb->to_world, rb->bbx_world, rb->bbx ); } /* @@ -853,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; } @@ -961,6 +962,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 */ @@ -1099,7 +1108,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; }