/*
* 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 );
}
/*
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;
}
}
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;
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] );
}
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];
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] );
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 */
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;
}
/* 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;
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] );