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.
This commit is contained in:
Robert Adams
2015-01-07 06:39:29 -08:00
parent 8e562f04d1
commit 700543b161
3 changed files with 39 additions and 12 deletions

View File

@@ -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;
}
}
}
}

View File

@@ -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<int>("AvatarJumpFrames", "Number of frames to allow jump forces. Changes jump height.",
4 ),
new ParameterDefn<float>("AvatarStepHeight", "Height of a step obstacle to consider step correction",
0.6f ) ,
0.999f ) ,
new ParameterDefn<float>("AvatarStepAngle", "The angle (in radians) for a vertical surface to be considered a step",
0.3f ) ,
new ParameterDefn<float>("AvatarStepGroundFudge", "Fudge factor subtracted from avatar base when comparing collision height",
0.1f ) ,
new ParameterDefn<float>("AvatarStepApproachFactor", "Factor to control angle of approach to step (0=straight on)",
0.6f ),
2f ),
new ParameterDefn<float>("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step",
1.0f ),
0f ),
new ParameterDefn<float>("AvatarStepUpCorrectionFactor", "Multiplied by height of step collision to create up movement at step",
2.0f ),
0.8f ),
new ParameterDefn<int>("AvatarStepSmoothingSteps", "Number of frames after a step collision that we continue walking up stairs",
1 ),