Nebula
Loading...
Searching...
No Matches
Navigation::Build Namespace Reference

Classes

struct  AreaDefinition
struct  AreaPrism
 the vertical prism an area volume marks More...
class  AreaTable
struct  AreaVolume
 assigns an area to the walkable surface inside it More...
struct  BuildInput
 everything a build needs More...
struct  BuildOutput
 the built navmesh More...
struct  BuildStats
 statistics of a build More...
struct  HeightFieldSource
 height field placed in the world, laid out like Physics::HeightFieldInput More...
class  InputHasher
 FNV-1a, 64 bit. More...
class  LogContext
 Forwards Recast errors to the log. More...
struct  MeshSource
 triangle geometry placed in the world More...
struct  Tile
 one tile of Detour data, as dtCreateNavMeshData produced it More...
struct  TileGrid
struct  TileScratch
 Owns the Recast intermediates of one tile. More...
struct  WorldMeshes
 Triangles of all mesh sources in world space, plus the tiles each triangle touches. More...

Enumerations

enum class  BakeResult { Baked , UpToDate , Failed }
enum class  TileResult { Built , Empty , Failed }
enum  PolyFlags : unsigned short { PolyFlag_Walk = 1 << 0 }
 polygon flags written into the Detour data More...

Functions

Math::mat4 ColliderTransform (const Math::vec3 &position, const Math::quat &orientation, const Math::vec3 &localPosition, const Math::quat &localOrientation)
 world transform of a collider shape, placed like physics places it: the entity's world position and orientation composed with the collider offset.
Util::Array< Math::vec3 > ConvexHullXZ (const Util::Array< Math::vec3 > &input)
 Monotone chain.
AreaPrism MakeAreaPrism (const Math::mat4 &boxTransform, const Math::bbox &localBox, const Math::mat4 &pointTransform, const Math::vec3 *points, SizeT pointCount)
 the prism an area volume marks.
Util::Array< Math::vec3 > BoxOutlineXZ (const Math::mat4 &boxTransform, const Math::bbox &localBox)
 the outline of a box seen from above, the hull of its corners, in world space
static float SegmentDistanceSqXZ (const Math::vec3 &p, const Math::vec3 &a, const Math::vec3 &b)
IndexT OutlineInsertIndex (const Math::vec3 *outline, SizeT count, const Math::vec3 &point)
 where a point goes into an outline: the index of the edge closest to it seen from above, the point is inserted after that index, between the two outline points of the edge
static bool SegmentsCrossXZ (const Math::vec3 &a, const Math::vec3 &b, const Math::vec3 &c, const Math::vec3 &d)
bool IsSimpleOutlineXZ (const Math::vec3 *outline, SizeT count)
 true if no two edges of the outline cross each other seen from above
static bool RayTriangle (const Math::vec3 &o, const Math::vec3 &d, const float *a, const float *b, const float *c, float &t)
static bool RayBox (const Math::vec3 &o, const Math::vec3 &d, const float *bmin, const float *bmax)
bool RaycastNavMesh (const dtNavMesh &navMesh, const Math::point &start, const Math::vector &dir, float &outT)
 Walks the detail triangles of every polygon, the same triangles Detour gives heights with.
bool LoadMeshSource (Util::StringAtom resource, IndexT meshIndex, IndexT primGroup, const Math::mat4 &transform, MeshSource &out)
 fill a mesh source from a mesh URN, folder:file:msh, like a MeshCollider reads it
bool LoadHeightFieldSource (Util::StringAtom resource, float heightRange, float sizeX, float sizeZ, const Math::mat4 &transform, HeightFieldSource &out)
 fill a height field source from a heightmap URN, folder:file:tex, like a HeightFieldCollider reads it
bool CompileAreaTable ()
 compile the project table to AreaTableFile, returns false if there is no project table or it doesn't compile
bool WriteAreaTableSource (const Util::Array< AreaDefinition > &areas, const IO::URI &file)
 The flags are written the way the schema names them, separated by spaces, the color as its fields.
void RegisterPathMappings ()
 register the work and export extensions of the nav URN type
bool SetupBuildInput (const NavMeshT &description, const AreaTable &areas, BuildInput &out)
 fill a build input from a description, loading every source through the geometry loader and resolving area names with the area table
uint64_t InputHash (const void *workData, SizeT workSize, const AreaTable &areas, const BuildInput &input)
 The description is part of the work data, only the geometry it points at has to be added.
bool IsBakedNavMesh (const void *data, SizeT size)
 check that a buffer holds a baked navmesh
bool ReadInputHash (const IO::URI &exportFile, uint64_t &hash)
 read the input hash stored in a baked navmesh, returns false if the file is missing or not a baked navmesh
