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.
bullet-2.82
Robert Adams 2014-06-18 22:39:28 -07:00
parent 3cbdf3bfe0
commit f348928590
2 changed files with 20 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
@ -227,7 +227,6 @@ public class BSActorAvatarMove : BSActor
stepVelocity.Z = m_controllingPrim.RawVelocity.Z; stepVelocity.Z = m_controllingPrim.RawVelocity.Z;
} }
// Colliding and not flying with an upward force. The avatar must be trying to jump. // 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) 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); // 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. // '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; OMV.Vector3 moveForce = (stepVelocity - m_controllingPrim.RawVelocity) * m_controllingPrim.Mass;
// Add special movement force to allow avatars to walk up stepped surfaces. // Add special movement force to allow avatars to walk up stepped surfaces.
moveForce += WalkUpStairs(); 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_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_controllingPrim.LocalID, stepVelocity, m_controllingPrim.RawVelocity, m_controllingPrim.Mass, moveForce);
m_physicsScene.PE.ApplyCentralImpulse(m_controllingPrim.PhysBody, moveForce); m_physicsScene.PE.ApplyCentralImpulse(m_controllingPrim.PhysBody, moveForce);

View File

@ -136,6 +136,8 @@ public static class BSParam
public static float AvatarHeightLowFudge { get; private set; } public static float AvatarHeightLowFudge { get; private set; }
public static float AvatarHeightMidFudge { get; private set; } public static float AvatarHeightMidFudge { get; private set; }
public static float AvatarHeightHighFudge { 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 AvatarContactProcessingThreshold { get; private set; }
public static float AvatarStopZeroThreshold { get; private set; } public static float AvatarStopZeroThreshold { get; private set; }
public static int AvatarJumpFrames { get; private set; } public static int AvatarJumpFrames { get; private set; }
@ -583,6 +585,10 @@ public static class BSParam
0f ), 0f ),
new ParameterDefn<float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground", new ParameterDefn<float>("AvatarHeightHighFudge", "A fudge factor to make tall avatars stand on the ground",
0f ), 0f ),
new ParameterDefn<float>("AvatarFlyingGroundMargin", "Meters avatar is kept above the ground when flying",
5f ),
new ParameterDefn<float>("AvatarFlyingGroundUpForce", "Upward force applied to the avatar to keep it at flying ground margin",
2.0f ),
new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", new ParameterDefn<float>("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
0.1f ), 0.1f ),
new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped", new ParameterDefn<float>("AvatarStopZeroThreshold", "Movement velocity below which avatar is assumed to be stopped",