v3_sub( mtxA[3], (v3f){ r,r,r }, box[0] );
v3_add( mtxA[3], (v3f){ r,r,r }, box[1] );
- while( bh_next( s->bh_scene, &it, box, &idx ) )
- {
+ while( bh_next( s->bh_scene, &it, box, &idx ) ){
u32 *ptri = &sc->arrindices[ idx*3 ];
v3f tri[3];
int contact = rb_sphere__triangle( mtxA, b, tri, &buf[count] );
count += contact;
- if( count == 16 )
- {
+ if( count == 16 ){
vg_warn( "Exceeding sphere_vs_scene capacity. Geometry too dense!\n" );
return count;
}
scene *sc = s->bh_scene->user;
- while( bh_next( s->bh_scene, &it, bbx, &idx ) )
- {
+ while( bh_next( s->bh_scene, &it, bbx, &idx ) ){
u32 *ptri = &sc->arrindices[ idx*3 ];
v3f tri[3];
int contact = rb_capsule__triangle( mtxA, c, tri, &buf[count] );
count += contact;
- if( count >= 16 )
- {
+ if( count >= 16 ){
vg_warn("Exceeding capsule_vs_scene capacity. Geometry too dense!\n");
return count;
}
*/
VG_STATIC void rb_presolve_contacts( rb_ct *buffer, int len )
{
- for( int i=0; i<len; i++ )
- {
+ for( int i=0; i<len; i++ ){
rb_ct *ct = &buffer[i];
rb_prepare_contact( ct, k_rb_delta );
ct->normal_mass += v3_dot( rbCn, rbCnI );
ct->normal_mass = 1.0f/ct->normal_mass;
- for( int j=0; j<2; j++ )
- {
+ for( int j=0; j<2; j++ ){
v3f raCtI, rbCtI;
v3_cross( ct->t[j], ra, raCt );
v3_cross( ct->t[j], rb, rbCt );
*/
VG_STATIC void rb_solve_contacts( rb_ct *buf, int len )
{
- for( int i=0; i<len; i++ )
- {
+ for( int i=0; i<len; i++ ){
struct contact *ct = &buf[i];
v3f rv, ra, rb;
rb_rcv( ct->rba, ct->rbb, ra, rb, rv );
/* Friction */
- for( int j=0; j<2; j++ )
- {
+ for( int j=0; j<2; j++ ){
float f = k_friction * ct->norm_impulse,
vt = v3_dot( rv, ct->t[j] ),
lambda = ct->tangent_mass[j] * -vt;
float spring, float dampening,
float timestep )
{
- float a = acosf( vg_clampf( v3_dot( rt, ra ), -1.0f, 1.0f ) );
+ float d = v3_dot( rt, ra );
+ float a = vg_signf( d ) * acosf( vg_clampf( d, -1.0f, 1.0f ) );
v3f axis;
v3_cross( rt, ra, axis );