34 lines
1.4 KiB
C++
34 lines
1.4 KiB
C++
#pragma once
|
|
#include "Node.h"
|
|
#include "Path.h"
|
|
|
|
namespace Gedeng {
|
|
|
|
// A NavMesh can be constructed from the geometry in a node tree in order to be
|
|
// used for pathfinding. A typical scenario would go as follows:
|
|
// 1. Load Nodes using NodeSystem::load_nodes_from_disk
|
|
// 2. Create a NavMesh using NavMesh::create_from_nodes
|
|
// 3. Verify the resulting NavMesh via NavMesh::is_valid
|
|
// 4. Get a path between the desired points via NavMesh::get_path
|
|
// 5. Position an entity along this path via Path::get_interpolated_position
|
|
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 and optimal 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.
|
|
Path get_path(const Vector3 &from, const Vector3 &to) const;
|
|
|
|
// Return any valid path from a given Vector3 to a given Vector3.
|
|
// This is more performant than `get_path`, but the returned path may not be
|
|
// optimal -- if that is undesired, call `get_path` instead.
|
|
Path get_unoptimized_path(const Vector3 &from, const Vector3 &to) const;
|
|
};
|
|
|
|
} // namespace Gedeng
|