static bool ReadWorkFile (const IO::URI &workFile, Util::Blob &data, NavMeshT &description)
static bool WriteBakedNavMesh (const IO::URI &exportFile, const NavMeshT &description, const BuildOutput &output, uint64_t hash)
BakeResult BakeNavMesh (const IO::URI &workFile, const IO::URI &exportFile, bool force)
 bake a work file to an export file, registers the default geometry loader if none is registered.
dtNavMesh * CreateDetourNavMesh (const BakedNavMesh *baked)
 create a Detour navmesh from baked data, the tile data is copied. Free with dtFreeNavMesh
static Math::vec3 TransformPoint (const Math::mat4 &m, float x, float y, float z)
static bool FlipsWinding (const Math::mat4 &m)
 A mirroring transform turns the triangles over, Recast uses the winding to tell up from down.
static float HeightFieldSampleHeight (const HeightFieldSource &field, SizeT x, SizeT z)
static bool IsValidHeightField (const HeightFieldSource &field)
static Math::bbox HeightFieldBounds (const HeightFieldSource &field)
Math::bbox SourceBounds (const BuildInput &input)
 return the world bounds of all sources
static void SetupWorldMeshes (const BuildInput &input, const TileGrid &grid, WorldMeshes &out)
 Transforms all meshes into one world space triangle soup and sorts the triangles into tiles.
static void AppendHeightFieldTriangles (const HeightFieldSource &field, const float *bmin, const float *bmax, Util::Array< float > &verts, Util::Array< int > &tris)
 Appends the height field triangles which can touch the world space box to verts and tris.
static bool RasterizeTriangles (rcContext &ctx, const rcConfig &config, const float *verts, int vertCount, const int *tris, int triCount, Util::Array< unsigned char > &areas, rcHeightfield &solid)
 Marks walkable triangles and rasterizes them into the heightfield.
static TileResult BuildTile (rcContext &ctx, const BuildInput &input, const Util::Array< IndexT > &areaOrder, const rcConfig &baseConfig, const TileGrid &grid, const WorldMeshes &meshes, int tx, int tz, Tile &tile, BuildStats &stats)
static void SetupConfig (const BuildInput &input, int tileSize, rcConfig &config)
bool BuildNavMesh (const BuildInput &input, BuildOutput &output, BuildStats *stats=nullptr)
 build the navmesh, returns false if nothing walkable was found or a tile failed
dtNavMesh * CreateDetourNavMesh (const BuildOutput &output)
 create a Detour navmesh from built data, the tile data is copied. Free with dtFreeNavMesh

Variables

static constexpr const char * AreaTableFile = "nav:navareas.navareas"
 the compiled table
static constexpr const char * AreaTableSource = "proj:work/data/tables/navareas.json"
 the table a project edits
static constexpr unsigned char NoArea = 0
static constexpr unsigned char MaxAreas = 64
static constexpr uint32_t BuilderVersion = 1
 part of every input hash, bump it when the builder output changes for the same input
static constexpr int MaxVertsPerPoly = 6
static constexpr int MinTileSize = 8
static constexpr int MaxTileBits = 14
static constexpr float MaxStoredHeight = 32767.0f
 physics stores height field samples as signed 16 bit, see Physics::CookHeightField
static constexpr unsigned char DefaultWalkableArea = 63
 the area of walkable surface which no area volume covers, Recast's RC_WALKABLE_AREA

Enumeration Type Documentation

◆ BakeResult

enum class Navigation::Build::BakeResult
strong
Enumerator
Baked 
UpToDate 
Failed 

◆ PolyFlags

enum Navigation::Build::PolyFlags : unsigned short

polygon flags written into the Detour data

Enumerator
PolyFlag_Walk 

◆ TileResult

enum class Navigation::Build::TileResult
strong
Enumerator
Built 
Empty 
Failed 

Function Documentation

◆ AppendHeightFieldTriangles()

void Navigation::Build::AppendHeightFieldTriangles ( const HeightFieldSource & field,
const float * bmin,
const float * bmax,
Util::Array< float > & verts,
Util::Array< int > & tris )
static

Appends the height field triangles which can touch the world space box to verts and tris.

◆ BakeNavMesh()

BakeResult Navigation::Build::BakeNavMesh ( const IO::URI & workFile,
const IO::URI & exportFile,
bool force )

bake a work file to an export file, registers the default geometry loader if none is registered.

Areas are resolved with the compiled area table, AreaTableFile, or the built in areas if there is none

◆ BoxOutlineXZ()

Util::Array< Math::vec3 > Navigation::Build::BoxOutlineXZ ( const Math::mat4 & boxTransform,
const Math::bbox & localBox )

the outline of a box seen from above, the hull of its corners, in world space

◆ BuildNavMesh()

