From 62089dcff3b7f62bf88c1b73f6dba32fbc826e40 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 4 Dec 2026 15:43:54 +0100 Subject: [PATCH] Fix Polygon2D.UV casing, stiffen deep-pen bump-stop, and widen mesa occlusion test margin --- client/TerrainRenderer.cs | 2 +- src/RustToDust.Ymir/ArenaSession.cs | 17 ++++++++++------- tests/RustToDust.Tests/DetectionLosTests.cs | 14 +++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/client/TerrainRenderer.cs b/client/TerrainRenderer.cs index 0443ab5..c8bb7e8 100644 --- a/client/TerrainRenderer.cs +++ b/client/TerrainRenderer.cs @@ -325,7 +325,7 @@ public partial class TerrainRenderer : Node3D new Vector2(rxPx, rzPx), new Vector2(-rxPx, rzPx) }, - Uv = BrushUv + UV = BrushUv }; } diff --git a/src/RustToDust.Ymir/ArenaSession.cs b/src/RustToDust.Ymir/ArenaSession.cs index 99b3948..e72ddcd 100644 --- a/src/RustToDust.Ymir/ArenaSession.cs +++ b/src/RustToDust.Ymir/ArenaSession.cs @@ -426,9 +426,9 @@ namespace RustToDust.Ymir float gripScale = groundedCorners > 0 ? (0.4f + 0.6f * (groundedCorners / 4f)) : 0.12f; 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; - if (groundedCorners > 0 && terrainNormal.Y < 0.74f) + if (groundedCorners > 0 && terrainNormal.Y < 0.78f) { Vector3 cliffHoriz = new Vector3(terrainNormal.X, 0f, terrainNormal.Z); if (cliffHoriz.LengthSquared() > 1e-4f) @@ -643,7 +643,9 @@ namespace RustToDust.Ymir groundedCorners++; maxPen = MathF.Max(maxPen, pen); 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; supportForce += cornerForce; supportTorque += Vector3.Cross(r, cornerForce) * torqueScale; @@ -657,7 +659,8 @@ namespace RustToDust.Ymir groundedCorners = Math.Max(groundedCorners, 1); maxPen = MathF.Max(maxPen, centerPen); 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; } @@ -674,7 +677,7 @@ namespace RustToDust.Ymir float vn = Vector3.Dot(vel, terrainNormal); 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; float maxAllowableY = MathF.Max(0f, maxSpringY - supportForce.Y); if (deflectForce.Y > maxAllowableY) @@ -684,9 +687,9 @@ namespace RustToDust.Ymir 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)); } } } diff --git a/tests/RustToDust.Tests/DetectionLosTests.cs b/tests/RustToDust.Tests/DetectionLosTests.cs index da31233..466cc1d 100644 --- a/tests/RustToDust.Tests/DetectionLosTests.cs +++ b/tests/RustToDust.Tests/DetectionLosTests.cs @@ -206,21 +206,21 @@ namespace RustToDust.Tests session.State.Spectators.UpdateSafeRadius(session.State.Time); TerrainBrush mesa = default; - float bestArea = -1f; + float bestMinRadius = -1f; for (int i = 0; i < session.State.Terrain.Brushes.Count; i++) { var b = session.State.Terrain.Brushes[i]; if (b.Kind == TerrainBrushKind.Mesa && b.HeightDelta >= 22f) { - float area = b.RadiusX * b.RadiusZ; - if (area > bestArea) + float minR = MathF.Min(b.RadiusX, b.RadiusZ); + if (minR > bestMinRadius) { - bestArea = area; + bestMinRadius = minR; 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 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; bool negIsFurther = (xNeg * xNeg + mesa.Z * mesa.Z) >= (xPos * xPos + mesa.Z * mesa.Z); 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 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 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) { session.SetContenderPose(player.Id, occludedX, latZ);