Smoother drives across the meadow: no more hitches opening sectors

- Sector maps are put away on a worker thread, and trimmed in batches
- A far sector's texture only needs its look; at most four new ones a frame
- Fresh maps fill rows between their borders instead of testing every cell
- Rocks are marked with plain numbers; marks come back on unpacked maps
- Worked-overlay sort uses float keys; idle belts look on staggered steps
- Chase camera cast no longer allocates; perf demo drives and runs too

Drive phase on a late save: p99 33 -> 16 ms, frames over 20 ms 242 -> 7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-10 12:59:16 +06:00
parent 29485df9e1
commit 172c3b978d
6 changed files with 271 additions and 76 deletions

View File

@ -14,6 +14,8 @@ namespace GrassCutter
/// <summary>Dev bots hold / tap the use buttons through these (they bypass focus checks).</summary>
public static bool BotUseHeld, BotUsePressed, BotAltHeld, BotAltPressed;
public static Vector2 BotMove;
/// <summary>The test bots run.</summary>
public static bool BotSprint;
public static bool BotJumpPressed;
/// <summary>The opening film is running: nobody moves.</summary>
public static bool Cinematic;
@ -63,6 +65,7 @@ namespace GrassCutter
get
{
if (Blocked) { s_sprintOn = false; return false; }
if (BotSprint) return true;
if (G != null && G.leftStickButton.isPressed) return true;
if (!SprintToggle) return Binds.Held(Act.Sprint);
if (s_sprintFrame != Time.frameCount)

View File

@ -676,9 +676,12 @@ namespace GrassCutter
var dir = (back + up * 0.25f).normalized;
float want = _chaseDist;
float reach = want;
var hits = Physics.SphereCastAll(target, 0.35f, dir, want, (1 << Layers.Default) | (1 << Layers.Build) | (1 << Layers.Vehicle), QueryTriggerInteraction.Ignore);
foreach (var h in hits)
int count = Physics.SphereCastNonAlloc(target, 0.35f, dir, s_boomHits, want, (1 << Layers.Default) | (1 << Layers.Build) | (1 << Layers.Vehicle), QueryTriggerInteraction.Ignore);
for (int i = 0; i < count; i++)
{
var h = s_boomHits[i];
if (h.distance > 0f && !h.collider.transform.IsChildOf(v.transform)) reach = Mathf.Min(reach, h.distance - 0.2f);
}
reach = Mathf.Max(1.5f, reach);
// closing in is instant (walls), backing off again is gentle
_chaseShown = _chaseShown <= 0f || reach < _chaseShown ? reach : Mathf.Lerp(_chaseShown, reach, Time.deltaTime * 4f);
@ -689,6 +692,8 @@ namespace GrassCutter
_boom.rotation = Quaternion.LookRotation(target - pos, up);
}
static readonly RaycastHit[] s_boomHits = new RaycastHit[32];
void EnterVehicle(Vehicle v)
{
SetFlying(false);