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.sedebug
parent
8e562f04d1
commit
700543b161
|
@ -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,10 +363,19 @@ 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);
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
|
@ -378,6 +387,7 @@ public class BSActorAvatarMove : BSActor
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_walkingUpStairs = 0;
|
||||
// If there is a good step sensing, move the avatar over the step.
|
||||
if (highestTouchPosition != OMV.Vector3.Zero)
|
||||
|
|
|
@ -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 ),
|
||||
|
||||
|
|
|
@ -1070,6 +1070,17 @@
|
|||
AvatarHeightMidFudge = 0 ; Adjustment at mid point of avatar height range
|
||||
AvatarHeightHighFudge = 0 ; Adjustment at high end of height range
|
||||
|
||||
; Avatar walk-up-stairs parameters
|
||||
; If an avatar collides with an object 'close to its feet', the avatar will be
|
||||
; moved/pushed up do simulate stepping up.
|
||||
;AvatarStepHeight = 0.6f ; The height, below which is considered a step collision.
|
||||
;AvatarStepAngle = 0.3f ; The angle from vertical (in radians) to consider a surface a step
|
||||
;AvatarStepApproachFactor = 2f ; Approach angle factor. O=straight on, .6=~45 degrees.
|
||||
;AvatarStepGroundFudge = 0.1f ; Fudge added to bottom of avatar below which step collisions happen
|
||||
;AvatarStepForceFactor = 0f ; Avatar is pushed up by its mass times this factor
|
||||
;AvatarStepUpCorrectionFactor = 0.8f ; Avatar is displaced up the collision height times this factor
|
||||
;AvatarStepSmoothingSteps = 1 ; Number of frames after a step collision that up correction is applied
|
||||
|
||||
; Terminal velocity of a falling avatar
|
||||
; This is the same http://en.wikipedia.org/wiki/Terminal_velocity#Examples
|
||||
; negative for a downward speed.
|
||||
|
|
Loading…
Reference in New Issue