feat(ground-ai): add offline tank navmesh and cover baking prototype

Add Stage 0 offline map geometry extraction and Recast/Detour baking tools for ground AI navigation on feat/tank-ai-nav:

- Vendor upstream recastnavigation Recast and Detour sources (zlib license) under native/third_party/recastnavigation.
- Define shared .wtogeo and .wtonav binary layouts in native/wto-nav/wto_nav_format.h.
- Add mission-bounds.mts to collect union ground battle areas, spawns, and capture zones across mission templates.
- Add Rust extractor (tools/navgen/extract) using wt-unpack and config/rendinst_dmg.blk destructionImpulse thresholds to classify hard solids, bridges, crushable objects, and tree trunks in Dagor world space.
- Add multi-threaded MSVC C++ baker (tools/navgen/bake) producing 3 vehicle-width tiled Detour navmeshes, island pruning, dual-height voxel tank covers (full, hull-down, corner peek, retreat-verified), 8m tactical grids, and spawn-to-cap connectivity checks.
- Add zero-dependency PNG top-down preview renderer (tools/navgen/render-preview.py).

Verified: Rust release build (0 warnings), MSVC x64 baker build (0 warnings), root typecheck, and end-to-end extraction/baking/100% 3-tier connectivity and preview rendering on avg_berlin, avg_poland, and avg_hurtgen (2.61.0.58).
This commit is contained in:
N0VAN0M4LY committed 2026-12-04 11:33:32 +08:00
1 parent 688406bb76
commit 842ee23fa4
40 files changed
+22824

No files matched your search

+143
View File
@@ -0,0 +1,143 @@
/*
* Shared binary format definitions for WTOffline ground AI navigation data:
* - `.wtogeo`: offline intermediate geometry dump (extractor -> Recast baker)
* - `.wtonav`: runtime navigation pack (baked Detour meshes + covers + tactical grid)
*
* All coordinates are in Dagor world space (left-handed, Y up, metres).
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define WTO_GEO_MAGIC "WTOGEO\0\1"
#define WTO_GEO_VERSION 1u
#define WTO_NAV_MAGIC "WTONAV\0\1"
#define WTO_NAV_VERSION 1u
#define WTO_NAV_TIER_COUNT 3u
#define WTO_NAV_TIER_NARROW 0u /* Tracked width <= 2.9 m (agentRadius 1.65 m) */
#define WTO_NAV_TIER_STANDARD 1u /* Tracked width <= 3.6 m (agentRadius 2.05 m) */
#define WTO_NAV_TIER_WIDE 2u /* Wide/heavy tracked > 3.6 m (agentRadius 2.45 m) */
/* Detour polygon Area IDs (0 = RC_NULL_AREA / unwalkable). */
enum WtoPolyArea {
WTO_AREA_UNWALKABLE = 0,
WTO_AREA_ROAD = 1,
WTO_AREA_BRIDGE = 2,
WTO_AREA_GROUND = 3,
WTO_AREA_ROUGH = 4,
WTO_AREA_FOREST = 5,
WTO_AREA_CRUSHABLE = 6,
WTO_AREA_SHALLOW_WATER = 7,
WTO_AREA_CHOKEPOINT = 8,
WTO_AREA_EXPOSED = 9,
WTO_AREA_DEEP_WATER = 10,
WTO_AREA_NO_GO = 11
};
/* Detour polygon flags for runtime dtQueryFilter filtering. */
enum WtoPolyFlag {
WTO_FLAG_WALK = 0x01,
WTO_FLAG_SHALLOW_WATER = 0x02,
WTO_FLAG_DEEP_WATER = 0x04,
WTO_FLAG_CHOKEPOINT = 0x08,
WTO_FLAG_BLOCKED = 0x10
};
/* Obstacle classification written into `.wtogeo` by the extractor. */
enum WtoObstacleClass {
WTO_OBS_HARD_SOLID = 0, /* Buildings, rocks, cliffs, bunkers, concrete walls */
WTO_OBS_BRIDGE_DECK = 1, /* Walkable bridge decks and ramps */
WTO_OBS_CRUSHABLE = 2, /* Wooden fences, hedges, low-HP destructibles */
WTO_OBS_TREE_THICK = 3, /* Thick immovable tree trunks (r >= 0.25 m) */
WTO_OBS_TREE_THIN = 4 /* Thin tree trunks / saplings (high-cost forest) */
};
/* Baked tank cover classifications. */
enum WtoCoverKind {
WTO_COVER_FULL = 1, /* Blocks hull + turret (reload, repair, corner peek) */
WTO_COVER_HULLDOWN = 2 /* Blocks hull, turret clear with forward firing arc */
};
#pragma pack(push, 1)
/* Intermediate geometry bundle header (`.wtogeo`). */
typedef struct WtoGeoHeader {
char magic[8]; /* WTO_GEO_MAGIC */
uint32_t version; /* WTO_GEO_VERSION */
uint32_t flags;
uint8_t everSha1[20]; /* Built-in SHA-1 from DBLD eVER block */
float waterLevel; /* Level water_level in metres (-1e6 if none) */
float boundsMin[2]; /* World XZ crop min (battle area union + margin) */
float boundsMax[2]; /* World XZ crop max */
uint32_t hmWidth; /* Cropped heightmap grid columns (X) */
uint32_t hmHeight; /* Cropped heightmap grid rows (Z) */
float hmCellSize; /* Metres per heightmap sample */
float hmOrigin[2]; /* World XZ of cropped sample (0, 0) */
uint32_t obsVertCount; /* Number of float3 obstacle vertices */
uint32_t obsTriCount; /* Number of obstacle triangles (uint32[3] + uint8 class) */
} WtoGeoHeader;
/* Baked tank cover point (48 bytes). */
typedef struct WtoCoverPoint {
float pos[3]; /* World XYZ parking position behind cover */
float coverDir[2]; /* Unit XZ vector pointing FROM pos TOWARD the blocked threat */
float retreatDir[2]; /* Unit XZ safe reverse/retreat direction away from cover */
float peekLeft[3]; /* World XYZ left corner peek spot (valid if hasPeekLeft) */
float peekRight[3]; /* World XYZ right corner peek spot (valid if hasPeekRight) */
float halfAngleDeg; /* Effective covered half-angle around coverDir */
float heightM; /* Measured hard-obstacle height above ground at cover */
float widthM; /* Continuous hard-obstacle width */
uint8_t kind; /* WtoCoverKind */
uint8_t hasPeekLeft; /* 1 if peekLeft is valid and navigable */
uint8_t hasPeekRight; /* 1 if peekRight is valid and navigable */
uint8_t reserved;
} WtoCoverPoint;
/* Low-resolution (8 m) tactical grid cell (4 bytes). */
typedef struct WtoTacticalCell {
uint8_t exposure; /* 0..255: static visibility exposure from enemy side */
uint8_t clearanceHalfM; /* Distance to nearest hard obstacle in 0.5 m units (0..127.5 m) */
uint8_t corridorTeam1; /* 0..255: Team 1 replay prior (128 = neutral) */
uint8_t corridorTeam2; /* 0..255: Team 2 replay prior (128 = neutral) */
} WtoTacticalCell;
/* Runtime navigation pack header (`.wtonav`, uncompressed payload header). */
typedef struct WtoNavHeader {
char magic[8]; /* WTO_NAV_MAGIC */
uint32_t version; /* WTO_NAV_VERSION */
uint32_t flags;
uint8_t everSha1[20]; /* Source level eVER SHA-1 fingerprint */
float bmin[3]; /* World AABB min */
float bmax[3]; /* World AABB max */
float waterLevel;
uint32_t tierCount; /* WTO_NAV_TIER_COUNT (3) */
uint32_t tierOffsets[WTO_NAV_TIER_COUNT];
uint32_t tierSizes[WTO_NAV_TIER_COUNT];
uint32_t coverOffset;
uint32_t coverCount;
uint32_t tacOffset;
uint32_t tacCols;
uint32_t tacRows;
float tacCellM;
float tacOrigin[2];
} WtoNavHeader;
/* Per-tier Detour blob layout at tierOffsets[t]:
* dtNavMeshParams (exact upstream struct)
* uint32_t tileCount
* repeated tileCount times:
* uint32_t tileDataSize
* uint8_t tileData[tileDataSize]
*/
#pragma pack(pop)
#ifdef __cplusplus
}
#endif