BulletSim: tweek avatar capsule parameters so avatar feet don't go below ground. This solves the bouncing, short avatar problem (Mantis 6403).

connector_plugin
Robert Adams 2012-11-20 08:34:18 -08:00
parent f656adee31
commit 2f5fe4b88e
2 changed files with 10 additions and 8 deletions

View File

@ -184,8 +184,8 @@ public sealed class BSCharacter : BSPhysObject
_size = value; _size = value;
ComputeAvatarScale(_size); ComputeAvatarScale(_size);
ComputeAvatarVolumeAndMass(); ComputeAvatarVolumeAndMass();
DetailLog("{0},BSCharacter.setSize,call,scale={1},density={2},volume={3},mass={4}", DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
LocalID, Scale, _avatarDensity, _avatarVolume, RawMass); LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass);
PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
{ {
@ -619,7 +619,8 @@ public sealed class BSCharacter : BSPhysObject
newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; newScale.Y = PhysicsScene.Params.avatarCapsuleRadius;
// From the total height, remove the capsule half spheres that are at each end // From the total height, remove the capsule half spheres that are at each end
newScale.Z = size.Z - (newScale.X + newScale.Y); // The 1.15f came from ODE. Not sure what this factors in.
newScale.Z = (size.Z * 1.15f) - (newScale.X + newScale.Y);
Scale = newScale; Scale = newScale;
} }

View File

@ -712,7 +712,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// here just before the physics engine is called to step the simulation. // here just before the physics engine is called to step the simulation.
public void ProcessTaints() public void ProcessTaints()
{ {
InTaintTime = true; InTaintTime = true; // Only used for debugging so locking is not necessary.
ProcessRegularTaints(); ProcessRegularTaints();
ProcessPostTaintTaints(); ProcessPostTaintTaints();
InTaintTime = false; InTaintTime = false;
@ -758,6 +758,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
DetailLog("{0},BSScene.ProcessTaints,leftTaintsOnList,numNotProcessed={1}", DetailLogZero, _taintOperations.Count); DetailLog("{0},BSScene.ProcessTaints,leftTaintsOnList,numNotProcessed={1}", DetailLogZero, _taintOperations.Count);
} }
*/ */
// swizzle a new list into the list location so we can process what's there // swizzle a new list into the list location so we can process what's there
List<TaintCallbackEntry> oldList; List<TaintCallbackEntry> oldList;
lock (_taintLock) lock (_taintLock)
@ -787,8 +788,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
// will replace any previous operation by the same object. // will replace any previous operation by the same object.
public void PostTaintObject(String ident, uint ID, TaintCallback callback) public void PostTaintObject(String ident, uint ID, TaintCallback callback)
{ {
if (!m_initialized) return;
string uniqueIdent = ident + "-" + ID.ToString(); string uniqueIdent = ident + "-" + ID.ToString();
lock (_taintLock) lock (_taintLock)
{ {
@ -864,13 +863,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
} }
} }
// Only used for debugging. Does not change state of anything so locking is not necessary.
public bool AssertInTaintTime(string whereFrom) public bool AssertInTaintTime(string whereFrom)
{ {
if (!InTaintTime) if (!InTaintTime)
{ {
DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom); DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom);
m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom); m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom);
Util.PrintCallStack(); Util.PrintCallStack(); // Prints the stack into the DEBUG log file.
} }
return InTaintTime; return InTaintTime;
} }
@ -1186,7 +1186,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
(s) => { return s.m_params[0].avatarCapsuleRadius; }, (s) => { return s.m_params[0].avatarCapsuleRadius; },
(s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ), (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ),
new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar",
1.5f, // 1.5f,
2.140599f,
(s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); }, (s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); },
(s) => { return s.m_params[0].avatarCapsuleHeight; }, (s) => { return s.m_params[0].avatarCapsuleHeight; },
(s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ), (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ),