Replace OldVertices transfer description with the final persistent TMap solution. Document plow ridge widening and AddDepth cap removal for snow volume conservation. Update project status with commit hash and next test steps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3.9 KiB
| date | project | scene | status |
|---|---|---|---|
| 2026-06-07 | garage/kamaz5360 | kamNiagraSnow | solved |
Snow Tracks Disappear When Vehicle Drives Far
Symptoms
- Wheel tracks, plow marks, and brush clearings made on the snow surface disappear.
- Tracks vanish after driving roughly 30–40 metres from where they were made.
- On return the snow looks untouched again.
Environment
- Project:
C:\git\kamaz5360 - Scene:
Content/kamaz5360/Maps/kamNiagraSnow.umap - Class:
ASnowTiledSurfaceManager— single-mesh mode (bUseProceduralSnowSurface = true) - File:
Source/kamaz5360/Snow/SnowTiledSurfaceManager.cpp
Root Cause
UpdateActiveTiles in KamazSnowTruckPawn.cpp calls UpdateProceduralSnowSurface(FocusLocation, bForceRebuild=true) whenever the vehicle moves more than SnowSurfaceHalfExtentCm * 0.65 (default 5000 × 0.65 = 3250 cm ≈ 32 m) from the current surface origin.
UpdateProceduralSnowSurface with bForceRebuild=true resets all six vertex arrays from scratch and re-fills them from GlobalSnowDepthCm. This completely erases all deformations: wheel tracks, plow cuts, ridges, and brush clearings.
Fix (Final — Persistent Deformation Map)
Header (SnowTiledSurfaceManager.h)
Added to private section:
// Global deformation store: grid key → snow depth above ground (cm)
// Written on every stamp; restored when the surface rebuilds or shifts.
TMap<FIntPoint, float> PersistentSurfaceDepths;
TMap<FIntPoint, FColor> PersistentSurfaceColors;
FORCEINLINE FIntPoint WorldToSurfaceGridKey(float WorldX, float WorldY) const
{
const float Spacing = FMath::Max(SnowSurfaceVertexSpacingCm, 1.0f);
return FIntPoint(FMath::RoundToInt(WorldX / Spacing), FMath::RoundToInt(WorldY / Spacing));
}
UpdateProceduralSnowSurface — vertex build loop
After computing LocalPosition (default snow top), before pushing to SnowSurfaceVertices:
const FIntPoint PersistKey = WorldToSurfaceGridKey(WorldX, WorldY);
if (const float* StoredDepth = PersistentSurfaceDepths.Find(PersistKey))
{
LocalPosition.Z = LocalBasePosition.Z + *StoredDepth;
if (const FColor* StoredColor = PersistentSurfaceColors.Find(PersistKey))
VertexColor = *StoredColor;
}
Every stamp function writes to the map
After updating SnowSurfaceVertices[Index].Z and SnowSurfaceColors[Index]:
const FIntPoint PersistKey = WorldToSurfaceGridKey(WorldBase.X, WorldBase.Y);
PersistentSurfaceDepths.Add(PersistKey, SnowSurfaceVertices[Index].Z - SnowSurfaceBaseVertices[Index].Z);
PersistentSurfaceColors.Add(PersistKey, SnowSurfaceColors[Index]);
Applied in: StampProceduralSnowSurface, StampProceduralSnowBox, plow cut block in StampProceduralPlowCutAndDeposit, and DepositSide lambda.
ClearAllSnowTiles
PersistentSurfaceDepths.Empty();
PersistentSurfaceColors.Empty();
Volume Conservation (Plow)
In the DepositSide lambda of StampProceduralPlowCutAndDeposit:
- Removed the
GlobalSnowDepthCm * 0.75fcap onAddDepthso the full removed volume is deposited. - Widened ridge zone:
RidgeHalfY55 → 90 cm, multiplier 2.5 → 3.5 vertex spacings. - Total snow volume is now conserved: snow cut by the plow blade accumulates as a ridge on the sides.
Properties
- Tracks are permanent for the entire game session (until
ClearAllSnowTilesis called). - Memory cost: O(deformed vertices) in
TMap. Typically under 1 MB even for large sessions. - No log spam — removed
KAMAZ_SNOW_SURFACE_REBUILD_TRANSFERlog line (no longer needed). - Works across unlimited surface rebuilds regardless of how far the vehicle travels.
Notes
- Persistence is in-memory only. Tracks are lost on PIE restart or game quit.
For cross-session persistence, serialize
PersistentSurfaceDepthsinEndPlay/BeginPlay. - The tiled-mesh mode (
bUseProceduralTileMeshes) already persists deformation viaSaveDirtyTile/LoadTileon disk. This fix only applies to the single-mesh mode.