BulletSim: add 'AvatarAlwaysRunFactor' parameter and use in setTargetVelocity

to implement the 'always run' feature.
0.7.5-pf-bulletsim
Robert Adams 2012-12-28 12:01:57 -08:00
parent 70e0a86601
commit 7266eeca6e
2 changed files with 9 additions and 3 deletions

View File

@ -464,15 +464,15 @@ public sealed class BSCharacter : BSPhysObject
{
DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value);
OMV.Vector3 targetVel = value;
if (_setAlwaysRun)
targetVel *= BSParam.AvatarAlwaysRunFactor;
PhysicsScene.TaintedObject("BSCharacter.setTargetVelocity", delegate()
{
_velocityMotor.Reset();
_velocityMotor.SetTarget(targetVel);
_velocityMotor.SetCurrent(_velocity);
_velocityMotor.Enabled = true;
// Make sure a property update happens next step so the motor gets incorporated.
BulletSimAPI.PushUpdate2(PhysBody.ptr);
});
}
}

View File

@ -68,6 +68,7 @@ public static class BSParam
// Avatar parameters
public static float AvatarFriction { get; private set; }
public static float AvatarStandingFriction { get; private set; }
public static float AvatarAlwaysRunFactor { get; private set; }
public static float AvatarDensity { get; private set; }
public static float AvatarRestitution { get; private set; }
public static float AvatarCapsuleWidth { get; private set; }
@ -367,6 +368,11 @@ public static class BSParam
(s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
(s) => { return AvatarStandingFriction; },
(s,p,l,v) => { AvatarStandingFriction = v; } ),
new ParameterDefn("AvatarAlwaysRunFactor", "Speed multiplier if avatar is set to always run",
1.3f,
(s,cf,p,v) => { AvatarAlwaysRunFactor = cf.GetFloat(p, v); },
(s) => { return AvatarAlwaysRunFactor; },
(s,p,l,v) => { AvatarAlwaysRunFactor = v; } ),
new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.",
3.5f,
(s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); },