@esengine/pathfinding 13.1.0 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +125 -25
- package/dist/index.js +871 -313
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1080,13 +1080,15 @@ declare function createJPSPathfinder(map: IPathfindingMap): JPSPathfinder;
|
|
|
1080
1080
|
* 1. 将地图划分为集群 (clusters)
|
|
1081
1081
|
* 2. 在集群边界检测入口点 (entrances)
|
|
1082
1082
|
* 3. 构建抽象图 (abstract graph) 连接入口点
|
|
1083
|
-
* 4.
|
|
1083
|
+
* 4. 预计算集群内入口点之间的真实路径代价
|
|
1084
|
+
* 5. 先在抽象图上寻路,再利用缓存细化为详细路径
|
|
1084
1085
|
*
|
|
1085
1086
|
* @en How it works:
|
|
1086
1087
|
* 1. Divide map into clusters
|
|
1087
1088
|
* 2. Detect entrances at cluster boundaries
|
|
1088
1089
|
* 3. Build abstract graph connecting entrances
|
|
1089
|
-
* 4.
|
|
1090
|
+
* 4. Precompute actual path costs between entrances within clusters
|
|
1091
|
+
* 5. First find path on abstract graph, then refine using cached paths
|
|
1090
1092
|
*/
|
|
1091
1093
|
|
|
1092
1094
|
/**
|
|
@@ -1100,8 +1102,8 @@ interface IHPAConfig {
|
|
|
1100
1102
|
*/
|
|
1101
1103
|
clusterSize: number;
|
|
1102
1104
|
/**
|
|
1103
|
-
* @zh
|
|
1104
|
-
* @en Maximum entrance width (entrances wider than this will be split)
|
|
1105
|
+
* @zh 最大入口宽度(超过此宽度会拆分或使用端点策略)
|
|
1106
|
+
* @en Maximum entrance width (entrances wider than this will be split or use endpoint strategy)
|
|
1105
1107
|
*/
|
|
1106
1108
|
maxEntranceWidth: number;
|
|
1107
1109
|
/**
|
|
@@ -1109,6 +1111,16 @@ interface IHPAConfig {
|
|
|
1109
1111
|
* @en Whether to enable internal path caching
|
|
1110
1112
|
*/
|
|
1111
1113
|
cacheInternalPaths: boolean;
|
|
1114
|
+
/**
|
|
1115
|
+
* @zh 入口策略:'middle' 在中间放节点,'end' 在宽入口两端各放节点
|
|
1116
|
+
* @en Entrance strategy: 'middle' places node at center, 'end' places nodes at both ends for wide entrances
|
|
1117
|
+
*/
|
|
1118
|
+
entranceStrategy?: 'middle' | 'end';
|
|
1119
|
+
/**
|
|
1120
|
+
* @zh 是否延迟计算 intra-edges(大幅加速预处理,首次查询时计算真实路径)
|
|
1121
|
+
* @en Whether to lazily compute intra-edges (greatly speeds up preprocessing, computes actual paths on first query)
|
|
1122
|
+
*/
|
|
1123
|
+
lazyIntraEdges?: boolean;
|
|
1112
1124
|
}
|
|
1113
1125
|
/**
|
|
1114
1126
|
* @zh 默认 HPA* 配置
|
|
@@ -1137,24 +1149,24 @@ declare const DEFAULT_HPA_CONFIG: IHPAConfig;
|
|
|
1137
1149
|
declare class HPAPathfinder implements IPathfinder {
|
|
1138
1150
|
private readonly map;
|
|
1139
1151
|
private readonly config;
|
|
1140
|
-
private readonly
|
|
1141
|
-
private readonly
|
|
1152
|
+
private readonly mapWidth;
|
|
1153
|
+
private readonly mapHeight;
|
|
1142
1154
|
private clusters;
|
|
1143
|
-
private entrances;
|
|
1144
|
-
private abstractNodes;
|
|
1145
1155
|
private clusterGrid;
|
|
1146
|
-
private
|
|
1156
|
+
private clustersX;
|
|
1157
|
+
private clustersY;
|
|
1158
|
+
private abstractNodes;
|
|
1159
|
+
private nodesByCluster;
|
|
1147
1160
|
private nextNodeId;
|
|
1148
|
-
private
|
|
1149
|
-
private localPathfinder;
|
|
1161
|
+
private entranceCount;
|
|
1162
|
+
private readonly localPathfinder;
|
|
1163
|
+
private readonly pathCache;
|
|
1164
|
+
private mapVersion;
|
|
1150
1165
|
private preprocessed;
|
|
1151
1166
|
constructor(map: IPathfindingMap, config?: Partial<IHPAConfig>);
|
|
1152
1167
|
/**
|
|
1153
1168
|
* @zh 预处理地图(构建抽象图)
|
|
1154
1169
|
* @en Preprocess map (build abstract graph)
|
|
1155
|
-
*
|
|
1156
|
-
* @zh 在地图变化后需要重新调用
|
|
1157
|
-
* @en Need to call again after map changes
|
|
1158
1170
|
*/
|
|
1159
1171
|
preprocess(): void;
|
|
1160
1172
|
/**
|
|
@@ -1183,22 +1195,110 @@ declare class HPAPathfinder implements IPathfinder {
|
|
|
1183
1195
|
cacheSize: number;
|
|
1184
1196
|
};
|
|
1185
1197
|
private getMapBounds;
|
|
1198
|
+
/**
|
|
1199
|
+
* @zh 构建集群
|
|
1200
|
+
* @en Build clusters
|
|
1201
|
+
*/
|
|
1186
1202
|
private buildClusters;
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1203
|
+
/**
|
|
1204
|
+
* @zh 检测入口并创建抽象节点
|
|
1205
|
+
* @en Detect entrances and create abstract nodes
|
|
1206
|
+
*/
|
|
1207
|
+
private buildEntrances;
|
|
1208
|
+
/**
|
|
1209
|
+
* @zh 检测并创建两个相邻集群之间的入口
|
|
1210
|
+
* @en Detect and create entrances between two adjacent clusters
|
|
1211
|
+
*/
|
|
1212
|
+
private detectAndCreateEntrances;
|
|
1213
|
+
/**
|
|
1214
|
+
* @zh 检测边界上的连续可通行区间
|
|
1215
|
+
* @en Detect continuous walkable spans on boundary
|
|
1216
|
+
*/
|
|
1217
|
+
private detectEntranceSpans;
|
|
1218
|
+
/**
|
|
1219
|
+
* @zh 为入口区间创建抽象节点
|
|
1220
|
+
* @en Create abstract nodes for entrance span
|
|
1221
|
+
*/
|
|
1222
|
+
private createEntranceNodes;
|
|
1223
|
+
/**
|
|
1224
|
+
* @zh 创建抽象节点
|
|
1225
|
+
* @en Create abstract node
|
|
1226
|
+
*/
|
|
1191
1227
|
private createAbstractNode;
|
|
1192
|
-
|
|
1228
|
+
/**
|
|
1229
|
+
* @zh 构建所有集群的 intra-edges
|
|
1230
|
+
* @en Build intra-edges for all clusters
|
|
1231
|
+
*/
|
|
1232
|
+
private buildIntraEdges;
|
|
1233
|
+
/**
|
|
1234
|
+
* @zh 构建单个集群的 intra-edges
|
|
1235
|
+
* @en Build intra-edges for single cluster
|
|
1236
|
+
*/
|
|
1237
|
+
private buildClusterIntraEdges;
|
|
1238
|
+
/**
|
|
1239
|
+
* @zh 延迟构建 intra-edges(只用启发式距离)
|
|
1240
|
+
* @en Build lazy intra-edges (using heuristic distance only)
|
|
1241
|
+
*/
|
|
1242
|
+
private buildLazyIntraEdges;
|
|
1243
|
+
/**
|
|
1244
|
+
* @zh 立即构建 intra-edges(计算真实路径)
|
|
1245
|
+
* @en Build eager intra-edges (compute actual paths)
|
|
1246
|
+
*/
|
|
1247
|
+
private buildEagerIntraEdges;
|
|
1248
|
+
/**
|
|
1249
|
+
* @zh 按需计算 intra-edge 的真实路径
|
|
1250
|
+
* @en Compute actual path for intra-edge on demand
|
|
1251
|
+
*/
|
|
1252
|
+
private computeIntraEdgePath;
|
|
1253
|
+
/**
|
|
1254
|
+
* @zh 获取指定位置的集群
|
|
1255
|
+
* @en Get cluster at position
|
|
1256
|
+
*/
|
|
1193
1257
|
private getClusterAt;
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1258
|
+
/**
|
|
1259
|
+
* @zh 获取受影响的集群
|
|
1260
|
+
* @en Get affected clusters
|
|
1261
|
+
*/
|
|
1262
|
+
private getAffectedClusters;
|
|
1263
|
+
/**
|
|
1264
|
+
* @zh 插入临时节点
|
|
1265
|
+
* @en Insert temporary node
|
|
1266
|
+
*/
|
|
1267
|
+
private insertTempNode;
|
|
1268
|
+
/**
|
|
1269
|
+
* @zh 移除临时节点
|
|
1270
|
+
* @en Remove temporary node
|
|
1271
|
+
*/
|
|
1272
|
+
private removeTempNode;
|
|
1273
|
+
/**
|
|
1274
|
+
* @zh 在抽象图上进行 A* 搜索
|
|
1275
|
+
* @en Perform A* search on abstract graph
|
|
1276
|
+
*/
|
|
1277
|
+
private abstractSearch;
|
|
1278
|
+
/**
|
|
1279
|
+
* @zh 重建抽象路径
|
|
1280
|
+
* @en Reconstruct abstract path
|
|
1281
|
+
*/
|
|
1282
|
+
private reconstructPath;
|
|
1283
|
+
/**
|
|
1284
|
+
* @zh 细化抽象路径为具体路径
|
|
1285
|
+
* @en Refine abstract path to concrete path
|
|
1286
|
+
*/
|
|
1198
1287
|
private refinePath;
|
|
1288
|
+
/**
|
|
1289
|
+
* @zh 追加路径(避免重复点)
|
|
1290
|
+
* @en Append path (avoid duplicate points)
|
|
1291
|
+
*/
|
|
1292
|
+
private appendPath;
|
|
1293
|
+
/**
|
|
1294
|
+
* @zh 局部寻路
|
|
1295
|
+
* @en Local pathfinding
|
|
1296
|
+
*/
|
|
1199
1297
|
private findLocalPath;
|
|
1200
|
-
|
|
1201
|
-
|
|
1298
|
+
/**
|
|
1299
|
+
* @zh 启发式函数(Octile 距离)
|
|
1300
|
+
* @en Heuristic function (Octile distance)
|
|
1301
|
+
*/
|
|
1202
1302
|
private heuristic;
|
|
1203
1303
|
}
|
|
1204
1304
|
/**
|