Document Kamaz OSM snow tile workflow

This commit is contained in:
Codex qore 2026-06-01 06:44:06 +03:00
parent 3682e03f3d
commit 6fdf221c64
4 changed files with 154 additions and 0 deletions

View file

@ -43,3 +43,13 @@ The user worked with an open Blender KAMAZ 5360 model and asked the agent to pre
- Buzina/CAN joystick docs, tools, firmware source, RawInput config, and a passive Unreal component were copied from `C:\git\joystick`. It is not yet connected to plow control.
- PIE initially crashed because UE 5.7 `HTTPServer` asserts when binding `FHttpPath(TEXT("/"))`; the dashboard route was changed to `/dashboard`.
- Detailed notes are now appended to `projects/garage/kamaz5360-chaos-vehicle.md`; reusable crash note: `problems/2026-05-26-ue57-httpserver-root-route-crash.md`.
## 2026-06-01 OSM Tverskaya Snow Tile Work
- Added a separate OSM test level `/Game/kamaz5360/Maps/Tverskaya` in `C:\git\kamaz5360`.
- Downloaded Tverskaya/Moscow OSM data to `Import/OSM/tverskaya.osm` using Overpass bbox `55.7530,37.5800,55.7820,37.6250`.
- Implemented `AKamazOsmStreetMapActor` to generate real-scale roads, sidewalks, terracotta buildings, and road/sidewalk snow masks.
- Added `setup_tverskaya_level.py` to duplicate the snow tile map, spawn OSM geometry, spawn `ASnowTiledSurfaceManager`, apply OSM snow masks, and place the KAMAZ near `55.76555, 37.60582`.
- Fixed OSM snow mask persistence by making `SnowSurfaceMaskSegments` a `UPROPERTY`; otherwise the mask was lost after saving/loading the level.
- Added a two-layer snow visibility approach: coarse distant OSM background snow plus detailed nearby procedural tiles. Dirty unloaded tiles leave low-poly far visual copies so cleared snow and snowdrifts remain visible from a distance.
- Documented the solution in `projects/garage/kamaz5360-chaos-vehicle.md` and `problems/2026-06-01-kamaz-osm-snow-tile-visibility.md`.

View file

@ -0,0 +1,64 @@
# KAMAZ OSM Snow Tile Visibility And Persistence
Date: 2026-06-01
Project: `garage`
Repo: `C:\git\kamaz5360`
## Problem
On the OSM Tverskaya snow test map, detailed snow tiles disappeared in the distance. The first instinct was to increase `ActiveTileRadius` so the player could see changed snow 500 m away, but with 10 m tiles that would require thousands of active procedural mesh components and would hurt performance.
A second bug made the OSM snow mask disappear after saving/loading the generated level: the mask worked during the setup commandlet but not after opening the `.umap`.
## Symptoms
- Distant snow tiles disappear while driving.
- Cleaned snow and snowdrifts may not be visible after a dirty tile unloads.
- If the snow mask is not serialized, snow is no longer constrained to roads/sidewalks on reload.
- OSM maps can stutter when per-stamp snow logs print every frame.
## Solution
Use a two-layer snow visualization:
1. A coarse OSM road/sidewalk background snow mesh for distant continuity.
2. Detailed active procedural tile meshes around the truck for wheel tracks, plow cuts, brush cleaning, and snowdrift volume.
When a dirty detailed tile unloads, keep a low-poly far visual copy of that tile. This preserves the visible result of cleared snow and pushed snowdrifts without keeping the full detailed simulation tile active.
Serialize `ASnowTiledSurfaceManager::SnowSurfaceMaskSegments` as a `UPROPERTY`, then rebuild the tile index from that serialized array at runtime.
Keep verbose tile/stamp logs behind debug flags:
- `KAMAZ_SNOW_TILE_DEPOSIT`
- `KAMAZ_SNOW_TILE_PLOW`
- per-tile create/load/unload/save logs
## Current Parameters
For `/Game/kamaz5360/Maps/Tverskaya`:
- `TileWorldSizeCm = 1000`
- `ActiveTileRadius = 3`
- `MaxLoadedTiles = 81`
- `SnowSurfaceVertexSpacingCm = 20`
- `bUseTiledBackgroundSurface = true`
- `TiledBackgroundVertexSpacingCm = 500`
- `bKeepUnloadedDirtyTileVisuals = true`
- `FarSnowTileVisualQuads = 10`
- `MaxFarSnowTileVisuals = 800`
## Expected Logs
```text
KAMAZ_OSM_BUILD file=C:/git/kamaz5360/Import/OSM/tverskaya.osm ...
KAMAZ_SNOW_SURFACE_MASK segments=50099 restricted=1
KAMAZ_OSM_SNOW_MASK applied segments=50099
KAMAZ_SNOW_SURFACE_MASK_INDEX segments=50099 indexedTiles=87532
KAMAZ_SNOW_TILES start mode=ProceduralTileMeshes ...
KAMAZ_SNOW_TILE_BACKGROUND ...
```
## Rule Of Thumb
Do not solve far visibility by keeping every distant tile active. Keep only nearby simulation tiles active, and use far visual LODs for distant saved/dirty state.

