Measured in a real 2560x1440 window on the player's Mommy save (RTX 4090): the GPU took ~5 ms, the main thread the rest. - Grass: a fully mown sector draws only its floor (one draw, not up to six); untouched and fully mown sectors share a mow map look, so the fur pile draws them all in one instanced call per pile (GC_SECTOR_BUFFER, sector frames from a structured buffer). Grass draws 1112 -> 337 at the base, 876 -> 439 in the meadow. - Bundles: loose ones sleep when they come to rest (our gravity kept ~600 bodies awake), ones on belts skip the ground checks, and all of them are stepped from one CargoTick instead of two Unity messages each. - Belts leave a jammed line alone and only look every few steps whether it can move; splitters test distance before transforming every bundle. - Light probes off on everything (the planet has none) and the GPU Resident Drawer off: both cost CPU per moving renderer for nothing. - -demogpu N -onscreen measures frame time with one feature off at a time. Base view 17-19 ms -> 14-15 ms, meadow 14-16 ms -> 11.5-12 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace GrassCutter
|
|
{
|
|
/// <summary>
|
|
/// Steps every bundle and every grabbable thing from one FixedUpdate. A big farm has two thousand bundles, and a Unity
|
|
/// message per object per physics step (two scripts each) cost more than what they do, which is mostly nothing.
|
|
/// </summary>
|
|
public class CargoTick : MonoBehaviour
|
|
{
|
|
static CargoTick s_on;
|
|
|
|
public static void Ensure()
|
|
{
|
|
if (s_on) return;
|
|
var go = new GameObject("CargoTick");
|
|
DontDestroyOnLoad(go);
|
|
s_on = go.AddComponent<CargoTick>();
|
|
}
|
|
|
|
void FixedUpdate()
|
|
{
|
|
// backwards: a step can hand a bundle to a depot, which takes it off the list
|
|
var g = Grabbable.All;
|
|
for (int i = g.Count - 1; i >= 0; i--)
|
|
if (i < g.Count && g[i]) g[i].Step();
|
|
var c = Cargo.All;
|
|
for (int i = c.Count - 1; i >= 0; i--)
|
|
if (i < c.Count && c[i]) c[i].Step();
|
|
}
|
|
}
|
|
}
|