Bulletsim: Create AvatarTerminalVelocity to BulletSim like what ODE and SL has. Before this falling from really high caused the avatar to fall faster then the veiwer can handle and cause camera issues.

0.8.0.3
Vegaslon 2014-06-20 09:34:07 -04:00 committed by Justin Clark-Casey
parent 8542f34d7d
commit ed6aabb197
3 changed files with 30 additions and 2 deletions

View File

@ -205,6 +205,17 @@ public class BSActorAvatarMove : BSActor
// Flying and not colliding and velocity nearly zero.
m_controllingPrim.ZeroMotion(true /* inTaintTime */);
}
else
{
//We are falling but are not touching any keys make sure not falling too fast
if (m_controllingPrim.RawVelocity.Z < BSParam.AvatarTerminalVelocity)
{
OMV.Vector3 slowingForce = new OMV.Vector3(0f, 0f, BSParam.AvatarTerminalVelocity - m_controllingPrim.RawVelocity.Z) * m_controllingPrim.Mass;
m_physicsScene.PE.ApplyCentralImpulse(m_controllingPrim.PhysBody, slowingForce);
}
}
}
m_physicsScene.DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}",
@ -252,8 +263,17 @@ public class BSActorAvatarMove : BSActor
}
else
{
// Since we're not affected by anything, whatever vertical motion the avatar has, continue that.
stepVelocity.Z = m_controllingPrim.RawVelocity.Z;
// Since we're not affected by anything, the avatar must be falling and we do not want that to be too fast.
if (m_controllingPrim.RawVelocity.Z < BSParam.AvatarTerminalVelocity)
{
stepVelocity.Z = BSParam.AvatarTerminalVelocity;
}
else
{
stepVelocity.Z = m_controllingPrim.RawVelocity.Z;
}
}
// DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
}

View File

@ -138,6 +138,7 @@ public static class BSParam
public static float AvatarHeightHighFudge { get; private set; }
public static float AvatarFlyingGroundMargin { get; private set; }
public static float AvatarFlyingGroundUpForce { get; private set; }
public static float AvatarTerminalVelocity { get; private set; }
public static float AvatarContactProcessingThreshold { get; private set; }
public static float AvatarStopZeroThreshold { get; private set; }
public static int AvatarJumpFrames { get; private set; }
@ -589,6 +590,8 @@ public static class BSParam
5f ),
new ParameterDefn<float>("AvatarFlyingGroundUpForce", "Upward force applied to the avatar to keep it at flying ground margin",
2.0f ),
new ParameterDefn<float>("AvatarTerminalVelocity", "Terminal Velocity of falling avatar",
-54.0f ),
new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
0.1f ),
new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",

View File

@ -1038,6 +1038,11 @@
AvatarHeightMidFudge = 0 ; Adjustment at mid point of avatar height range
AvatarHeightHighFudge = 0 ; Adjustment at high end of height range
; Terminal velocity of a falling avatar
; This is the same http://en.wikipedia.org/wiki/Terminal_velocity#Examples
; negative for a downward speed.
AvatarTerminalVelocity = -54
; Default linkset implmentation
; 'Constraint' uses physics constraints to hold linkset together. 'Compound'
; builds a compound shape from the children shapes to create a single physical