BulletSim: Add delay to stationary check after adding force to Avatar.
Fix to Mantis 8496. Add parameter [BulletSim] AvatarAddForceFrames.0.9.1.0-post-fixes
parent
39f73b82d4
commit
87c81b5172
|
@ -47,9 +47,9 @@ public class BSActorAvatarMove : BSActor
|
|||
// The amount the step up is applying. Used to smooth stair walking.
|
||||
float m_lastStepUp;
|
||||
|
||||
// There are times the velocity is set but we don't want to inforce stationary until the
|
||||
// real velocity drops.
|
||||
bool m_waitingForLowVelocityForStationary = false;
|
||||
// There are times the velocity or force is set but we don't want to inforce
|
||||
// stationary until some tick in the future and the real velocity drops.
|
||||
int m_waitingForLowVelocityForStationary = 0;
|
||||
|
||||
public BSActorAvatarMove(BSScene physicsScene, BSPhysObject pObj, string actorName)
|
||||
: base(physicsScene, pObj, actorName)
|
||||
|
@ -114,14 +114,18 @@ public class BSActorAvatarMove : BSActor
|
|||
m_velocityMotor.Enabled = true;
|
||||
m_physicsScene.DetailLog("{0},BSCharacter.MoveMotor,SetVelocityAndTarget,vel={1}, targ={2}",
|
||||
m_controllingPrim.LocalID, vel, targ);
|
||||
m_waitingForLowVelocityForStationary = false;
|
||||
m_waitingForLowVelocityForStationary = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void SuppressStationayCheckUntilLowVelocity()
|
||||
{
|
||||
m_waitingForLowVelocityForStationary = true;
|
||||
m_waitingForLowVelocityForStationary = 1;
|
||||
}
|
||||
public void SuppressStationayCheckUntilLowVelocity(int waitTicks)
|
||||
{
|
||||
m_waitingForLowVelocityForStationary = waitTicks;
|
||||
}
|
||||
|
||||
// If a movement motor has not been created, create one and start the movement
|
||||
|
@ -143,7 +147,7 @@ public class BSActorAvatarMove : BSActor
|
|||
m_controllingPrim.OnPreUpdateProperty += Process_OnPreUpdateProperty;
|
||||
|
||||
m_walkingUpStairs = 0;
|
||||
m_waitingForLowVelocityForStationary = false;
|
||||
m_waitingForLowVelocityForStationary = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,15 +198,17 @@ public class BSActorAvatarMove : BSActor
|
|||
// if colliding with something stationary and we're not doing volume detect .
|
||||
if (!m_controllingPrim.ColliderIsMoving && !m_controllingPrim.ColliderIsVolumeDetect)
|
||||
{
|
||||
if (m_waitingForLowVelocityForStationary)
|
||||
if (m_waitingForLowVelocityForStationary-- <= 0)
|
||||
{
|
||||
// if waiting for velocity to drop and it has finally dropped, we can be stationary
|
||||
// m_physicsScene.DetailLog("{0},BSCharacter.MoveMotor,waitingForLowVelocity {1}",
|
||||
// m_controllingPrim.LocalID, m_waitingForLowVelocityForStationary);
|
||||
if (m_controllingPrim.RawVelocity.LengthSquared() < BSParam.AvatarStopZeroThresholdSquared)
|
||||
{
|
||||
m_waitingForLowVelocityForStationary = false;
|
||||
m_waitingForLowVelocityForStationary = 0;
|
||||
}
|
||||
}
|
||||
if (!m_waitingForLowVelocityForStationary)
|
||||
if (m_waitingForLowVelocityForStationary <= 0)
|
||||
{
|
||||
m_physicsScene.DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", m_controllingPrim.LocalID);
|
||||
m_controllingPrim.IsStationary = true;
|
||||
|
|
|
@ -701,7 +701,7 @@ public sealed class BSCharacter : BSPhysObject
|
|||
}
|
||||
if (m_moveActor != null)
|
||||
{
|
||||
m_moveActor.SuppressStationayCheckUntilLowVelocity();
|
||||
m_moveActor.SuppressStationayCheckUntilLowVelocity(BSParam.AvatarAddForceFrames);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -149,6 +149,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 int AvatarAddForceFrames { get; private set; }
|
||||
public static float AvatarTerminalVelocity { get; private set; }
|
||||
public static float AvatarContactProcessingThreshold { get; private set; }
|
||||
public static float AvatarAddForcePushFactor { get; private set; }
|
||||
|
@ -634,6 +635,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<int>("AvatarAddForceFrames", "Frames to allow AddForce to apply before checking for stationary",
|
||||
10 ),
|
||||
new ParameterDefn<float>("AvatarTerminalVelocity", "Terminal Velocity of falling avatar",
|
||||
-54.0f ),
|
||||
new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
|
||||
|
|
Loading…
Reference in New Issue