From b293242017e88118a5c260d4900090b04b3f8383 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 18 Jun 2014 22:39:28 -0700 Subject: BulletSim: more tweeks to AliciaRaven's flying mods. Added parameters AvatarFlyingGroundMargin and AvatarFlyingGroundUpForce set to 5.0 and 2.0 respectively which seems to give about the same action as in SL. Also moved force addition to before the velocity to force computation so the upward velocity is properly applied to the avatar mass. --- .../Physics/BulletSPlugin/BSActorAvatarMove.cs | 23 +++++++++++----------- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 6 ++++++ 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 557c4e2..42381ef 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); } - // '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 + //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) + 8f; + float hover_height = m_physicsScene.TerrainManager.GetTerrainHeightAtXYZ(m_controllingPrim.RawPosition) + + BSParam.AvatarFlyingGroundMargin; if( m_controllingPrim.Position.Z < hover_height) { - moveForce.Z = moveForce.Z + 50f; + 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(); + 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 de42a4c..042e8a4 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", -- cgit v1.1