gedeng/include/Gedeng/NavMesh.h
karl 90d8b0479d Add basic pathfinding API
This should cover all requirements from the assignment, but a more specific use case will be added later.
2021-03-31 14:49:25 +02:00

28 lines
951 B
C++

#pragma once
#include "Node.h"
#include "Path.h"
namespace Gedeng {
class NavMesh {
// Build the NavMesh from all collider geometry in the given node and all
// its children.
void create_from_nodes(const Node &root);
// Return true if the NavMesh has succesfully been created from nodes (by a
// former `create_from_nodes` call) and its geometry is valid.
bool is_valid() const;
// Return a valid path from a given Vector3 to a given Vector3.
// If no valid path can be constructed, the returned path will be of size 1
// and contain only the `from` vector.
// The returned path may not be optimal -- if that is undesired, call
// `optimize_path` on the result.
Path get_path(const Vector3 &from, const Vector3 &to) const;
// Optimize the given path to traverse the NavMesh as efficiently as
// possible. This can be slow!
void optimize_path(Path &path) const;
};
} // namespace Gedeng