From 700543b161f653ea41faf3d125a1eb9be389ec23 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 7 Jan 2015 06:39:29 -0800 Subject: BulletSim: tweek step parameters and logic to make walking up steps closer to SL. This change should address small floor edges acting like walls, approaching a step at any angle (other than walking backwards) will allow walking up, and reducing the avatar pop-up when going up stairs. --- .../Physics/BulletSPlugin/BSActorAvatarMove.cs | 26 +++++++++++++++------- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 14 ++++++++---- 2 files changed, 28 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs index 8e998ba..9bbba40 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorAvatarMove.cs @@ -341,7 +341,7 @@ public class BSActorAvatarMove : BSActor // float nearFeetHeightMin = m_controllingPrim.RawPosition.Z - (m_controllingPrim.Size.Z / 2f) + 0.05f; // Note: there is a problem with the computation of the capsule height. Thus RawPosition is off // from the height. Revisit size and this computation when height is scaled properly. - float nearFeetHeightMin = m_controllingPrim.RawPosition.Z - (m_controllingPrim.Size.Z / 2f) - 0.05f; + float nearFeetHeightMin = m_controllingPrim.RawPosition.Z - (m_controllingPrim.Size.Z / 2f) - BSParam.AvatarStepGroundFudge; float nearFeetHeightMax = nearFeetHeightMin + BSParam.AvatarStepHeight; // Look for a collision point that is near the character's feet and is oriented the same as the charactor is. @@ -363,15 +363,25 @@ public class BSActorAvatarMove : BSActor if (touchPosition.Z >= nearFeetHeightMin && touchPosition.Z <= nearFeetHeightMax) { // This contact is within the 'near the feet' range. - // The normal should be our contact point to the object so it is pointing away - // thus the difference between our facing orientation and the normal should be small. + // The step is presumed to be more or less vertical. Thus the Z component should + // be nearly horizontal. OMV.Vector3 directionFacing = OMV.Vector3.UnitX * m_controllingPrim.RawOrientation; - OMV.Vector3 touchNormal = OMV.Vector3.Normalize(kvp.Value.SurfaceNormal); - float diff = Math.Abs(OMV.Vector3.Distance(directionFacing, touchNormal)); - if (diff < BSParam.AvatarStepApproachFactor) + OMV.Vector3 touchNormal = OMV.Vector3.Normalize(kvp.Value.SurfaceNormal); + const float PIOver2 = 1.571f; // Used to make unit vector axis into approx radian angles + // m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs,avNormal={1},colNormal={2},diff={3}", + // m_controllingPrim.LocalID, directionFacing, touchNormal, + // Math.Abs(OMV.Vector3.Distance(directionFacing, touchNormal)) ); + if ((Math.Abs(directionFacing.Z) * PIOver2) < BSParam.AvatarStepAngle + && (Math.Abs(touchNormal.Z) * PIOver2) < BSParam.AvatarStepAngle) { - if (highestTouchPosition.Z < touchPosition.Z) - highestTouchPosition = touchPosition; + // The normal should be our contact point to the object so it is pointing away + // thus the difference between our facing orientation and the normal should be small. + float diff = Math.Abs(OMV.Vector3.Distance(directionFacing, touchNormal)); + if (diff < BSParam.AvatarStepApproachFactor) + { + if (highestTouchPosition.Z < touchPosition.Z) + highestTouchPosition = touchPosition; + } } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index e7f4def..ef75e3f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -153,6 +153,8 @@ public static class BSParam public static int AvatarJumpFrames { get; private set; } public static float AvatarBelowGroundUpCorrectionMeters { get; private set; } public static float AvatarStepHeight { get; private set; } + public static float AvatarStepAngle { get; private set; } + public static float AvatarStepGroundFudge { get; private set; } public static float AvatarStepApproachFactor { get; private set; } public static float AvatarStepForceFactor { get; private set; } public static float AvatarStepUpCorrectionFactor { get; private set; } @@ -614,13 +616,17 @@ public static class BSParam new ParameterDefn("AvatarJumpFrames", "Number of frames to allow jump forces. Changes jump height.", 4 ), new ParameterDefn("AvatarStepHeight", "Height of a step obstacle to consider step correction", - 0.6f ) , + 0.999f ) , + new ParameterDefn("AvatarStepAngle", "The angle (in radians) for a vertical surface to be considered a step", + 0.3f ) , + new ParameterDefn("AvatarStepGroundFudge", "Fudge factor subtracted from avatar base when comparing collision height", + 0.1f ) , new ParameterDefn("AvatarStepApproachFactor", "Factor to control angle of approach to step (0=straight on)", - 0.6f ), + 2f ), new ParameterDefn("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step", - 1.0f ), + 0f ), new ParameterDefn("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step", - 2.0f ), + 0.8f ), new ParameterDefn("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs", 1 ), -- cgit v1.1