refactor: Rename NavMesh to Pathfinding
This commit is contained in:
parent
63576e6317
commit
ef2d119783
6 changed files with 17 additions and 17 deletions
|
@ -74,7 +74,6 @@ set(HEADERS
|
|||
src/game/gui/mainmenu.h
|
||||
src/game/gui/portraitsel.h
|
||||
src/game/gui/target.h
|
||||
src/game/navmesh.h
|
||||
src/game/module.h
|
||||
src/game/multiplayer/area.h
|
||||
src/game/multiplayer/callbacks.h
|
||||
|
@ -93,6 +92,7 @@ set(HEADERS
|
|||
src/game/object/spatial.h
|
||||
src/game/object/trigger.h
|
||||
src/game/object/waypoint.h
|
||||
src/game/pathfinding.h
|
||||
src/game/paths.h
|
||||
src/game/room.h
|
||||
src/game/script/routines.h
|
||||
|
@ -214,7 +214,6 @@ set(SOURCES
|
|||
src/game/multiplayer/game.cpp
|
||||
src/game/multiplayer/objectfactory.cpp
|
||||
src/game/multiplayer/util.cpp
|
||||
src/game/navmesh.cpp
|
||||
src/game/object/creature.cpp
|
||||
src/game/object/door.cpp
|
||||
src/game/object/factory.cpp
|
||||
|
@ -224,6 +223,7 @@ set(SOURCES
|
|||
src/game/object/spatial.cpp
|
||||
src/game/object/trigger.cpp
|
||||
src/game/object/waypoint.cpp
|
||||
src/game/pathfinding.cpp
|
||||
src/game/paths.cpp
|
||||
src/game/room.cpp
|
||||
src/game/script/routines.cpp
|
||||
|
|
|
@ -71,7 +71,7 @@ Area::Area(uint32_t id, GameVersion version, ObjectFactory *objectFactory, Scene
|
|||
_version(version),
|
||||
_objectFactory(objectFactory),
|
||||
_sceneGraph(sceneGraph),
|
||||
_navMesh(new NavMesh()) {
|
||||
_pathfinding(new Pathfinding()) {
|
||||
|
||||
assert(_objectFactory);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void Area::loadPTH() {
|
|||
_sceneGraph->addRoot(aabb);
|
||||
}
|
||||
|
||||
_navMesh->load(paths, pointZ);
|
||||
_pathfinding->load(paths, pointZ);
|
||||
}
|
||||
|
||||
void Area::loadARE(const GffStruct &are) {
|
||||
|
|
|
@ -27,12 +27,12 @@
|
|||
#include "../script/variable.h"
|
||||
|
||||
#include "camera/camera.h"
|
||||
#include "navmesh.h"
|
||||
#include "object/creature.h"
|
||||
#include "object/door.h"
|
||||
#include "object/placeable.h"
|
||||
#include "object/trigger.h"
|
||||
#include "object/waypoint.h"
|
||||
#include "pathfinding.h"
|
||||
#include "room.h"
|
||||
|
||||
namespace reone {
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
std::unique_ptr<resources::Visibility> _visibility;
|
||||
CameraStyle _cameraStyle;
|
||||
std::string _music;
|
||||
std::unique_ptr<NavMesh> _navMesh;
|
||||
std::unique_ptr<Pathfinding> _pathfinding;
|
||||
std::unordered_map<ScriptType, std::string> _scripts;
|
||||
std::list<DelayedCommand> _delayed;
|
||||
std::map<int, UserDefinedEvent> _events;
|
||||
|
|
|
@ -141,7 +141,7 @@ void Area::selectNextPathPoint(Creature::Path &path) {
|
|||
|
||||
void Area::updateCreaturePath(Creature &creature, const glm::vec3 &dest) {
|
||||
const glm::vec3 &origin = creature.position();
|
||||
vector<glm::vec3> points(_navMesh->findPath(origin, dest));
|
||||
vector<glm::vec3> points(_pathfinding->findPath(origin, dest));
|
||||
uint32_t now = SDL_GetTicks();
|
||||
|
||||
creature.setPath(dest, move(points), now);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "navmesh.h"
|
||||
#include "pathfinding.h"
|
||||
|
||||
#include "glm/gtx/norm.hpp"
|
||||
|
||||
|
@ -27,10 +27,10 @@ namespace reone {
|
|||
|
||||
namespace game {
|
||||
|
||||
NavMesh::Edge::Edge(uint16_t toIndex, float length) : toIndex(toIndex), length(length) {
|
||||
Pathfinding::Edge::Edge(uint16_t toIndex, float length) : toIndex(toIndex), length(length) {
|
||||
}
|
||||
|
||||
void NavMesh::load(const Paths &paths, const unordered_map<int, float> &pointZ) {
|
||||
void Pathfinding::load(const Paths &paths, const unordered_map<int, float> &pointZ) {
|
||||
const vector<Paths::Point> &points = paths.points();
|
||||
for (uint16_t i = 0; i < points.size(); ++i) {
|
||||
const Paths::Point &point = points[i];
|
||||
|
@ -49,7 +49,7 @@ void NavMesh::load(const Paths &paths, const unordered_map<int, float> &pointZ)
|
|||
}
|
||||
}
|
||||
|
||||
const vector<glm::vec3> NavMesh::findPath(const glm::vec3 &from, const glm::vec3 &to) const {
|
||||
const vector<glm::vec3> Pathfinding::findPath(const glm::vec3 &from, const glm::vec3 &to) const {
|
||||
if (_vertices.empty()) {
|
||||
return vector<glm::vec3> { from, to };
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ const vector<glm::vec3> NavMesh::findPath(const glm::vec3 &from, const glm::vec3
|
|||
return move(path);
|
||||
}
|
||||
|
||||
uint16_t NavMesh::getNearestVertex(const glm::vec3 &point) const {
|
||||
uint16_t Pathfinding::getNearestVertex(const glm::vec3 &point) const {
|
||||
uint16_t index = 0xffff;
|
||||
float minDist = 0.0f;
|
||||
|
||||
|
@ -102,7 +102,7 @@ uint16_t NavMesh::getNearestVertex(const glm::vec3 &point) const {
|
|||
return index;
|
||||
}
|
||||
|
||||
void NavMesh::visit(uint16_t index, FindPathContext &ctx) const {
|
||||
void Pathfinding::visit(uint16_t index, FindPathContext &ctx) const {
|
||||
if (ctx.visited.find(index) != ctx.visited.end()) return;
|
||||
|
||||
float dist = ctx.fromToDistance[index].second;
|
|
@ -31,9 +31,9 @@ namespace reone {
|
|||
|
||||
namespace game {
|
||||
|
||||
class NavMesh {
|
||||
class Pathfinding {
|
||||
public:
|
||||
NavMesh() = default;
|
||||
Pathfinding() = default;
|
||||
|
||||
void load(const Paths &paths, const std::unordered_map<int, float> &pointZ);
|
||||
|
||||
|
@ -56,8 +56,8 @@ private:
|
|||
std::vector<glm::vec3> _vertices;
|
||||
std::unordered_map<uint16_t, std::vector<Edge>> _edges;
|
||||
|
||||
NavMesh(const NavMesh &) = delete;
|
||||
NavMesh &operator=(const NavMesh &) = delete;
|
||||
Pathfinding(const Pathfinding &) = delete;
|
||||
Pathfinding &operator=(const Pathfinding &) = delete;
|
||||
|
||||
uint16_t getNearestVertex(const glm::vec3 &point) const;
|
||||
void visit(uint16_t index, FindPathContext &ctx) const;
|
Loading…
Reference in a new issue