From abf85b7f192e167ed5f462ac8d1a8de365e4f03b Mon Sep 17 00:00:00 2001 From: Vegaslon Date: Fri, 20 Jun 2014 09:34:07 -0400 Subject: [PATCH] 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. --- .../BulletSPlugin/BSActorAvatarMove.cs | 24 +++++++++++++++++-- .../Region/Physics/BulletSPlugin/BSParam.cs | 3 +++ bin/OpenSimDefaults.ini | 5 ++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 42381ef061..14518e9044 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -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); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 042e8a4adf..8b4df05f3e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -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("AvatarFlyingGroundUpForce", "Upward force applied to the avatar to keep it at flying ground margin", 2.0f ), + new ParameterDefn("AvatarTerminalVelocity", "Terminal Velocity of falling avatar", + -54.0f ), new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", 0.1f ), new ParameterDefn("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped", diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 8b8364cf8c..3f373ce933 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -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