X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=rigidbody.h;h=29e8cea766b19e44abeb861740afa490cf90abd7;hb=d13f2700b1773551307685cc7c34c804ccd6d664;hp=05d2db1100fe78310d8a548691d99138c90a9d3a;hpb=4a883ac1b2506032f9dddab342712de46f2ca734;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/rigidbody.h b/rigidbody.h index 05d2db1..29e8cea 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -338,17 +338,12 @@ static void rb_init( rigidbody *rb ) v3f dims; v3_sub( rb->bbx[1], rb->bbx[0], dims ); volume = dims[0]*dims[1]*dims[2]; - - if( !rb->is_world ) - vg_info( "Box volume: %f\n", volume ); } else if( rb->type == k_rb_shape_sphere ) { volume = sphere_volume( rb->inf.sphere.radius ); v3_fill( rb->bbx[0], -rb->inf.sphere.radius ); v3_fill( rb->bbx[1], rb->inf.sphere.radius ); - - vg_info( "Sphere volume: %f\n", volume ); } else if( rb->type == k_rb_shape_capsule ) { @@ -1860,6 +1855,23 @@ static void rb_constraint_position( rigidbody *ra, v3f lca, } } +/* + * Effectors + */ + +static void rb_effect_simple_bouyency( rigidbody *ra, v4f plane, + float amt, float drag ) +{ + /* float */ + float depth = v3_dot( plane, ra->co ) - plane[3], + lambda = vg_clampf( -depth, 0.0f, 1.0f ) * amt; + + v3_muladds( ra->v, plane, lambda * ktimestep, ra->v ); + + if( depth < 0.0f ) + v3_muls( ra->v, 1.0f-(drag*ktimestep), ra->v ); +} + /* * ----------------------------------------------------------------------------- * BVH implementation, this is ONLY for static rigidbodies, its to slow for