This should cover all requirements from the assignment, but a more specific use case will be added later.
28 lines
951 B
C++
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
|