mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 04:51:49 +00:00
add pathfinding
This commit is contained in:
parent
88721344c1
commit
9bb50db297
4 changed files with 171 additions and 1 deletions
48
src/voxels/Pathfinding.hpp
Normal file
48
src/voxels/Pathfinding.hpp
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
class Level;
|
||||
|
||||
namespace voxels {
|
||||
struct RouteNode {
|
||||
glm::ivec3 pos;
|
||||
};
|
||||
|
||||
struct Route {
|
||||
bool found;
|
||||
std::vector<RouteNode> nodes;
|
||||
};
|
||||
|
||||
struct Map {
|
||||
int width;
|
||||
int height;
|
||||
std::unique_ptr<uint8_t[]> map;
|
||||
|
||||
Map(int width, int height)
|
||||
: width(width),
|
||||
height(height),
|
||||
map(std::make_unique<uint8_t[]>(width * height)) {
|
||||
}
|
||||
|
||||
uint8_t& operator[](int i) {
|
||||
return map[i];
|
||||
}
|
||||
|
||||
const uint8_t& operator[](int i) const {
|
||||
return map[i];
|
||||
}
|
||||
};
|
||||
|
||||
class Pathfinding {
|
||||
public:
|
||||
Pathfinding(const Level& level);
|
||||
|
||||
Route perform(const glm::ivec3& start, const glm::ivec3& end);
|
||||
private:
|
||||
const Level& level;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue