diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 557c4e254d..42381ef061 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -227,7 +227,6 @@ public class BSActorAvatarMove : BSActor stepVelocity.Z = m_controllingPrim.RawVelocity.Z; } - // Colliding and not flying with an upward force. The avatar must be trying to jump. if (!m_controllingPrim.Flying && m_controllingPrim.IsColliding && stepVelocity.Z > 0) { @@ -259,23 +258,25 @@ public class BSActorAvatarMove : BSActor // DetailLog("{0},BSCharacter.MoveMotor,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity); } + //Alicia: Maintain minimum height when flying. + // SL has a flying effect that keeps the avatar flying above the ground by some margin + if (m_controllingPrim.Flying) + { + float hover_height = m_physicsScene.TerrainManager.GetTerrainHeightAtXYZ(m_controllingPrim.RawPosition) + + BSParam.AvatarFlyingGroundMargin; + + if( m_controllingPrim.Position.Z < hover_height) + { + stepVelocity.Z += BSParam.AvatarFlyingGroundUpForce; + } + } + // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - m_controllingPrim.RawVelocity) * m_controllingPrim.Mass; // Add special movement force to allow avatars to walk up stepped surfaces. moveForce += WalkUpStairs(); - //Alicia: Maintain minimum height when flying - if (m_controllingPrim.Flying) - { - float hover_height = m_physicsScene.TerrainManager.GetTerrainHeightAtXYZ(m_controllingPrim.RawPosition) + 8f; - - if( m_controllingPrim.Position.Z < hover_height) - { - moveForce.Z = moveForce.Z + 50f; - } - } - m_physicsScene.DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", m_controllingPrim.LocalID, stepVelocity, m_controllingPrim.RawVelocity, m_controllingPrim.Mass, moveForce); m_physicsScene.PE.ApplyCentralImpulse(m_controllingPrim.PhysBody, moveForce); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index de42a4cdd0..042e8a4adf 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -136,6 +136,8 @@ public static class BSParam public static float AvatarHeightLowFudge { get; private set; } public static float AvatarHeightMidFudge { get; private set; } public static float AvatarHeightHighFudge { get; private set; } + public static float AvatarFlyingGroundMargin { get; private set; } + public static float AvatarFlyingGroundUpForce { get; private set; } public static float AvatarContactProcessingThreshold { get; private set; } public static float AvatarStopZeroThreshold { get; private set; } public static int AvatarJumpFrames { get; private set; } @@ -583,6 +585,10 @@ public static class BSParam 0f ), new ParameterDefn("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground", 0f ), + new ParameterDefn("AvatarFlyingGroundMargin", "Meters avatar is kept above the ground when flying", + 5f ), + new ParameterDefn("AvatarFlyingGroundUpForce", "Upward force applied to the avatar to keep it at flying ground margin", + 2.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",