diff options
Diffstat (limited to 'game/network')
-rw-r--r-- | game/network/link.h | 4 | ||||
-rw-r--r-- | game/network/rail.cpp | 11 | ||||
-rw-r--r-- | game/network/rail.h | 6 |
3 files changed, 11 insertions, 10 deletions
diff --git a/game/network/link.h b/game/network/link.h index 4968eba..e541975 100644 --- a/game/network/link.h +++ b/game/network/link.h @@ -2,8 +2,8 @@ #define LINK_H #include <array> -#include <gfx/gl/transform.h> #include <glm/glm.hpp> +#include <location.hpp> #include <memory> #include <special_members.hpp> #include <utility> @@ -39,7 +39,7 @@ public: NO_COPY(Link); NO_MOVE(Link); - [[nodiscard]] virtual Transform positionAt(float dist, unsigned char start) const = 0; + [[nodiscard]] virtual Location positionAt(float dist, unsigned char start) const = 0; std::array<End, 2> ends; float length; diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 55d57e4..6834989 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -9,6 +9,7 @@ #include <gfx/models/vertex.hpp> #include <glm/gtx/transform.hpp> #include <initializer_list> +#include <location.hpp> #include <maths.h> #include <stdexcept> #include <type_traits> @@ -97,7 +98,7 @@ RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) void RailLinks::render(const Shader & shader) const { - shader.setModel(glm::identity<glm::mat4>()); + shader.setModel(Location {}); texture->Bind(); links.apply(&RailLink::render, shader); } @@ -158,13 +159,13 @@ RailLinkStraight::RailLinkStraight(NodePtr a, NodePtr b, const glm::vec3 & diff) defaultMesh(); } -Transform +Location RailLinkStraight::positionAt(float dist, unsigned char start) const { const auto es {std::make_pair(ends[start].first.get(), ends[1 - start].first.get())}; const auto diff {es.second->pos - es.first->pos}; const auto dir {glm::normalize(diff)}; - return Transform {es.first->pos + RAIL_HEIGHT + dir * dist, {-vector_pitch(dir), vector_yaw(dir), 0}}; + return Location {es.first->pos + RAIL_HEIGHT + dir * dist, {-vector_pitch(dir), vector_yaw(dir), 0}}; } RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec2 c) : @@ -197,7 +198,7 @@ RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec3 c, defaultMesh(); } -Transform +Location RailLinkCurve::positionAt(float dist, unsigned char start) const { static constexpr std::array<float, 2> dirOffset {half_pi, -half_pi}; @@ -210,5 +211,5 @@ RailLinkCurve::positionAt(float dist, unsigned char start) const const auto relClimb {RAIL_HEIGHT + glm::vec3 {0, -centreBase.y + es.first->pos.y + ((es.second->pos.y - es.first->pos.y) * frac), 0}}; const auto pitch {vector_pitch({0, (es.first->pos.y - es.second->pos.y) / length, 0})}; - return Transform {relPos + relClimb + centreBase, {pitch, normalize(ang + dirOffset[start]), 0}}; + return Location {relPos + relClimb + centreBase, {pitch, normalize(ang + dirOffset[start]), 0}}; } diff --git a/game/network/rail.h b/game/network/rail.h index 5837ac1..d25964d 100644 --- a/game/network/rail.h +++ b/game/network/rail.h @@ -3,12 +3,12 @@ #include "collection.hpp" #include "game/worldobject.h" -#include "gfx/gl/transform.h" #include "gfx/models/mesh.h" #include "gfx/models/vertex.hpp" #include "gfx/renderable.h" #include "link.h" #include <glm/glm.hpp> +#include <location.hpp> #include <maths.h> #include <memory> #include <set> @@ -37,7 +37,7 @@ protected: class RailLinkStraight : public RailLink { public: RailLinkStraight(const NodePtr &, const NodePtr &); - [[nodiscard]] Transform positionAt(float dist, unsigned char start) const override; + [[nodiscard]] Location positionAt(float dist, unsigned char start) const override; private: RailLinkStraight(NodePtr, NodePtr, const glm::vec3 & diff); @@ -46,7 +46,7 @@ private: class RailLinkCurve : public RailLink { public: RailLinkCurve(const NodePtr &, const NodePtr &, glm::vec2); - [[nodiscard]] Transform positionAt(float dist, unsigned char start) const override; + [[nodiscard]] Location positionAt(float dist, unsigned char start) const override; private: RailLinkCurve(const NodePtr &, const NodePtr &, glm::vec3, const Arc); |