import { type Box3, type Vec3 } from 'mathcat'; import { type BuildContextState } from './build-context.js'; import type { Heightfield } from './heightfield.js'; export type CompactHeightfieldSpan = { /** the lower extent of the span. measured from the heightfields base. */ y: number; /** the id of the region the span belongs to, or zero if not in a region */ region: number; /** packed neighbour connection data */ con: number; /** the height of the span, measured from y */ h: number; }; export type CompactHeightfieldCell = { /** index to the first span in the column */ index: number; /** number of spans in the column */ count: number; }; export type CompactHeightfield = { /** the width of the heightfield (along x axis in cell units) */ width: number; /** the height of the heightfield (along z axis in cell units) */ height: number; /** the number of spans in the heightfield */ spanCount: number; /** the walkable height used during the build of the heightfield */ walkableHeightVoxels: number; /** the walkable climb used during the build of the heightfield */ walkableClimbVoxels: number; /** the AABB border size used during the build of the heightfield */ borderSize: number; /** the maxiumum distance value of any span within the heightfield */ maxDistance: number; /** the maximum region id of any span within the heightfield */ maxRegions: number; /** the heightfield bounds in world space */ bounds: Box3; /** the size of each cell */ cellSize: number; /** the height of each cell */ cellHeight: number; /** array of cells, size = width*height */ cells: CompactHeightfieldCell[]; /** array of spans, size = spanCount */ spans: CompactHeightfieldSpan[]; /** array containing area id data, size = spanCount */ areas: number[]; /** array containing distance field data, size = spanCount */ distances: number[]; }; /** * Helper function to set connection data in a span */ export declare const setCon: (span: CompactHeightfieldSpan, dir: number, layerIndex: number) => void; /** * Helper function to get connection data from a span */ export declare const getCon: (span: CompactHeightfieldSpan, dir: number) => number; export declare const buildCompactHeightfield: (ctx: BuildContextState, walkableHeightVoxels: number, walkableClimbVoxels: number, heightfield: Heightfield) => CompactHeightfield; export declare const erodeWalkableArea: (walkableRadiusVoxels: number, compactHeightfield: CompactHeightfield) => void; /** * Erodes the walkable area for a base agent radius and marks restricted areas for larger agents based on given walkable radius thresholds. * * Note that this function requires careful tuning of the build parameters to get a good result: * - The cellSize needs to be small enough to accurately represent narrow passages. Generally you need to use smaller cellSizes than you otherwise would for single agent navmesh builds. * - The thresholds should not be so small that the resulting regions are too small to successfully build good navmesh polygons for. Values like 1-2 voxels will likely lead to poor results. * - You may get a better result using "buildRegionsMonotone" over "buildRegions" as this will better handle the many small clusters of areas that may be created from smaller thresholds. * * A typical workflow for using this utility to implement multi-agent support: * 1. Call erodeAndMarkWalkableAreas with your smallest agent radius and list of restricted areas * 2. Continue with buildDistanceField, buildRegionsMonotone, etc. * 3. Configure query filters so large agents exclude the narrow/restricted area IDs * * @param baseWalkableRadiusVoxels the smallest agent radius in voxels (used for erosion) * @param thresholds array of area ids and their corresponding walkable radius in voxels. * @param compactHeightfield the compact heightfield to process */ export declare const erodeAndMarkWalkableAreas: (baseWalkableRadiusVoxels: number, thresholds: Array<{ areaId: number; walkableRadiusVoxels: number; }>, compactHeightfield: CompactHeightfield) => void; /** * Marks spans in the heightfield that intersect the specified box area with the given area ID. */ export declare const markBoxArea: (bounds: Box3, areaId: number, compactHeightfield: CompactHeightfield) => void; /** * Marks spans in the heightfield that intersect the specified rotated box area with the given area ID. * @param center - The center point of the box in world space [x, y, z] * @param halfExtents - Half extents of the box along each axis [x, y, z] * @param angleRadians - Rotation angle in radians around the Y axis * @param areaId - The area ID to assign to intersecting spans * @param compactHeightfield - The compact heightfield to mark */ export declare const markRotatedBoxArea: (center: Vec3, halfExtents: Vec3, angleRadians: number, areaId: number, compactHeightfield: CompactHeightfield) => void; /** * Marks spans in the heightfield that intersect the specified convex polygon area with the given area ID. */ export declare const markConvexPolyArea: (verts: number[], minY: number, maxY: number, areaId: number, compactHeightfield: CompactHeightfield) => void; /** * Marks spans in the heightfield that intersect the specified cylinder area with the given area ID. */ export declare const markCylinderArea: (position: Vec3, radius: number, height: number, areaId: number, compactHeightfield: CompactHeightfield) => void; /** * Applies a median filter to walkable area types (based on area id), removing noise. * filter is usually applied after applying area id's using functions * such as #markBoxArea, #markConvexPolyArea, and #markCylinderArea. */ export declare const medianFilterWalkableArea: (compactHeightfield: CompactHeightfield) => boolean;