View file

@ -22,3 +22,4 @@ Current entries:
- `2026-05-26-ue57-chaos-vehicle-blender-wheel-suspension.md`
- `2026-05-26-ndi-sources-hidden-by-vpn-interface-priority.md`
- `2026-05-26-ue57-httpserver-root-route-crash.md`
- `2026-06-01-kamaz-osm-snow-tile-visibility.md`

View file

@ -568,3 +568,82 @@ Actual push result on 2026-05-28:
- Branch pushed: `kamaz-landscape`
- Remote `master` was not overwritten because it had diverged and pointed at `f67bdca Add MOZA input telemetry and joystick prep`.
- Use `git checkout kamaz-landscape` or `git checkout tags/kamaz-landscape` to restore this exact Landscape/plow/brush checkpoint.
## OSM Tverskaya Snow Tile Test
Date: 2026-06-01
The project now has a separate OSM snow test map:
```text
/Game/kamaz5360/Maps/Tverskaya
```
Local setup assets:
```text
C:\git\kamaz5360\Import\OSM\tverskaya.osm
C:\git\kamaz5360\Import\OSM\tverskaya.overpassql
C:\git\kamaz5360\Scripts\setup_tverskaya_level.py
C:\git\kamaz5360\Docs\tverskaya_osm_snow.md
```
The Overpass bbox for the Tverskaya test extract is:
```text
55.7530,37.5800,55.7820,37.6250
```
When writing the Overpass query on Windows, save it as UTF-8 without BOM before sending it with `curl.exe --data-urlencode`. A BOM caused an Overpass mirror to return HTML or reject the query.
The OSM actor is `AKamazOsmStreetMapActor`. It imports OSM XML directly in C++ and generates road, sidewalk, building meshes and snow mask segments for `ASnowTiledSurfaceManager`.
Current map setup:
- OSM scale: `UnrealUnitsPerMeter = 100.0`, real UE centimeter scale.
- Spawn seed: `55.76555, 37.60582`, snapped to nearest drivable OSM road with `LatLonToNearestRoadWorld`.
- Snow tiles: `TileWorldSizeCm = 1000`, so each active tile is 10 m x 10 m.
- Active detailed radius: `ActiveTileRadius = 3`, roughly 70 m x 70 m around the truck.
- `MaxLoadedTiles = 81`.
- Detailed snow vertex spacing: `20 cm`.
- Global snow depth: `20 cm`.
- Residual snow after plow: `1 cm`.
Important architecture decision:
- Do not solve distant visibility by raising `ActiveTileRadius` to hundreds of meters; at 10 m tiles this explodes into thousands of mesh components.
- Use two layers:
1. a coarse OSM road/sidewalk background snow mesh for distant continuity;
2. detailed active procedural tile meshes near the truck for wheel tracks, plow cuts, brush cleaning, and snowdrift volume.
- When a dirty active tile unloads, the manager leaves a low-poly far visual copy of that tile so cleared snow and pushed snowdrifts remain visible from far away.
Critical solved bug:
`ASnowTiledSurfaceManager::SnowSurfaceMaskSegments` must be a `UPROPERTY`. Without that, the OSM snow mask works only inside the setup commandlet and is lost after saving/loading the map. Runtime symptom: snow appears as if it is not constrained to OSM roads/sidewalks.
Expected setup/runtime log markers:
```text
KAMAZ_OSM_BUILD file=C:/git/kamaz5360/Import/OSM/tverskaya.osm ...
KAMAZ_SNOW_SURFACE_MASK segments=50099 restricted=1
KAMAZ_OSM_SNOW_MASK applied segments=50099
KAMAZ_OSM_NEAREST_ROAD lat=55.7655500 lon=37.6058200 found=1 ...
KAMAZ_SNOW_SURFACE_MASK_INDEX segments=50099 indexedTiles=87532
KAMAZ_SNOW_TILES start mode=ProceduralTileMeshes ...
KAMAZ_SNOW_TILE_BACKGROUND ...
```
Performance notes:
- Verbose per-stamp logs such as `KAMAZ_SNOW_TILE_DEPOSIT`, `KAMAZ_SNOW_TILE_PLOW`, and per-tile create/load/unload logs can destroy test performance on OSM maps. Keep them behind debug flags and off for normal testing.
- Keep detailed tile meshes active only around the truck.
- Distant changed snow should be visual LOD, not full simulation.
Telemetry page:
```text
http://127.0.0.1:8765/dashboard
http://127.0.0.1:8765/api/telemetry
```
The telemetry route is only available during Play/PIE while the pawn with `UKamazTelemetryWebServerComponent` exists.