bool Navigation::Build::BuildNavMesh ( const BuildInput & input,
BuildOutput & output,
BuildStats * outStats )

build the navmesh, returns false if nothing walkable was found or a tile failed

◆ BuildTile()

TileResult Navigation::Build::BuildTile ( rcContext & ctx,
const BuildInput & input,
const Util::Array< IndexT > & areaOrder,
const rcConfig & baseConfig,
const TileGrid & grid,
const WorldMeshes & meshes,
int tx,
int tz,
Tile & tile,
BuildStats & stats )
static

◆ ColliderTransform()

Math::mat4 Navigation::Build::ColliderTransform ( const Math::vec3 & position,
const Math::quat & orientation,
const Math::vec3 & localPosition,
const Math::quat & localOrientation )

world transform of a collider shape, placed like physics places it: the entity's world position and orientation composed with the collider offset.

Scale is ignored, physics doesn't scale collider shapes

◆ CompileAreaTable()

bool Navigation::Build::CompileAreaTable ( )

compile the project table to AreaTableFile, returns false if there is no project table or it doesn't compile

◆ ConvexHullXZ()

Util::Array< Math::vec3 > Navigation::Build::ConvexHullXZ ( const Util::Array< Math::vec3 > & input)

Monotone chain.

convex hull of points seen from above, in x and z, counter clockwise. The y of the points is kept

◆ CreateDetourNavMesh() [1/2]

dtNavMesh * Navigation::Build::CreateDetourNavMesh ( const BakedNavMesh * baked)

create a Detour navmesh from baked data, the tile data is copied. Free with dtFreeNavMesh

◆ CreateDetourNavMesh() [2/2]

dtNavMesh * Navigation::Build::CreateDetourNavMesh ( const BuildOutput & output)

create a Detour navmesh from built data, the tile data is copied. Free with dtFreeNavMesh

◆ FlipsWinding()

bool Navigation::Build::FlipsWinding ( const Math::mat4 & m)
inlinestatic

A mirroring transform turns the triangles over, Recast uses the winding to tell up from down.

◆ HeightFieldBounds()

Math::bbox Navigation::Build::HeightFieldBounds ( const HeightFieldSource & field)
static

◆ HeightFieldSampleHeight()

float Navigation::Build::HeightFieldSampleHeight ( const HeightFieldSource & field,
SizeT x,
SizeT z )
inlinestatic

◆ InputHash()

uint64_t Navigation::Build::InputHash ( const void * workData,
SizeT workSize,
const AreaTable & areas,
const BuildInput & input )

The description is part of the work data, only the geometry it points at has to be added.

hash of the work file data, the area table and the loaded source geometry

◆ IsBakedNavMesh()

bool Navigation::Build::IsBakedNavMesh ( const void * data,
SizeT size )

check that a buffer holds a baked navmesh

◆ IsSimpleOutlineXZ()

bool Navigation::Build::IsSimpleOutlineXZ ( const Math::vec3 * outline,
SizeT count )

true if no two edges of the outline cross each other seen from above

◆ IsValidHeightField()

bool Navigation::Build::IsValidHeightField ( const HeightFieldSource & field)
static

◆ LoadHeightFieldSource()

bool Navigation::Build::LoadHeightFieldSource ( Util::StringAtom resource,
float heightRange,
float sizeX,
float sizeZ,
const Math::mat4 & transform,
HeightFieldSource & out )

fill a height field source from a heightmap URN, folder:file:tex, like a HeightFieldCollider reads it

◆ LoadMeshSource()

bool Navigation::Build::LoadMeshSource ( Util::StringAtom resource,
IndexT meshIndex,
IndexT primGroup,
const Math::mat4 & transform,
MeshSource & out )

fill a mesh source from a mesh URN, folder:file:msh, like a MeshCollider reads it

◆ MakeAreaPrism()

AreaPrism Navigation::Build::MakeAreaPrism ( const Math::mat4 & boxTransform,
const Math::bbox & localBox,
const Math::mat4 & pointTransform,
const Math::vec3 * points,
SizeT pointCount )

the prism an area volume marks.

With fewer than 3 points it is the prism around the box. Otherwise the points are the outline, in order, and the height span covers every point give or take half the height of the box, so the surface a point was placed on is inside. The outline may be concave. Points are transformed by pointTransform, box corners by boxTransform

◆ OutlineInsertIndex()

IndexT Navigation::Build::OutlineInsertIndex ( const Math::vec3 * outline,
SizeT count,
const Math::vec3 & point )

where a point goes into an outline: the index of the edge closest to it seen from above, the point is inserted after that index, between the two outline points of the edge

◆ RasterizeTriangles()

