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>
52 lines
2.6 KiB
C#
52 lines
2.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace GrassCutter
|
|
{
|
|
/// <summary>Scene entry point: warms up singletons and configures physics layers.</summary>
|
|
public class GameBoot : MonoBehaviour
|
|
{
|
|
void Awake()
|
|
{
|
|
Application.targetFrameRate = -1;
|
|
Layers.SetupCollisions();
|
|
Fx.Warmup();
|
|
_ = Sfx.I;
|
|
GameSettings.Apply();
|
|
if (CommandLine.Has("-resetsave")) { TeamState.DeleteSave(); Debug.Log("[Boot] save reset"); }
|
|
foreach (var d in UnityEngine.InputSystem.InputSystem.devices) Debug.Log($"[Input] device: {d.name} ({d.layout}) {d.description.product}");
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
NoProbes();
|
|
// dev bots render off-screen so they can run with -batchmode without touching the user's desktop
|
|
// (-onscreen: a real window instead, for measuring what the screen really costs)
|
|
if ((CommandLine.Has("-screenshot") || CommandLine.Has("-autodemo")) && !CommandLine.Has("-onscreen"))
|
|
BotCapture.Setup(int.TryParse(CommandLine.Get("-shotw", "1600"), out var w) ? w : 1600, int.TryParse(CommandLine.Get("-shoth", "900"), out var h) ? h : 900);
|
|
if (CommandLine.Get("-screenshot") is string path) gameObject.AddComponent<AutoScreenshot>().path = path;
|
|
if (CommandLine.Get("-autodemo") is string demo) gameObject.AddComponent<DemoBot>().folder = demo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The planet has no light probes, so interpolating them for every moving thing (two thousand bundles on the belts
|
|
/// of a big farm) is work for nothing: the ambient light is the same. Off on every networked prefab and everything
|
|
/// in the scene, once at boot.
|
|
/// </summary>
|
|
static void NoProbes()
|
|
{
|
|
if (LightmapSettings.lightProbes != null && LightmapSettings.lightProbes.count > 0) return;
|
|
void Off(GameObject go)
|
|
{
|
|
if (!go) return;
|
|
foreach (var r in go.GetComponentsInChildren<Renderer>(true)) r.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
|
|
}
|
|
var nm = Unity.Netcode.NetworkManager.Singleton;
|
|
// (not in the editor: there the prefab is the asset on disk)
|
|
if (!Application.isEditor && nm && nm.NetworkConfig?.Prefabs?.Prefabs != null)
|
|
foreach (var p in nm.NetworkConfig.Prefabs.Prefabs) Off(p.Prefab);
|
|
foreach (var r in Object.FindObjectsByType<Renderer>(FindObjectsInactive.Include, FindObjectsSortMode.None))
|
|
r.lightProbeUsage = UnityEngine.Rendering.LightProbeUsage.Off;
|
|
}
|
|
}
|
|
}
|