Add center skid-plate bump-stop to terrain support for sharp ridge crests
This commit is contained in:
parent
ade15c3325
commit
76584473d4
1 changed files with 11 additions and 3 deletions
|
|
@ -551,9 +551,9 @@ namespace RustToDust.Ymir
|
||||||
float hx = spec.HalfWidth * 0.9f;
|
float hx = spec.HalfWidth * 0.9f;
|
||||||
float hz = spec.HalfLength * 0.9f;
|
float hz = spec.HalfLength * 0.9f;
|
||||||
float bottomY = -spec.HalfHeight;
|
float bottomY = -spec.HalfHeight;
|
||||||
const float restTravel = 0.18f;
|
const float restTravel = 0.20f;
|
||||||
float kSpring = mass * 75f;
|
float kSpring = mass * 85f;
|
||||||
float cDamp = mass * 9.5f;
|
float cDamp = mass * 10.5f;
|
||||||
|
|
||||||
Span<Vector3> corners = stackalloc Vector3[4]
|
Span<Vector3> corners = stackalloc Vector3[4]
|
||||||
{
|
{
|
||||||
|
|
@ -579,6 +579,14 @@ namespace RustToDust.Ymir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Center skid-plate bump-stop prevents belly clipping when straddling sharp ridge crests at speed
|
||||||
|
float centerPen = (State.Terrain.SampleHeight(pos.X, pos.Z) + 0.08f) - (pos.Y - spec.HalfHeight);
|
||||||
|
if (centerPen > 0f)
|
||||||
|
{
|
||||||
|
groundedCorners = Math.Max(groundedCorners, 1);
|
||||||
|
supportForce.Y += Math.Clamp(mass * 160f * centerPen - mass * 12f * vel.Y, 0f, mass * 140f);
|
||||||
|
}
|
||||||
|
|
||||||
var (nx, ny, nz) = State.Terrain.SampleNormal(pos.X, pos.Z);
|
var (nx, ny, nz) = State.Terrain.SampleNormal(pos.X, pos.Z);
|
||||||
terrainNormal = new Vector3(nx, ny, nz);
|
terrainNormal = new Vector3(nx, ny, nz);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue