UNPKG

@esengine/pathfinding

Version:

寻路系统 | Pathfinding System - A*, Grid, NavMesh

985 lines (967 loc) 30.6 kB
import { I as IPathfinder, a as IPathfindingMap, b as IPathfindingOptions, c as IPathResult, H as HeuristicFunction, d as IPathNode, e as IPoint, f as IPathValidator, g as IPathValidationResult, h as IPathSmoother } from './FlowController-BztOzQsW.js'; export { ap as CollisionResolverAdapter, ab as DEFAULT_FLOW_CONTROLLER_CONFIG, p as DEFAULT_HPA_CONFIG, ao as DEFAULT_ORCA_PARAMS, D as DEFAULT_PATHFINDING_OPTIONS, r as DEFAULT_PATH_CACHE_CONFIG, C as DEFAULT_REPLANNING_CONFIG, a9 as EMPTY_COLLISION_RESULT, E as EMPTY_PATH_RESULT, a8 as EMPTY_PLAN_RESULT, F as EMPTY_PROGRESS, ar as FlowController, ag as GridPathfinderAdapter, l as HPAPathfinder, Z as IAvoidanceAgentData, $ as IAvoidanceResult, a2 as ICollisionResolver, a3 as ICongestionZone, N as IDynamicObstacle, a4 as IFlowAgentData, a5 as IFlowControlResult, a7 as IFlowController, a6 as IFlowControllerConfig, au as IGridPathfinderAdapterConfig, t as IHPAConfig, av as IIncrementalGridPathPlannerConfig, W as IIncrementalPathPlanner, X as IIncrementalPathRequest, w as IIncrementalPathResult, x as IIncrementalPathfinder, z as IIncrementalPathfinderConfig, y as IIncrementalPathfindingOptions, a0 as ILocalAvoidance, a1 as INavCollisionResult, Y as INavPathProgress, K as INavPolygon, S as INavVector2, at as IORCAParams, _ as IObstacleData, s as IPathCacheConfig, U as IPathPlanOptions, T as IPathPlanResult, V as IPathPlanner, v as IPathProgress, u as IPathRequest, M as IPortal, A as IReplanningConfig, G as IncrementalAStarPathfinder, ak as IncrementalGridPathPlannerAdapter, L as LineOfSightCheck, Q as NavMesh, ae as NavMeshPathPlannerAdapter, am as ORCALocalAvoidanceAdapter, O as ObstacleType, aa as PassPermission, P as PathCache, ac as PathPlanState, B as PathfindingState, k as chebyshevDistance, ah as createAStarPlanner, aq as createDefaultCollisionResolver, as as createFlowController, n as createHPAPathfinder, aj as createHPAPlanner, J as createIncrementalAStarPathfinder, al as createIncrementalAStarPlanner, ai as createJPSPlanner, R as createNavMesh, af as createNavMeshPathPlanner, an as createORCAAvoidance, q as createPathCache, i as createPoint, j as euclideanDistance, ad as isIncrementalPlanner, m as manhattanDistance, o as octileDistance } from './FlowController-BztOzQsW.js'; export { C as CollisionResolver, j as DEFAULT_AGENT_PARAMS, k as DEFAULT_COLLISION_CONFIG, D as DEFAULT_ORCA_CONFIG, E as EMPTY_COLLISION, a as IAvoidanceAgent, i as ICollisionResolverConfig, h as ICollisionResult, f as INeighborResult, I as IORCALine, d as IORCAResult, e as IORCASolver, c as IORCASolverConfig, b as IObstacle, g as ISpatialIndex, l as createCollisionResolver } from './CollisionResolver-CSgWsegP.js'; export { K as KDTree, O as ORCASolver, a as createKDTree, c as createORCASolver, s as solveORCALinearProgram } from './KDTree-BRpn7O8K.js'; export { IVector2 } from '@esengine/ecs-framework-math'; /** * @zh 二叉堆(优先队列) * @en Binary Heap (Priority Queue) * * @zh 用于 A* 算法的高效开放列表 * @en Efficient open list for A* algorithm */ declare class BinaryHeap<T> { private heap; private readonly compare; /** * @zh 创建二叉堆 * @en Create binary heap * * @param compare - @zh 比较函数,返回负数表示 a < b @en Compare function, returns negative if a < b */ constructor(compare: (a: T, b: T) => number); /** * @zh 堆大小 * @en Heap size */ get size(): number; /** * @zh 是否为空 * @en Is empty */ get isEmpty(): boolean; /** * @zh 插入元素 * @en Push element */ push(item: T): void; /** * @zh 弹出最小元素 * @en Pop minimum element */ pop(): T | undefined; /** * @zh 查看最小元素(不移除) * @en Peek minimum element (without removing) */ peek(): T | undefined; /** * @zh 更新元素(重新排序) * @en Update element (re-sort) */ update(item: T): void; /** * @zh 检查是否包含元素 * @en Check if contains element */ contains(item: T): boolean; /** * @zh 清空堆 * @en Clear heap */ clear(): void; /** * @zh 上浮操作 * @en Bubble up operation */ private bubbleUp; /** * @zh 下沉操作 * @en Sink down operation */ private sinkDown; } /** * @zh 带索引追踪的二叉堆(优先队列) * @en Indexed Binary Heap (Priority Queue) with index tracking */ /** * @zh 可索引的堆元素接口 * @en Interface for indexable heap elements */ interface IHeapIndexable { /** @zh 堆中的索引位置 @en Index position in heap */ heapIndex: number; } /** * @zh 带索引追踪的二叉堆 * @en Binary Heap with index tracking */ declare class IndexedBinaryHeap<T extends IHeapIndexable> { private heap; private readonly compare; /** * @zh 创建带索引追踪的二叉堆 * @en Create indexed binary heap * * @param compare - @zh 比较函数,返回负数表示 a < b @en Compare function, returns negative if a < b */ constructor(compare: (a: T, b: T) => number); /** * @zh 堆大小 * @en Heap size */ get size(): number; /** * @zh 是否为空 * @en Is empty */ get isEmpty(): boolean; /** * @zh 插入元素 * @en Push element */ push(item: T): void; /** * @zh 弹出最小元素 * @en Pop minimum element */ pop(): T | undefined; /** * @zh 查看最小元素(不移除) * @en Peek minimum element (without removing) */ peek(): T | undefined; /** * @zh 更新元素 * @en Update element */ update(item: T): void; /** * @zh 检查是否包含元素 * @en Check if contains element */ contains(item: T): boolean; /** * @zh 从堆中移除指定元素 * @en Remove specific element from heap */ remove(item: T): boolean; /** * @zh 清空堆 * @en Clear heap */ clear(): void; /** * @zh 上浮操作 * @en Bubble up operation */ private bubbleUp; /** * @zh 下沉操作 * @en Sink down operation */ private sinkDown; } /** * @zh A* 寻路算法实现 * @en A* Pathfinding Algorithm Implementation */ /** * @zh A* 寻路器 * @en A* Pathfinder * * @zh 使用 A* 算法在地图上查找最短路径 * @en Uses A* algorithm to find shortest path on a map * * @example * ```typescript * const map = new GridMap(width, height); * const pathfinder = new AStarPathfinder(map); * const result = pathfinder.findPath(0, 0, 10, 10); * if (result.found) { * console.log('Path:', result.path); * } * ``` */ declare class AStarPathfinder implements IPathfinder { private readonly map; private nodeCache; private openList; constructor(map: IPathfindingMap); /** * @zh 查找路径 * @en Find path */ findPath(startX: number, startY: number, endX: number, endY: number, options?: IPathfindingOptions): IPathResult; /** * @zh 清理状态 * @en Clear state */ clear(): void; /** * @zh 获取或创建 A* 节点 * @en Get or create A* node */ private getOrCreateAStarNode; /** * @zh 构建路径结果 * @en Build path result */ private buildPath; } /** * @zh 创建 A* 寻路器 * @en Create A* pathfinder */ declare function createAStarPathfinder(map: IPathfindingMap): AStarPathfinder; /** * @zh 网格地图实现 * @en Grid Map Implementation */ /** * @zh 网格节点 * @en Grid node */ declare class GridNode implements IPathNode { readonly id: number; readonly position: IPoint; readonly x: number; readonly y: number; cost: number; walkable: boolean; constructor(x: number, y: number, width: number, walkable?: boolean, cost?: number); } /** * @zh 4方向偏移 (上下左右) * @en 4-directional offsets (up, down, left, right) */ declare const DIRECTIONS_4: readonly [{ readonly dx: 0; readonly dy: -1; }, { readonly dx: 1; readonly dy: 0; }, { readonly dx: 0; readonly dy: 1; }, { readonly dx: -1; readonly dy: 0; }]; /** * @zh 8方向偏移 (含对角线) * @en 8-directional offsets (including diagonals) */ declare const DIRECTIONS_8: readonly [{ readonly dx: 0; readonly dy: -1; }, { readonly dx: 1; readonly dy: -1; }, { readonly dx: 1; readonly dy: 0; }, { readonly dx: 1; readonly dy: 1; }, { readonly dx: 0; readonly dy: 1; }, { readonly dx: -1; readonly dy: 1; }, { readonly dx: -1; readonly dy: 0; }, { readonly dx: -1; readonly dy: -1; }]; /** * @zh 网格地图配置 * @en Grid map options */ interface IGridMapOptions { /** @zh 是否允许对角移动 @en Allow diagonal movement */ allowDiagonal?: boolean; /** @zh 对角移动代价 @en Diagonal movement cost */ diagonalCost?: number; /** @zh 是否避免穿角 @en Avoid corner cutting */ avoidCorners?: boolean; /** @zh 启发式函数 @en Heuristic function */ heuristic?: HeuristicFunction; } /** * @zh 默认网格地图配置 * @en Default grid map options */ declare const DEFAULT_GRID_OPTIONS: Required<IGridMapOptions>; /** * @zh 网格地图 * @en Grid Map * * @zh 基于二维数组的网格地图实现,支持4方向和8方向移动 * @en Grid map implementation based on 2D array, supports 4 and 8 directional movement * * @example * ```typescript * // Create a 10x10 grid * const grid = new GridMap(10, 10); * * // Set some cells as obstacles * grid.setWalkable(5, 5, false); * grid.setWalkable(5, 6, false); * * // Use with pathfinder * const pathfinder = new AStarPathfinder(grid); * const result = pathfinder.findPath(0, 0, 9, 9); * ``` */ declare class GridMap implements IPathfindingMap { readonly width: number; readonly height: number; private readonly nodes; private readonly options; constructor(width: number, height: number, options?: IGridMapOptions); /** * @zh 创建网格节点 * @en Create grid nodes */ private createNodes; /** * @zh 获取指定位置的节点 * @en Get node at position */ getNodeAt(x: number, y: number): GridNode | null; /** * @zh 检查坐标是否在边界内 * @en Check if coordinates are within bounds */ isInBounds(x: number, y: number): boolean; /** * @zh 检查位置是否可通行 * @en Check if position is walkable */ isWalkable(x: number, y: number): boolean; /** * @zh 设置位置是否可通行 * @en Set position walkability */ setWalkable(x: number, y: number, walkable: boolean): void; /** * @zh 设置位置的移动代价 * @en Set movement cost at position * * @param x - @zh X 坐标 @en X coordinate * @param y - @zh Y 坐标 @en Y coordinate * @param cost - @zh 移动代价,必须为正数 @en Movement cost, must be positive * @throws @zh 如果 cost 不是正数则抛出错误 @en Throws if cost is not positive */ setCost(x: number, y: number, cost: number): void; /** * @zh 获取节点的邻居 * @en Get neighbors of a node */ getNeighbors(node: IPathNode): GridNode[]; /** * @zh 遍历节点的邻居(零分配) * @en Iterate over neighbors (zero allocation) */ forEachNeighbor(node: IPathNode, callback: (neighbor: GridNode) => boolean | void): void; /** * @zh 计算启发式距离 * @en Calculate heuristic distance */ heuristic(a: IPoint, b: IPoint): number; /** * @zh 计算移动代价 * @en Calculate movement cost */ getMovementCost(from: IPathNode, to: IPathNode): number; /** * @zh 从二维数组加载地图 * @en Load map from 2D array * * @param data - @zh 0=可通行,非0=不可通行 @en 0=walkable, non-0=blocked */ loadFromArray(data: number[][]): void; /** * @zh 从字符串加载地图 * @en Load map from string * * @param str - @zh 地图字符串,'.'=可通行,'#'=障碍 @en Map string, '.'=walkable, '#'=blocked */ loadFromString(str: string): void; /** * @zh 导出为字符串 * @en Export to string */ toString(): string; /** * @zh 重置所有节点为可通行 * @en Reset all nodes to walkable */ reset(): void; /** * @zh 设置矩形区域的通行性 * @en Set walkability for a rectangle region */ setRectWalkable(x: number, y: number, width: number, height: number, walkable: boolean): void; } /** * @zh 创建网格地图 * @en Create grid map */ declare function createGridMap(width: number, height: number, options?: IGridMapOptions): GridMap; /** * @zh 网格寻路器(统一实现) * @en Grid Pathfinder (unified implementation) */ /** * @zh 寻路模式 * @en Pathfinding mode */ type GridPathfinderMode = 'standard' | 'fast' | 'bidirectional'; /** * @zh 网格寻路器配置 * @en Grid pathfinder configuration */ interface IGridPathfinderConfig { /** * @zh 寻路模式 * @en Pathfinding mode * * - standard: 标准A*,适合小地图 * - fast: TypedArray优化,适合中大地图 * - bidirectional: 双向搜索,适合超大地图 */ mode?: GridPathfinderMode; } /** * @zh 网格寻路器 * @en Grid Pathfinder */ declare class GridPathfinder implements IPathfinder { private readonly map; private readonly mode; private readonly state; private readonly openList; private readonly openListBack; constructor(map: GridMap, config?: IGridPathfinderConfig); findPath(startX: number, startY: number, endX: number, endY: number, options?: IPathfindingOptions): IPathResult; private findPathUnidirectional; private findPathBidirectional; private validate; private buildPath; private buildPathBidirectional; clear(): void; } /** * @zh 创建网格寻路器 * @en Create grid pathfinder */ declare function createGridPathfinder(map: GridMap, config?: IGridPathfinderConfig): GridPathfinder; /** * @zh 路径验证器 * @en Path Validator */ /** * @zh 路径验证器 * @en Path Validator * * @zh 用于检查现有路径在地图变化后是否仍然有效 * @en Used to check if an existing path is still valid after map changes * * @example * ```typescript * const validator = new PathValidator(); * const result = validator.validatePath(path, 0, path.length, map); * * if (!result.valid) { * console.log('Path invalid at index:', result.invalidIndex); * // Trigger replanning from current position * } * ``` */ declare class PathValidator implements IPathValidator { /** * @zh 验证路径段的有效性 * @en Validate path segment validity * * @param path - @zh 要验证的路径 @en Path to validate * @param fromIndex - @zh 起始索引 @en Start index * @param toIndex - @zh 结束索引 @en End index * @param map - @zh 地图实例 @en Map instance * @returns @zh 验证结果 @en Validation result */ validatePath(path: readonly IPoint[], fromIndex: number, toIndex: number, map: IPathfindingMap): IPathValidationResult; /** * @zh 检查两点之间的视线(使用 Bresenham 算法) * @en Check line of sight between two points (using Bresenham algorithm) * * @param x1 - @zh 起点 X @en Start X * @param y1 - @zh 起点 Y @en Start Y * @param x2 - @zh 终点 X @en End X * @param y2 - @zh 终点 Y @en End Y * @param map - @zh 地图实例 @en Map instance * @returns @zh 是否有视线 @en Whether there is line of sight */ private checkLineOfSight; } /** * @zh 障碍物变化记录 * @en Obstacle change record */ interface IObstacleChange { /** * @zh X 坐标 * @en X coordinate */ readonly x: number; /** * @zh Y 坐标 * @en Y coordinate */ readonly y: number; /** * @zh 变化前是否可通行 * @en Was walkable before change */ readonly wasWalkable: boolean; /** * @zh 变化时间戳 * @en Change timestamp */ readonly timestamp: number; } /** * @zh 障碍物变化区域 * @en Obstacle change region */ interface IChangeRegion { /** * @zh 最小 X 坐标 * @en Minimum X coordinate */ readonly minX: number; /** * @zh 最小 Y 坐标 * @en Minimum Y coordinate */ readonly minY: number; /** * @zh 最大 X 坐标 * @en Maximum X coordinate */ readonly maxX: number; /** * @zh 最大 Y 坐标 * @en Maximum Y coordinate */ readonly maxY: number; } /** * @zh 障碍物变化管理器 * @en Obstacle Change Manager * * @zh 跟踪地图障碍物变化,用于触发动态重规划 * @en Tracks map obstacle changes, used to trigger dynamic replanning * * @example * ```typescript * const manager = new ObstacleChangeManager(); * * // Record change when obstacle is added/removed * manager.recordChange(10, 20, true); // Was walkable, now blocked * * // Get affected region for notification * const region = manager.getAffectedRegion(); * if (region) { * pathfinder.notifyObstacleChange( * region.minX, region.minY, * region.maxX, region.maxY * ); * } * * // Clear after notification * manager.flush(); * ``` */ declare class ObstacleChangeManager { private readonly changes; private epoch; /** * @zh 记录障碍物变化 * @en Record obstacle change * * @param x - @zh X 坐标 @en X coordinate * @param y - @zh Y 坐标 @en Y coordinate * @param wasWalkable - @zh 变化前是否可通行 @en Was walkable before change */ recordChange(x: number, y: number, wasWalkable: boolean): void; /** * @zh 获取影响区域 * @en Get affected region * * @returns @zh 影响区域或 null(如果没有变化)@en Affected region or null if no changes */ getAffectedRegion(): IChangeRegion | null; /** * @zh 获取所有变化 * @en Get all changes * * @returns @zh 变化列表 @en List of changes */ getChanges(): IObstacleChange[]; /** * @zh 检查是否有变化 * @en Check if there are changes * * @returns @zh 是否有变化 @en Whether there are changes */ hasChanges(): boolean; /** * @zh 获取当前 epoch * @en Get current epoch * * @returns @zh 当前 epoch @en Current epoch */ getEpoch(): number; /** * @zh 清空变化记录并推进 epoch * @en Clear changes and advance epoch */ flush(): void; /** * @zh 清空所有状态 * @en Clear all state */ clear(): void; } /** * @zh 创建路径验证器 * @en Create path validator * * @returns @zh 路径验证器实例 @en Path validator instance */ declare function createPathValidator(): PathValidator; /** * @zh 创建障碍物变化管理器 * @en Create obstacle change manager * * @returns @zh 障碍物变化管理器实例 @en Obstacle change manager instance */ declare function createObstacleChangeManager(): ObstacleChangeManager; /** * @zh JPS (Jump Point Search) 寻路算法实现 * @en JPS (Jump Point Search) Pathfinding Algorithm Implementation * * @zh JPS 是 A* 的优化版本,通过跳跃点剪枝大幅提升开放地形的搜索效率 * @en JPS is an optimized version of A* that significantly improves search efficiency on open terrain through jump point pruning */ /** * @zh JPS 寻路器 * @en JPS Pathfinder * * @zh 适用于均匀代价网格地图,在开放地形上比标准 A* 快 10-100 倍 * @en Suitable for uniform cost grid maps, 10-100x faster than standard A* on open terrain * * @example * ```typescript * const map = createGridMap(100, 100); * const pathfinder = new JPSPathfinder(map); * const result = pathfinder.findPath(0, 0, 99, 99); * ``` */ declare class JPSPathfinder implements IPathfinder { private readonly map; private readonly width; private readonly height; private openList; private nodeGrid; constructor(map: IPathfindingMap); /** * @zh 寻找路径 * @en Find path */ findPath(startX: number, startY: number, endX: number, endY: number, options?: Partial<IPathfindingOptions>): IPathResult; /** * @zh 清理状态 * @en Clear state */ clear(): void; /** * @zh 获取地图边界 * @en Get map bounds */ private getMapBounds; /** * @zh 初始化节点网格 * @en Initialize node grid */ private initGrid; /** * @zh 获取或创建节点 * @en Get or create node */ private getOrCreateNode; /** * @zh 启发式函数(八方向距离) * @en Heuristic function (octile distance) */ private heuristic; /** * @zh 识别后继节点(跳跃点) * @en Identify successors (jump points) */ private identifySuccessors; /** * @zh 查找邻居(根据父节点方向剪枝) * @en Find neighbors (pruned based on parent direction) */ private findNeighbors; /** * @zh 跳跃函数(迭代版本,避免递归开销) * @en Jump function (iterative version to avoid recursion overhead) */ private jump; /** * @zh 直线跳跃(水平或垂直方向) * @en Straight jump (horizontal or vertical direction) */ private jumpStraight; /** * @zh 检查位置是否可通行 * @en Check if position is walkable */ private isWalkableAt; /** * @zh 构建路径 * @en Build path */ private buildPath; /** * @zh 插值路径(在跳跃点之间填充中间点) * @en Interpolate path (fill intermediate points between jump points) */ private interpolatePath; } /** * @zh 创建 JPS 寻路器 * @en Create JPS pathfinder * * @param map - @zh 寻路地图实例 @en Pathfinding map instance * @returns @zh JPS 寻路器实例 @en JPS pathfinder instance */ declare function createJPSPathfinder(map: IPathfindingMap): JPSPathfinder; /** * @zh 路径平滑算法 * @en Path Smoothing Algorithms */ /** * @zh 使用 Bresenham 算法检测视线 * @en Line of sight check using Bresenham algorithm */ declare function bresenhamLineOfSight(x1: number, y1: number, x2: number, y2: number, map: IPathfindingMap): boolean; /** * @zh 使用射线投射检测视线(更精确) * @en Line of sight check using ray casting (more precise) */ declare function raycastLineOfSight(x1: number, y1: number, x2: number, y2: number, map: IPathfindingMap, stepSize?: number): boolean; /** * @zh 路径简化器 - 移除不必要的拐点 * @en Path Simplifier - Removes unnecessary waypoints * * @zh 使用视线检测移除可以直接到达的中间点 * @en Uses line of sight to remove intermediate points that can be reached directly */ declare class LineOfSightSmoother implements IPathSmoother { private readonly lineOfSight; constructor(lineOfSight?: typeof bresenhamLineOfSight); smooth(path: readonly IPoint[], map: IPathfindingMap): IPoint[]; } /** * @zh Catmull-Rom 样条曲线平滑 * @en Catmull-Rom spline smoothing */ declare class CatmullRomSmoother implements IPathSmoother { private readonly segments; private readonly tension; /** * @param segments - @zh 每段之间的插值点数 @en Number of interpolation points per segment * @param tension - @zh 张力 (0-1) @en Tension (0-1) */ constructor(segments?: number, tension?: number); smooth(path: readonly IPoint[], _map: IPathfindingMap): IPoint[]; /** * @zh Catmull-Rom 插值 * @en Catmull-Rom interpolation */ private interpolate; } /** * @zh 组合路径平滑器 * @en Combined path smoother * * @zh 先简化路径,再用曲线平滑 * @en First simplify path, then smooth with curves */ declare class CombinedSmoother implements IPathSmoother { private readonly simplifier; private readonly curveSmoother; constructor(curveSegments?: number, tension?: number); smooth(path: readonly IPoint[], map: IPathfindingMap): IPoint[]; } /** * @zh 创建视线平滑器 * @en Create line of sight smoother */ declare function createLineOfSightSmoother(lineOfSight?: typeof bresenhamLineOfSight): LineOfSightSmoother; /** * @zh 创建曲线平滑器 * @en Create curve smoother */ declare function createCatmullRomSmoother(segments?: number, tension?: number): CatmullRomSmoother; /** * @zh 创建组合平滑器 * @en Create combined smoother */ declare function createCombinedSmoother(curveSegments?: number, tension?: number): CombinedSmoother; /** * @zh 半径感知路径平滑器 * @en Radius-Aware Path Smoother * * @zh 通用的路径后处理器,确保路径与障碍物保持安全距离 * @en Generic path post-processor that ensures paths maintain safe distance from obstacles */ /** * @zh 半径感知平滑器配置 * @en Radius-aware smoother configuration */ interface IRadiusAwareSmootherConfig { /** * @zh 代理半径 * @en Agent radius */ agentRadius: number; /** * @zh 额外安全边距 * @en Extra safety margin * @default 0.1 */ safetyMargin?: number; /** * @zh 采样方向数量(用于检测周围障碍物) * @en Number of sample directions (for detecting nearby obstacles) * @default 8 */ sampleDirections?: number; /** * @zh 最大偏移尝试次数 * @en Maximum offset attempts * @default 8 */ maxOffsetAttempts?: number; /** * @zh 是否处理拐点(角落) * @en Whether to process turning points (corners) * @default true */ processCorners?: boolean; } /** * @zh 半径感知路径平滑器 * @en Radius-Aware Path Smoother * * @zh 对任意寻路算法输出的路径进行后处理,确保路径点与障碍物保持足够距离 * @en Post-processes paths from any pathfinding algorithm to ensure path points maintain sufficient distance from obstacles * * @example * ```typescript * // 创建平滑器 * const smoother = new RadiusAwarePathSmoother({ agentRadius: 0.5 }); * * // 处理路径 * const safePath = smoother.smooth(rawPath, map); * * // 与其他平滑器组合使用 * const combined = new CombinedRadiusAwareSmoother( * new LineOfSightSmoother(), * { agentRadius: 0.5 } * ); * ``` */ declare class RadiusAwarePathSmoother implements IPathSmoother { private readonly config; private readonly sampleAngles; constructor(config: IRadiusAwareSmootherConfig); /** * @zh 平滑路径,确保与障碍物保持安全距离 * @en Smooth path, ensuring safe distance from obstacles * * @param path - @zh 原始路径 @en Original path * @param map - @zh 地图 @en Map * @returns @zh 处理后的安全路径 @en Processed safe path */ smooth(path: readonly IPoint[], map: IPathfindingMap): IPoint[]; /** * @zh 将点从障碍物偏移 * @en Offset point away from obstacles */ private offsetPointFromObstacles; /** * @zh 偏移拐点(角落) * @en Offset corner point */ private offsetCornerPoint; /** * @zh 检测附近的障碍物方向 * @en Detect nearby obstacle directions */ private detectNearbyObstacles; } /** * @zh 组合半径感知平滑器 * @en Combined radius-aware smoother * * @zh 先使用其他平滑器(如 LOS、Catmull-Rom),再应用半径感知处理 * @en First applies other smoother (like LOS, Catmull-Rom), then applies radius-aware processing * * @example * ```typescript * const smoother = new CombinedRadiusAwareSmoother( * new LineOfSightSmoother(), * { agentRadius: 0.5 } * ); * const path = smoother.smooth(rawPath, map); * ``` */ declare class CombinedRadiusAwareSmoother implements IPathSmoother { private readonly baseSmoother; private readonly radiusAwareSmoother; constructor(baseSmoother: IPathSmoother, config: IRadiusAwareSmootherConfig); smooth(path: readonly IPoint[], map: IPathfindingMap): IPoint[]; } /** * @zh 创建半径感知平滑器 * @en Create radius-aware smoother * * @param agentRadius - @zh 代理半径 @en Agent radius * @param options - @zh 额外配置 @en Additional options * * @example * ```typescript * const smoother = createRadiusAwareSmoother(0.5); * const safePath = smoother.smooth(path, map); * ``` */ declare function createRadiusAwareSmoother(agentRadius: number, options?: Omit<IRadiusAwareSmootherConfig, 'agentRadius'>): RadiusAwarePathSmoother; /** * @zh 创建组合半径感知平滑器 * @en Create combined radius-aware smoother * * @param baseSmoother - @zh 基础平滑器 @en Base smoother * @param agentRadius - @zh 代理半径 @en Agent radius * @param options - @zh 额外配置 @en Additional options * * @example * ```typescript * const smoother = createCombinedRadiusAwareSmoother( * new LineOfSightSmoother(), * 0.5 * ); * ``` */ declare function createCombinedRadiusAwareSmoother(baseSmoother: IPathSmoother, agentRadius: number, options?: Omit<IRadiusAwareSmootherConfig, 'agentRadius'>): CombinedRadiusAwareSmoother; export { AStarPathfinder, BinaryHeap, CatmullRomSmoother, CombinedRadiusAwareSmoother, CombinedSmoother, DEFAULT_GRID_OPTIONS, DIRECTIONS_4, DIRECTIONS_8, GridMap, GridNode, GridPathfinder, type GridPathfinderMode, HeuristicFunction, type IChangeRegion, type IGridMapOptions, type IGridPathfinderConfig, type IHeapIndexable, type IObstacleChange, IPathNode, IPathResult, IPathSmoother, IPathValidationResult, IPathValidator, IPathfinder, IPathfindingMap, IPathfindingOptions, IPoint, type IRadiusAwareSmootherConfig, IndexedBinaryHeap, JPSPathfinder, LineOfSightSmoother, ObstacleChangeManager, PathValidator, RadiusAwarePathSmoother, bresenhamLineOfSight, createAStarPathfinder, createCatmullRomSmoother, createCombinedRadiusAwareSmoother, createCombinedSmoother, createGridMap, createGridPathfinder, createJPSPathfinder, createLineOfSightSmoother, createObstacleChangeManager, createPathValidator, createRadiusAwareSmoother, raycastLineOfSight };