bool Navigation::Build::RasterizeTriangles ( rcContext & ctx,
const rcConfig & config,
const float * verts,
int vertCount,
const int * tris,
int triCount,
Util::Array< unsigned char > & areas,
rcHeightfield & solid )
static

Marks walkable triangles and rasterizes them into the heightfield.

◆ RayBox()

bool Navigation::Build::RayBox ( const Math::vec3 & o,
const Math::vec3 & d,
const float * bmin,
const float * bmax )
static

◆ RaycastNavMesh()

bool Navigation::Build::RaycastNavMesh ( const dtNavMesh & navMesh,
const Math::point & start,
const Math::vector & dir,
float & outT )

Walks the detail triangles of every polygon, the same triangles Detour gives heights with.

intersect a ray with the detail surface of a navmesh, t is in units of dir. Returns false if it misses

◆ RayTriangle()

bool Navigation::Build::RayTriangle ( const Math::vec3 & o,
const Math::vec3 & d,
const float * a,
const float * b,
const float * c,
float & t )
static

◆ ReadInputHash()

bool Navigation::Build::ReadInputHash ( const IO::URI & exportFile,
uint64_t & hash )

read the input hash stored in a baked navmesh, returns false if the file is missing or not a baked navmesh

◆ ReadWorkFile()

bool Navigation::Build::ReadWorkFile ( const IO::URI & workFile,
Util::Blob & data,
NavMeshT & description )
static

◆ RegisterPathMappings()

void Navigation::Build::RegisterPathMappings ( )

register the work and export extensions of the nav URN type

◆ SegmentDistanceSqXZ()

float Navigation::Build::SegmentDistanceSqXZ ( const Math::vec3 & p,
const Math::vec3 & a,
const Math::vec3 & b )
static

◆ SegmentsCrossXZ()

bool Navigation::Build::SegmentsCrossXZ ( const Math::vec3 & a,
const Math::vec3 & b,
const Math::vec3 & c,
const Math::vec3 & d )
static

◆ SetupBuildInput()

bool Navigation::Build::SetupBuildInput ( const NavMeshT & description,
const AreaTable & areas,
BuildInput & out )

fill a build input from a description, loading every source through the geometry loader and resolving area names with the area table

◆ SetupConfig()

void Navigation::Build::SetupConfig ( const BuildInput & input,
int tileSize,
rcConfig & config )
static

◆ SetupWorldMeshes()

void Navigation::Build::SetupWorldMeshes ( const BuildInput & input,
const TileGrid & grid,
WorldMeshes & out )
static

Transforms all meshes into one world space triangle soup and sorts the triangles into tiles.

◆ SourceBounds()

Math::bbox Navigation::Build::SourceBounds ( const BuildInput & input)

return the world bounds of all sources

◆ TransformPoint()

Math::vec3 Navigation::Build::TransformPoint ( const Math::mat4 & m,
float x,
float y,
float z )
inlinestatic

◆ WriteAreaTableSource()

bool Navigation::Build::WriteAreaTableSource ( const Util::Array< AreaDefinition > & areas,
const IO::URI & file )

The flags are written the way the schema names them, separated by spaces, the color as its fields.

write areas as a table to compile, like the project table. The built in areas are left out, they always exist

◆ WriteBakedNavMesh()

bool Navigation::Build::WriteBakedNavMesh ( const IO::URI & exportFile,
const NavMeshT & description,
const BuildOutput & output,
uint64_t hash )
static

Variable Documentation

◆ AreaTableFile

const char* Navigation::Build::AreaTableFile = "nav:navareas.navareas"
staticconstexpr

the compiled table

◆ AreaTableSource

const char* Navigation::Build::AreaTableSource = "proj:work/data/tables/navareas.json"
staticconstexpr

the table a project edits

◆ BuilderVersion

uint32_t Navigation::Build::BuilderVersion = 1
staticconstexpr

part of every input hash, bump it when the builder output changes for the same input

◆ DefaultWalkableArea

unsigned char Navigation::Build::DefaultWalkableArea = 63
staticconstexpr

the area of walkable surface which no area volume covers, Recast's RC_WALKABLE_AREA

◆ MaxAreas

unsigned char Navigation::Build::MaxAreas = 64
staticconstexpr

◆ MaxStoredHeight

float Navigation::Build::MaxStoredHeight = 32767.0f
staticconstexpr

physics stores height field samples as signed 16 bit, see Physics::CookHeightField

◆ MaxTileBits

int Navigation::Build::MaxTileBits = 14
staticconstexpr

◆ MaxVertsPerPoly

int Navigation::Build::MaxVertsPerPoly = 6
staticconstexpr

◆ MinTileSize

int Navigation::Build::MinTileSize = 8
staticconstexpr

◆ NoArea

unsigned char Navigation::Build::NoArea = 0
staticconstexpr