BulletSim: Add AvatarRestitution parameter. Centralize computation of buoyancy for flying. Tweek avatar default friction and resititution

0.7.4.1
Robert Adams 2012-03-18 11:53:53 -07:00
parent 6ecdadb329
commit de24feb275
3 changed files with 11 additions and 4 deletions

View File

@ -94,7 +94,7 @@ public class BSCharacter : PhysicsActor
_flying = isFlying; _flying = isFlying;
_orientation = Quaternion.Identity; _orientation = Quaternion.Identity;
_velocity = Vector3.Zero; _velocity = Vector3.Zero;
_buoyancy = isFlying ? 1f : 0f; _buoyancy = ComputeBuoyancyFromFlying(isFlying);
_scale = new Vector3(1f, 1f, 1f); _scale = new Vector3(1f, 1f, 1f);
_density = _scene.Params.avatarDensity; _density = _scene.Params.avatarDensity;
ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
@ -110,7 +110,7 @@ public class BSCharacter : PhysicsActor
shapeData.Buoyancy = _buoyancy; shapeData.Buoyancy = _buoyancy;
shapeData.Static = ShapeData.numericFalse; shapeData.Static = ShapeData.numericFalse;
shapeData.Friction = _scene.Params.avatarFriction; shapeData.Friction = _scene.Params.avatarFriction;
shapeData.Restitution = _scene.Params.defaultRestitution; shapeData.Restitution = _scene.Params.avatarRestitution;
// do actual create at taint time // do actual create at taint time
_scene.TaintedObject(delegate() _scene.TaintedObject(delegate()
@ -261,9 +261,12 @@ public class BSCharacter : PhysicsActor
set { set {
_flying = value; _flying = value;
// simulate flying by changing the effect of gravity // simulate flying by changing the effect of gravity
this.Buoyancy(_flying ? 1f : 0f); this.Buoyancy(ComputeBuoyancyFromFlying(_flying));
} }
} }
private float ComputeBuoyancyFromFlying(bool ifFlying) {
return ifFlying ? 1f : 0f;
}
public override bool public override bool
SetAlwaysRun { SetAlwaysRun {
get { return _setAlwaysRun; } get { return _setAlwaysRun; }

View File

@ -235,6 +235,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
parms.terrainHitFraction = 0.8f; parms.terrainHitFraction = 0.8f;
parms.terrainRestitution = 0f; parms.terrainRestitution = 0f;
parms.avatarFriction = 0.5f; parms.avatarFriction = 0.5f;
parms.avatarRestitution = 0.0f;
parms.avatarDensity = 60f; parms.avatarDensity = 60f;
parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleRadius = 0.37f;
parms.avatarCapsuleHeight = 1.5f; // 2.140599f parms.avatarCapsuleHeight = 1.5f; // 2.140599f
@ -279,7 +280,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction);
parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution); parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution);
parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction);
parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution);
parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity);
parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution);
parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius);
parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight);
} }

View File

@ -846,7 +846,8 @@
TerrainFriction = 0.50 TerrainFriction = 0.50
TerrainHitFriction = 0.8 TerrainHitFriction = 0.8
TerrainRestitution = 0 TerrainRestitution = 0
AvatarFriction = 0.5 AvatarFriction = 0.2
AvatarRestitution = 0.0
AvatarDensity = 60.0 AvatarDensity = 60.0
AvatarCapsuleRadius = 0.37 AvatarCapsuleRadius = 0.37
AvatarCapsuleHeight = 1.5 AvatarCapsuleHeight = 1.5