From 87c81b5172e98a31405d924cbdb4b7ef271f3c38 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 6 Mar 2019 10:29:46 -0800 Subject: BulletSim: Add delay to stationary check after adding force to Avatar. Fix to Mantis 8496. Add parameter [BulletSim] AvatarAddForceFrames. --- .../PhysicsModules/BulletS/BSActorAvatarMove.cs | 24 ++++++++++++++-------- .../Region/PhysicsModules/BulletS/BSCharacter.cs | 2 +- OpenSim/Region/PhysicsModules/BulletS/BSParam.cs | 3 +++ 3 files changed, 19 insertions(+), 10 deletions(-) mode change 100644 => 100755 OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs index 40c6b98..4e9216d 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs @@ -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; diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs old mode 100644 new mode 100755 index 2ca7dbc..f971e59 --- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs @@ -701,7 +701,7 @@ public sealed class BSCharacter : BSPhysObject } if (m_moveActor != null) { - m_moveActor.SuppressStationayCheckUntilLowVelocity(); + m_moveActor.SuppressStationayCheckUntilLowVelocity(BSParam.AvatarAddForceFrames); } }); } diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSParam.cs b/OpenSim/Region/PhysicsModules/BulletS/BSParam.cs index 495f752..d80b050 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSParam.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSParam.cs @@ -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("AvatarFlyingGroundUpForce", "Upward force applied to the avatar to keep it at flying ground margin", 2.0f ), + new ParameterDefn("AvatarAddForceFrames", "Frames to allow AddForce to apply before checking for stationary", + 10 ), new ParameterDefn("AvatarTerminalVelocity", "Terminal Velocity of falling avatar", -54.0f ), new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", -- cgit v1.1