Files
sbox-public/engine/Sandbox.Engine/Scene/Components/Clutter/ClutterTile.cs
Antoine Pilote 5cbff413b4 Clutter culling (#5108)
Adds GPU culling
Fixed collision not working for painted instances
LOD is selected on the GPU now

Improvements on our benchmark: 32ms down to 8ms in some cases
2026-07-01 12:22:54 -07:00

49 lines
1.1 KiB
C#

namespace Sandbox.Clutter;
/// <summary>
/// Represents a single tile in the clutter spatial grid.
/// Tracks spawned objects for cleanup when the tile is no longer needed.
/// </summary>
class ClutterTile
{
/// <summary>
/// Grid coordinates of this tile.
/// </summary>
public Vector2Int Coordinates { get; set; }
/// <summary>
/// World-space bounds of this tile.
/// </summary>
public BBox Bounds { get; set; }
/// <summary>
/// Random seed offset for deterministic generation.
/// </summary>
public int SeedOffset { get; set; }
/// <summary>
/// Whether this tile has been populated with clutter instances.
/// </summary>
public bool IsPopulated { get; internal set; }
/// <summary>
/// GameObjects spawned from prefab entries.
/// </summary>
internal List<GameObject> SpawnedObjects { get; } = [];
internal void AddObject( GameObject obj )
{
if ( obj.IsValid() )
SpawnedObjects.Add( obj );
}
internal void Destroy()
{
foreach ( var obj in SpawnedObjects )
if ( obj.IsValid() ) obj.Destroy();
SpawnedObjects.Clear();
IsPopulated = false;
}
}