|
| | CrowdField ()=default |
| | Crowd field.
|
| |
| void | resize (int width, int height, float cellSize, float originX, float originY) |
| | 配置网格(保留原有 cost/goals,若尺寸变化则重置)。
|
| |
| void | clear () |
| | 清空全部数据(回到无效状态)。
|
| |
| bool | valid () const |
| | 是否配置了有效网格。
|
| |
| int | getWidth () const |
| | 网格尺寸访问器。
|
| |
| int | getHeight () const |
| | Returns the height.
|
| |
| float | getCellSize () const |
| | Returns the cell size.
|
| |
| float | getOriginX () const |
| | Returns the origin x.
|
| |
| float | getOriginY () const |
| | Returns the origin y.
|
| |
| void | setBlocked (int cx, int cy, bool blocked) |
| | 设置/清除某格阻挡。
|
| |
| bool | isBlocked (int cx, int cy) const |
| | 查询某格是否阻挡。
|
| |
| void | setCellCost (int cx, int cy, float cost) |
| | 设置某格地形代价(进入该格的移动成本)。
|
| |
| float | getCellCost (int cx, int cy) const |
| | 查询地形代价(越界/阻挡返回 0)。
|
| |
| void | setAllCellCost (float cost) |
| | 把全部格子设为同一地形代价(通常 build 前重置用)。
|
| |
| void | setGoal (int gx, int gy) |
| | 设定唯一目标格(等价 clearGoals + addGoal)。
|
| |
| void | addGoal (int gx, int gy) |
| | Append a unique goal cell; existing goals leave revision unchanged.
|
| |
| void | clearGoals () |
| | 清空目标列表。
|
| |
| int | goalCount () const |
| | 目标个数。
|
| |
| bool | isBuilt () const |
| | Whether directions were built for the current terrain and goals.
|
| |
| std::uint64_t | revision () const noexcept |
| | Read owner-local terrain/goal revision; snapshots preserve it.
|
| |
| std::uint64_t | inputRevision () const noexcept |
| | Navigation geometry/cost/rule epoch; goal edits and field publications do not change it.
|
| |
| std::uint64_t | builtRevision () const noexcept |
| | Read revision consumed by the last completed build.
|
| |
| FieldState | state () const noexcept |
| | Distinguish absent, unbuilt, current and stale navigation.
|
| |
| void | build () |
| | Legacy synchronous build; publish the completed staged Dijkstra result atomically. @thread Owner thread only. @reentrancy No callbacks. @cost Copies field storage then performs global Dijkstra; amortize at explicit navigation rebuild boundaries.
|
| |
| float | costAtCell (int cx, int cy) const |
| | 查询格级积分代价(未 build 返回 kUnreachable)。
|
| |
| bool | isReachable (int cx, int cy) const |
| | 某格是否可达(积分代价有限且非负)。
|
| |
| void | flowAtCell (int cx, int cy, float &dx, float &dy) const |
| | 查询格级方向向量(单位长度;目标格/阻挡/不可达为 0)。
|
| |
| float | costAtWorld (float wx, float wy) const |
| | 查询世界坐标处的积分代价(双线性插值;场外返回 kUnreachable)。
|
| |
| void | flowAtWorld (float wx, float wy, float &dx, float &dy) const |
| | 查询世界坐标处的跟随方向(双线性插值后归一化)。
|
| |
| bool | resolvePenetration (float &wx, float &wy, float radius) const |
| | 圆 vs 阻挡格碰撞消解:把圆心从覆盖到的阻挡格中推出来。
|
| |
| const std::vector< float > & | integration () const |
| | 只读访问积分场(调试渲染用)。
|
| |
| const std::vector< float > & | flowX () const |
| | 只读访问方向场 X 分量(调试渲染用)。
|
| |
| const std::vector< float > & | flowY () const |
| | 只读访问方向场 Y 分量(调试渲染用)。
|
| |
连续流场(flow field)。
build() 从所有目标格做一次 8 邻域 Dijkstra,得到到目标的积分代价 (integration cost);随后由中心差分求梯度,生成每格的单位方向向量 (沿代价下降方向)。flowAtWorld() 用双线性插值给出任意世界坐标的方向, 供单位逐帧采样跟随。
在文件 CrowdField.h 第 25 行定义.
| void eve::crowd::CrowdField::flowAtWorld |
( |
float |
wx, |
|
|
float |
wy, |
|
|
float & |
dx, |
|
|
float & |
dy |
|
) |
| const |
查询世界坐标处的跟随方向(双线性插值后归一化)。
- 参数
-
| wx | 世界 X |
| wy | 世界 Y |
| [out] | dx | 方向 X(场外/全不可达为 0) |
| [out] | dy | 方向 Y |
在文件 CrowdField.cpp 第 335 行定义.
引用了 dx, dy, index, isBuilt(), sx, sy, valid(), wx, wy, x , 以及 y.
| void eve::crowd::CrowdField::resize |
( |
int |
width, |
|
|
int |
height, |
|
|
float |
cellSize, |
|
|
float |
originX, |
|
|
float |
originY |
|
) |
| |
配置网格(保留原有 cost/goals,若尺寸变化则重置)。
- 参数
-
| width | 列数(>0) |
| height | 行数(>0) |
| cellSize | 每格世界尺寸(>0) |
| originX | 世界原点 X(格 (0,0) 左下角) |
| originY | 世界原点 Y |
Identical geometry is a no-op. All buffer allocations precede geometry/revision publication. @thread Owner thread only. @reentrancy No callbacks. @cost Allocates grid-sized derived storage; amortize at explicit surface configuration boundaries.
- 异常
-
| std::invalid_argument | Nonfinite geometry is rejected without changing the field. |
| std::length_error | Grid dimensions exceed signed index range. |
| std::bad_alloc | Buffer preparation fails without changing the field. |
在文件 CrowdField.cpp 第 33 行定义.
引用了 count, flowX(), flowY(), height, integration(), kUnreachable, size , 以及 width.
| bool eve::crowd::CrowdField::resolvePenetration |
( |
float & |
wx, |
|
|
float & |
wy, |
|
|
float |
radius |
|
) |
| const |
圆 vs 阻挡格碰撞消解:把圆心从覆盖到的阻挡格中推出来。
按单位半径展开 AABB,检查覆盖到的格;对每个阻挡格沿穿透最小的轴推出, 使单位圆不再与任何阻挡格重叠。墙角处可能需迭代 2 次。
- 参数
-
| [in,out] | wx | 圆心世界 X |
| [in,out] | wy | 圆心世界 Y |
| radius | 单位半径 |
- 返回
- 是否发生了推挤
在文件 CrowdField.cpp 第 373 行定义.
引用了 cx, cy, distance, dx, dy, isBlocked(), left, radius, right, scale, up, valid(), wx , 以及 wy.
被这些函数引用 eve::crowd::Crowd::Impl::selectAvoidanceVelocity().