OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
waymatrix.h
Go to the documentation of this file.
1#pragma once
2
3#include <Tempest/Painter>
4#include <Tempest/Matrix4x4>
5
6#include <zenkit/world/WayNet.hh>
7
8#include <vector>
9#include <functional>
10
11#include "waypath.h"
12#include "waypoint.h"
13
14class World;
15class DbgPainter;
16
17class WayMatrix final {
18 public:
19 WayMatrix(World& owner, const zenkit::WayNet& dat);
20
21 const WayPoint* findWayPoint (const Tempest::Vec3& at, const std::function<bool(const WayPoint&)>& filter) const;
22 const WayPoint* findFreePoint(const Tempest::Vec3& at, std::string_view name, const std::function<bool(const WayPoint&)>& filter) const;
23 const WayPoint* findNextPoint(const Tempest::Vec3& at) const;
24
25 void addFreePoint (const Tempest::Vec3& pos, const Tempest::Vec3& dir, std::string_view name);
26 void addStartPoint(const Tempest::Vec3& pos, const Tempest::Vec3& dir, std::string_view name);
27
28 const WayPoint& startPoint() const;
29 const WayPoint& deadPoint() const;
30 void buildIndex();
31
32 const WayPoint* findWayPoint(std::string_view name) const;
33 const WayPoint* findPoint(std::string_view name, bool inexact) const;
34 void marchPoints(DbgPainter& p) const;
35
36 WayPath wayTo(const WayPoint** begin, size_t beginSz, const Tempest::Vec3 exactBegin, const WayPoint& end) const;
37
38 private:
39 struct WayEdge {
40 size_t a = 0;
41 size_t b = 0;
42 };
43
44 World& world;
45 // scripting doc says 20m, but number seems to be incorrect
46 // Vatras requires at least 8 meters
47 // Keroloth requires less than 8.25 meters
48 // Abuyin requires less than 10 meters
49 // Harry(CoM) requires less(!) than 8 meters
50 // Gothic 1 range is identical
51 // Vanilla is buggy here as Vatras can't reach his praying spot from teaching location
52 float distanceThreshold = 820.f;
53
54 std::vector<WayEdge> edges;
55
56 std::vector<WayPoint> wayPoints;
57 std::vector<WayPoint> freePoints, startPoints;
58 std::vector<WayPoint*> indexPoints;
59
60 std::vector<WayPoint*> fpInd;
61
62 struct FpIndex {
63 std::string key;
64 std::vector<const WayPoint*> index;
65 };
66 mutable std::vector<FpIndex> fpIndex;
67
68 mutable uint16_t pathGen=0;
69 mutable std::vector<const WayPoint*> stk[2];
70
71 void adjustWaypoints(std::vector<WayPoint> &wp);
72 void calculateLadderPoints();
73
74 const FpIndex& findFpIndex(std::string_view name) const;
75 const WayPoint* findFreePoint(float x, float y, float z, const FpIndex &ind,
76 const std::function<bool(const WayPoint&)>& filter) const;
77 };
const WayPoint * findNextPoint(const Tempest::Vec3 &at) const
Definition waymatrix.cpp:84
const WayPoint & startPoint() const
void buildIndex()
Definition waymatrix.cpp:33
void addFreePoint(const Tempest::Vec3 &pos, const Tempest::Vec3 &dir, std::string_view name)
const WayPoint * findFreePoint(const Tempest::Vec3 &at, std::string_view name, const std::function< bool(const WayPoint &)> &filter) const
const WayPoint * findPoint(std::string_view name, bool inexact) const
void addStartPoint(const Tempest::Vec3 &pos, const Tempest::Vec3 &dir, std::string_view name)
const WayPoint * findWayPoint(const Tempest::Vec3 &at, const std::function< bool(const WayPoint &)> &filter) const
const WayPoint & deadPoint() const
WayPath wayTo(const WayPoint **begin, size_t beginSz, const Tempest::Vec3 exactBegin, const WayPoint &end) const
void marchPoints(DbgPainter &p) const
Definition world.h:31