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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user