C2 Tile Manager
Spatial hash tile index for scene objects, forest items, decals, road markings, and AI graph nodes. Provides tile-based scene queries with debug visualization and WebSocket data export.
Spatial hash tile index for scene objects, forest items, decals, road markings, and AI graph nodes. Provides tile-based scene queries with debug visualization and WebSocket data export.
Overview
Builds a lightweight spatial index by dividing the game world into square tiles. Objects are assigned to tiles based on their world-space bounding boxes. Supports debug visualization via ImGui and serves tile data over WebSocket for external tools.
Public API
| Function | Args | Returns | Description |
|---|---|---|---|
M.onExtensionLoaded | - | - | Builds initial tile index on extension load |
M.onMissionLoaded | - | - | Rebuilds tile index when a mission loads |
M.onPreRender | dt | - | ImGui debug window and debug drawing each frame |
M.onSerialize | - | table | Serializes debug state for hot-reload |
M.onDeserialized | data | - | Restores debug state after hot-reload |
M.showWindow | - | - | Opens the ImGui debug window |
M.onC2WebSocketHandlerMessage | args | - | Handles WebSocket tile data requests |
WebSocket Messages
| Message Type | Direction | Description |
|---|---|---|
buildTileData | In | Rebuild tile index (optional tileSize param) |
getTileCacheInfo | In | Request tile grid metadata (bounds, size) |
getSceneTile | In | Request detailed data for tile at (tileX, tileY) |
tileCacheInfo | Out | Response with tile grid bounds and size |
sceneTileData | Out | Full tile data (objects, forest, decals, markings, AI nodes) |
Tile Data Structure
Each tile contains:
| Field | Type | Description |
|---|---|---|
objects | array | Scene objects with pos, rot, scale, bounding box |
forestItems | array | Forest vegetation items with mesh path |
decals | array | Decal instances with material info |
roadMarkings | array | DecalRoad line/parking/crossing markings with node positions |
aiNodes | array | AI navigation graph nodes with links and lane data |
metadata | table | Tile coordinates, size, estimated data size in KB |
Debug Visualization
The ImGui window (showWindow) provides toggles for:
- Tile borders and stats overlay
- Object spheres and OBB wireframes
- Forest item visualization
- Decal quads with material text
- Road marking prisms (parking, crossings, gutters)
- AI graph with optional lane arrows and drivability coloring
- 3D tile grid volume rendering
Usage Example
-- Open debug window
extensions.c2_panelPlugins_tileManager.showWindow()
-- Request tile data via WebSocket
-- Send: {"type": "getSceneTile", "tileX": 5, "tileY": -3}
-- Receive: {"type": "sceneTileData", "tileX": 5, "tileY": -3, "data": {...}}Notes
- Default tile size is 50 meters (configurable 10–2000)
- Position data in tiles is stored relative to tile origin for compactness
- Rotation stored as quaternion
{x, y, z, w} - Objects spanning >50 tiles in any axis are clamped to prevent degenerate cases
- Forest items are indexed by radius coverage across tiles
- Road markings filter for
line_*,gutter*, andcrossing_*materials - Cache is automatically cleared when tile count exceeds 50
See Also
- C2 WebSocket Handler - WebSocket server that routes messages
- C2 Vehicle Manager - Real-time vehicle data streaming
C2 WebSocket Handler
Core WebSocket server for the C2 (Command & Control) system. Provides a JSON message bus on localhost for external tools to communicate with the game engine.
C2 Vehicle Manager
Real-time vehicle data streaming plugin for the C2 WebSocket system. Subscribers receive position, rotation, and velocity updates each frame.