BulletSim: Change BSCharacter to use new base Density and Friction

variables rather than own local varaibles.
user_profiles
Robert Adams 2013-02-08 15:36:10 -08:00
parent 1b55a9d81e
commit 222040f1ec
2 changed files with 12 additions and 16 deletions

View File

@ -45,7 +45,6 @@ public sealed class BSCharacter : BSPhysObject
private bool _selected;
private OMV.Vector3 _position;
private float _mass;
private float _avatarDensity;
private float _avatarVolume;
private OMV.Vector3 _force;
private OMV.Vector3 _velocity;
@ -63,9 +62,6 @@ public sealed class BSCharacter : BSPhysObject
private bool _kinematic;
private float _buoyancy;
// The friction and velocity of the avatar is modified depending on whether walking or not.
private float _currentFriction; // the friction currently being used (changed by setVelocity).
private BSVMotor _velocityMotor;
private OMV.Vector3 _PIDTarget;
@ -86,8 +82,8 @@ public sealed class BSCharacter : BSPhysObject
_orientation = OMV.Quaternion.Identity;
_velocity = OMV.Vector3.Zero;
_buoyancy = ComputeBuoyancyFromFlying(isFlying);
_currentFriction = BSParam.AvatarStandingFriction;
_avatarDensity = BSParam.AvatarDensity;
Friction = BSParam.AvatarStandingFriction;
Density = BSParam.AvatarDensity;
// Old versions of ScenePresence passed only the height. If width and/or depth are zero,
// replace with the default values.
@ -104,7 +100,7 @@ public sealed class BSCharacter : BSPhysObject
SetupMovementMotor();
DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}",
LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
LocalID, _size, Scale, Density, _avatarVolume, RawMass);
// do actual creation in taint time
PhysicsScene.TaintedObject("BSCharacter.create", delegate()
@ -229,10 +225,10 @@ public sealed class BSCharacter : BSPhysObject
}
// Standing has more friction on the ground
if (_currentFriction != BSParam.AvatarStandingFriction)
if (Friction != BSParam.AvatarStandingFriction)
{
_currentFriction = BSParam.AvatarStandingFriction;
PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
Friction = BSParam.AvatarStandingFriction;
PhysicsScene.PE.SetFriction(PhysBody, Friction);
}
}
DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding);
@ -241,11 +237,11 @@ public sealed class BSCharacter : BSPhysObject
{
OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue;
if (_currentFriction != BSParam.AvatarFriction)
if (Friction != BSParam.AvatarFriction)
{
// Probably starting up walking. Set friction to moving friction.
_currentFriction = BSParam.AvatarFriction;
PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
Friction = BSParam.AvatarFriction;
PhysicsScene.PE.SetFriction(PhysBody, Friction);
}
// If falling, we keep the world's downward vector no matter what the other axis specify.
@ -345,7 +341,7 @@ public sealed class BSCharacter : BSPhysObject
Scale = ComputeAvatarScale(_size);
ComputeAvatarVolumeAndMass();
DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
LocalID, _size, Scale, Density, _avatarVolume, RawMass);
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
{
@ -873,7 +869,7 @@ public sealed class BSCharacter : BSPhysObject
* Math.Min(Size.X, Size.Y) / 2
* Size.Y / 2f // plus the volume of the capsule end caps
);
_mass = _avatarDensity * _avatarVolume;
_mass = Density * _avatarVolume;
}
// The physics engine says that properties have updated. Update same and inform

View File

@ -424,7 +424,7 @@ public static class BSParam
(s) => { return AvatarFriction; },
(s,p,l,v) => { AvatarFriction = v; } ),
new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.",
10.0f,
0.95f,
(s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
(s) => { return AvatarStandingFriction; },
(s,p,l,v) => { AvatarStandingFriction = v; } ),