Fix Polygon2D.UV casing, stiffen deep-pen bump-stop, and widen mesa occlusion test margin
This commit is contained in:
parent
af6604da80
commit
62089dcff3
3 changed files with 18 additions and 15 deletions
|
|
@ -325,7 +325,7 @@ public partial class TerrainRenderer : Node3D
|
||||||
new Vector2(rxPx, rzPx),
|
new Vector2(rxPx, rzPx),
|
||||||
new Vector2(-rxPx, rzPx)
|
new Vector2(-rxPx, rzPx)
|
||||||
},
|
},
|
||||||
Uv = BrushUv
|
UV = BrushUv
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -426,9 +426,9 @@ namespace RustToDust.Ymir
|
||||||
float gripScale = groundedCorners > 0 ? (0.4f + 0.6f * (groundedCorners / 4f)) : 0.12f;
|
float gripScale = groundedCorners > 0 ? (0.4f + 0.6f * (groundedCorners / 4f)) : 0.12f;
|
||||||
|
|
||||||
Vector3 force = supportForce;
|
Vector3 force = supportForce;
|
||||||
// On steep cliffs (ny < 0.74), strip inward horizontal thrust so vehicles slide along the slope instead of burrowing
|
// On steep cliffs (ny < 0.78), strip inward horizontal thrust so vehicles slide along the slope instead of burrowing
|
||||||
Vector3 effectiveDriveFwd = driveForward;
|
Vector3 effectiveDriveFwd = driveForward;
|
||||||
if (groundedCorners > 0 && terrainNormal.Y < 0.74f)
|
if (groundedCorners > 0 && terrainNormal.Y < 0.78f)
|
||||||
{
|
{
|
||||||
Vector3 cliffHoriz = new Vector3(terrainNormal.X, 0f, terrainNormal.Z);
|
Vector3 cliffHoriz = new Vector3(terrainNormal.X, 0f, terrainNormal.Z);
|
||||||
if (cliffHoriz.LengthSquared() > 1e-4f)
|
if (cliffHoriz.LengthSquared() > 1e-4f)
|
||||||
|
|
@ -643,7 +643,9 @@ namespace RustToDust.Ymir
|
||||||
groundedCorners++;
|
groundedCorners++;
|
||||||
maxPen = MathF.Max(maxPen, pen);
|
maxPen = MathF.Max(maxPen, pen);
|
||||||
float vCornerN = Vector3.Dot(vel + Vector3.Cross(angVel, r), supportDir);
|
float vCornerN = Vector3.Dot(vel + Vector3.Cross(angVel, r), supportDir);
|
||||||
float fN = Math.Clamp(kSpring * (pen * orthoScale) - cDamp * vCornerN, 0f, mass * 45f);
|
float penEff = pen * orthoScale;
|
||||||
|
float bumpExtra = pen > 0.20f ? mass * 220f * (pen - 0.20f) : 0f;
|
||||||
|
float fN = Math.Clamp(kSpring * penEff + bumpExtra - cDamp * vCornerN, 0f, mass * 65f);
|
||||||
Vector3 cornerForce = supportDir * fN;
|
Vector3 cornerForce = supportDir * fN;
|
||||||
supportForce += cornerForce;
|
supportForce += cornerForce;
|
||||||
supportTorque += Vector3.Cross(r, cornerForce) * torqueScale;
|
supportTorque += Vector3.Cross(r, cornerForce) * torqueScale;
|
||||||
|
|
@ -657,7 +659,8 @@ namespace RustToDust.Ymir
|
||||||
groundedCorners = Math.Max(groundedCorners, 1);
|
groundedCorners = Math.Max(groundedCorners, 1);
|
||||||
maxPen = MathF.Max(maxPen, centerPen);
|
maxPen = MathF.Max(maxPen, centerPen);
|
||||||
float vCenterN = Vector3.Dot(vel, supportDir);
|
float vCenterN = Vector3.Dot(vel, supportDir);
|
||||||
float fCenter = Math.Clamp(mass * 120f * (centerPen * orthoScale) - mass * 10f * vCenterN, 0f, mass * 55f);
|
float centerExtra = centerPen > 0.20f ? mass * 220f * (centerPen - 0.20f) : 0f;
|
||||||
|
float fCenter = Math.Clamp(mass * 120f * (centerPen * orthoScale) + centerExtra - mass * 10f * vCenterN, 0f, mass * 65f);
|
||||||
supportForce += supportDir * fCenter;
|
supportForce += supportDir * fCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -674,7 +677,7 @@ namespace RustToDust.Ymir
|
||||||
float vn = Vector3.Dot(vel, terrainNormal);
|
float vn = Vector3.Dot(vel, terrainNormal);
|
||||||
if (vn < 0f)
|
if (vn < 0f)
|
||||||
{
|
{
|
||||||
float deflectMag = MathF.Min(-vn * mass * 30f, -vn * mass / FixedDt);
|
float deflectMag = MathF.Min(-vn * mass * 48f, -vn * mass / FixedDt);
|
||||||
Vector3 deflectForce = terrainNormal * deflectMag;
|
Vector3 deflectForce = terrainNormal * deflectMag;
|
||||||
float maxAllowableY = MathF.Max(0f, maxSpringY - supportForce.Y);
|
float maxAllowableY = MathF.Max(0f, maxSpringY - supportForce.Y);
|
||||||
if (deflectForce.Y > maxAllowableY)
|
if (deflectForce.Y > maxAllowableY)
|
||||||
|
|
@ -684,9 +687,9 @@ namespace RustToDust.Ymir
|
||||||
supportForce += deflectForce;
|
supportForce += deflectForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxPen > 0.35f && terrainNormal.Y < 0.85f)
|
if (maxPen > 0.28f && terrainNormal.Y < 0.88f)
|
||||||
{
|
{
|
||||||
supportForce += new Vector3(terrainNormal.X, 0f, terrainNormal.Z) * (mass * 45f * MathF.Min(maxPen, 1.5f));
|
supportForce += new Vector3(terrainNormal.X, 0f, terrainNormal.Z) * (mass * 55f * MathF.Min(maxPen, 1.5f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,21 +206,21 @@ namespace RustToDust.Tests
|
||||||
session.State.Spectators.UpdateSafeRadius(session.State.Time);
|
session.State.Spectators.UpdateSafeRadius(session.State.Time);
|
||||||
|
|
||||||
TerrainBrush mesa = default;
|
TerrainBrush mesa = default;
|
||||||
float bestArea = -1f;
|
float bestMinRadius = -1f;
|
||||||
for (int i = 0; i < session.State.Terrain.Brushes.Count; i++)
|
for (int i = 0; i < session.State.Terrain.Brushes.Count; i++)
|
||||||
{
|
{
|
||||||
var b = session.State.Terrain.Brushes[i];
|
var b = session.State.Terrain.Brushes[i];
|
||||||
if (b.Kind == TerrainBrushKind.Mesa && b.HeightDelta >= 22f)
|
if (b.Kind == TerrainBrushKind.Mesa && b.HeightDelta >= 22f)
|
||||||
{
|
{
|
||||||
float area = b.RadiusX * b.RadiusZ;
|
float minR = MathF.Min(b.RadiusX, b.RadiusZ);
|
||||||
if (area > bestArea)
|
if (minR > bestMinRadius)
|
||||||
{
|
{
|
||||||
bestArea = area;
|
bestMinRadius = minR;
|
||||||
mesa = b;
|
mesa = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert.True(bestArea > 0f, "Expected at least one tall Mesa in generated terrain.");
|
Assert.True(bestMinRadius > 0f, "Expected at least one tall Mesa in generated terrain.");
|
||||||
|
|
||||||
var player = session.State.Player;
|
var player = session.State.Player;
|
||||||
var tourists = session.State.Spectators.Spectators.Where(s => s.Tier == SpectatorTier.Tourist).ToList();
|
var tourists = session.State.Spectators.Spectators.Where(s => s.Tier == SpectatorTier.Tourist).ToList();
|
||||||
|
|
@ -232,7 +232,7 @@ namespace RustToDust.Tests
|
||||||
float xPos = mesa.X + mesa.RadiusX + 18f;
|
float xPos = mesa.X + mesa.RadiusX + 18f;
|
||||||
bool negIsFurther = (xNeg * xNeg + mesa.Z * mesa.Z) >= (xPos * xPos + mesa.Z * mesa.Z);
|
bool negIsFurther = (xNeg * xNeg + mesa.Z * mesa.Z) >= (xPos * xPos + mesa.Z * mesa.Z);
|
||||||
float occludedX = negIsFurther ? xNeg : xPos;
|
float occludedX = negIsFurther ? xNeg : xPos;
|
||||||
float specSideX = negIsFurther ? xPos : xNeg;
|
float specSideX = negIsFurther ? (mesa.X + mesa.RadiusX + 45f) : (mesa.X - mesa.RadiusX - 45f);
|
||||||
|
|
||||||
// Briefly establish visual contact for provokedSpec at initial spot, then move player behind the mesa
|
// Briefly establish visual contact for provokedSpec at initial spot, then move player behind the mesa
|
||||||
session.SetContenderPose(player.Id, specSideX - (negIsFurther ? 12f : -12f), mesa.Z);
|
session.SetContenderPose(player.Id, specSideX - (negIsFurther ? 12f : -12f), mesa.Z);
|
||||||
|
|
@ -261,7 +261,7 @@ namespace RustToDust.Tests
|
||||||
// Run 300 ticks (5.0s > 4.0s TargetMemoryDuration) while player moves laterally behind cover
|
// Run 300 ticks (5.0s > 4.0s TargetMemoryDuration) while player moves laterally behind cover
|
||||||
for (int tick = 0; tick < 300; tick++)
|
for (int tick = 0; tick < 300; tick++)
|
||||||
{
|
{
|
||||||
float latZ = mesa.Z - 14f + (tick / 299f) * 34f;
|
float latZ = mesa.Z - 14f + (tick / 299f) * 28f;
|
||||||
if (tick % 10 == 0)
|
if (tick % 10 == 0)
|
||||||
{
|
{
|
||||||
session.SetContenderPose(player.Id, occludedX, latZ);
|
session.SetContenderPose(player.Id, occludedX, latZ);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue