X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=rigidbody.h;h=398791341b592459f3b1e922ebfdb46a2fcf88a5;hb=d6171f1c56789b2ca79efa3313fbbf74a13bda7a;hp=fe8197569e689f87d316905f2ce4244b5b351e69;hpb=a1056ed8198f0f5be0e0f341da8bd49aa6c47198;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/rigidbody.h b/rigidbody.h index fe81975..3987913 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -1509,8 +1509,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, 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]; @@ -1526,8 +1525,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, 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; } @@ -1999,8 +1997,7 @@ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, 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]; @@ -2012,8 +2009,7 @@ VG_STATIC int rb_capsule__scene( m4x3f mtxA, rb_capsule *c, 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; } @@ -2208,8 +2204,7 @@ VG_STATIC void rb_depenetrate( rb_ct *manifold, int len, v3f dt ) */ VG_STATIC void rb_presolve_contacts( rb_ct *buffer, int len ) { - for( int i=0; inormal_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 ); @@ -2282,8 +2276,7 @@ VG_STATIC void rb_linear_impulse( rigidbody *rb, v3f delta, v3f impulse ) */ VG_STATIC void rb_solve_contacts( rb_ct *buf, int len ) { - for( int i=0; irba, 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; @@ -2829,7 +2821,8 @@ VG_STATIC void rb_effect_spring_target_vector( rigidbody *rba, v3f ra, v3f rt, 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 );