X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=rigidbody.h;h=026d8676dbd0cbccab6b7174c2a1498626ce2e77;hb=4625f91b85d2badbb719a7f5bcaa2426af25911b;hp=5d5ffdfa4290c10ba4b7f692ed5dec0801e717d3;hpb=def76bcdaea4e73faab70c60d8ee48a00f2fb48a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/rigidbody.h b/rigidbody.h index 5d5ffdf..026d867 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -25,10 +25,11 @@ static const float k_friction = 0.6f, k_damp_linear = 0.05f, /* scale velocity 1/(1+x) */ k_damp_angular = 0.1f, /* scale angular 1/(1+x) */ - k_limit_bias = 0.04f, + k_limit_bias = 0.02f, k_joint_bias = 0.08f, /* positional joints */ k_joint_correction = 0.01f, - k_penetration_slop = 0.01f; + k_penetration_slop = 0.01f, + k_inertia_scale = 4.0f; /* * ----------------------------------------------------------------------------- @@ -382,7 +383,7 @@ static void rb_init( rigidbody *rb ) v3_muls( extent, 0.5f, extent ); /* local intertia tensor */ - float scale = 4.0f; + float scale = k_inertia_scale; float ex2 = scale*extent[0]*extent[0], ey2 = scale*extent[1]*extent[1], ez2 = scale*extent[2]*extent[2]; @@ -1859,6 +1860,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