Cap vertical deflection above 65 m/s^2 to downward arrest only (prevent ramp sky launch)
This commit is contained in:
parent
47175cf12a
commit
310fa880a5
1 changed files with 9 additions and 2 deletions
|
|
@ -672,14 +672,21 @@ namespace RustToDust.Ymir
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steep-slope velocity projection / deflection: when contacting terrain and moving into the surface,
|
// Steep-slope velocity projection / deflection: when contacting terrain and moving into the surface,
|
||||||
// damp inward normal velocity cleanly (capped at cancelling vn to 0 so it never adds upward launch velocity).
|
// damp inward normal velocity cleanly while never converting horizontal speed into an upward sky launch.
|
||||||
if (maxPen > 0f)
|
if (maxPen > 0f)
|
||||||
{
|
{
|
||||||
float vn = Vector3.Dot(vel, terrainNormal);
|
float vn = Vector3.Dot(vel, terrainNormal);
|
||||||
if (vn < 0f)
|
if (vn < 0f)
|
||||||
{
|
{
|
||||||
float deflectMag = MathF.Min(-vn * mass * 42f, -vn * mass / FixedDt);
|
float deflectMag = MathF.Min(-vn * mass * 42f, -vn * mass / FixedDt);
|
||||||
supportForce += terrainNormal * deflectMag;
|
Vector3 deflectForce = terrainNormal * deflectMag;
|
||||||
|
// Allow vertical deflection above 65 m/s^2 ONLY to arrest actual downward velocity (vel.Y < 0).
|
||||||
|
float maxDeflectY = MathF.Max(0f, maxSpringY - supportForce.Y) + MathF.Max(0f, (-vel.Y * mass) / FixedDt);
|
||||||
|
if (deflectForce.Y > maxDeflectY)
|
||||||
|
{
|
||||||
|
deflectForce.Y = maxDeflectY;
|
||||||
|
}
|
||||||
|
supportForce += deflectForce;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue