Vixen
02b45cc4
csharp
public sealed class NavMeshImporter

Bakes a navmesh from the geometry a .vxnavmesh names.

No guide page documents this yet — the page shows what the code says about itself.

As a importer

Extensions
.vxnavmesh

Remarks

This is what makes baking a build step rather than something a game does at start-up. The asset is two files, as everything else in the pipeline is: a .vxnavmesh saying what to bake, and its .meta saying how. What comes out is a NavMeshAsset — inert arrays a player loads and hands to ToNavMesh.

The geometry is a declared dependency, so re-exporting it rebakes the navmesh. That is the entire reason this is an importer rather than a menu item: a navmesh that silently describes the level as it was last week is worse than no navmesh, because nothing about it looks wrong until an agent walks into a wall that was added on Tuesday.

The collision geometry is its own file, deliberately. Baking from the visual mesh means voxelising every leaf, every railing and every decorative moulding, which is slower and worse: navigation wants the shape a body collides with. The file named here is whatever the project uses for that, read through the same ModelReader the model importer uses.

A level is usually more than one file. geometry takes either one path or a list of placed pieces — a floor, a building, three crates at three positions — each read, transformed to where it stands, and voxelised into one soup with the rest. Every piece is declared as a dependency of its own, so moving a crate in the source rebakes the navmesh and re-exporting one building does not require touching the others.

What this is not is baking a scene. The placements here are authored in this file rather than read out of the level the game actually loads, because there is no compiled scene to read them from — see the assembly's README. When there is, the work left is to fill the same list from it: the reading, the transforming and the flattening below do not care where a placement came from.

The document is small enough to read by hand rather than through the YAML object binder: some paths, and a list of area boxes. Doing it by hand is also what lets each mistake be reported against the field that made it, rather than as a binder exception naming a type.

Fields and properties (1)

  • public override int Version

    Its own version. Bumping it invalidates every artefact it has ever produced, which is the whole mechanism for "I fixed the mip filter, re-import everything".

Methods (1)

Used by (2)

  • BuiltInImportersVixen.Editor.Assets
  • NavMeshImporterTestsVixen.Editor.Assets.Tests