载入中...
搜索中...
未找到
FlowField.h
浏览该文件的文档.
1#pragma once
2
3#include <limits>
4#include <vector>
5
6namespace eve::map {
7
13class FlowField {
14public:
15 static constexpr float kUnreachable = std::numeric_limits<float>::infinity();
16
17 void clear();
18 void resize(int width, int height);
19 int getWidth() const { return width_; }
20 int getHeight() const { return height_; }
21
22 int getGoalX() const { return goalX_; }
23 int getGoalY() const { return goalY_; }
24 void setGoal(int x, int y);
25
26 float costAt(int x, int y) const;
27 void setCost(int x, int y, float cost);
28
29 int nextX(int x, int y) const;
30 int nextY(int x, int y) const;
31 void setNext(int x, int y, int nx, int ny);
32
33 bool isReachable(int x, int y) const;
34
35private:
36 bool inBounds(int x, int y) const;
37 int index(int x, int y) const { return y * width_ + x; }
38
39 int width_ = 0;
40 int height_ = 0;
41 int goalX_ = 0;
42 int goalY_ = 0;
43 std::vector<float> cost_;
44 std::vector<int> nextX_;
45 std::vector<int> nextY_;
46};
47
48} // namespace eve::map
int y
Definition Grass.cpp:135
float height
Definition Grass.cpp:235
int x
Definition Grass.cpp:135
int width
std::vector< float > cost
Integration + direction field for group pathfinding to a single goal. nextX/nextY point to the neighb...
Definition FlowField.h:13
bool isReachable(int x, int y) const
int getGoalX() const
Definition FlowField.h:22
void resize(int width, int height)
void setGoal(int x, int y)
float costAt(int x, int y) const
void setNext(int x, int y, int nx, int ny)
int getWidth() const
Definition FlowField.h:19
int getGoalY() const
Definition FlowField.h:23
static constexpr float kUnreachable
Definition FlowField.h:15
int nextY(int x, int y) const
int nextX(int x, int y) const
void setCost(int x, int y, float cost)
int getHeight() const
Definition FlowField.h:20
放置世界:格子占用(多通道)+ 地形语义 + 已放置建筑实例。 行为由 PlacementSystem 提供;本类暴露便于脚本绑定的薄封装方法。 坐标换算统一走 eve::grid(支持 rectang...