summaryrefslogtreecommitdiff
path: root/game/network/rail.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-03 00:08:47 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-03 00:08:47 +0000
commit94311f9c4e82b7475802b1934cc0c5b243e0cd2f (patch)
tree5ef23f6c1151917eb723b67c262da0168e42343c /game/network/rail.cpp
parentOur own matrix rotations (diff)
downloadilt-94311f9c4e82b7475802b1934cc0c5b243e0cd2f.tar.bz2
ilt-94311f9c4e82b7475802b1934cc0c5b243e0cd2f.tar.xz
ilt-94311f9c4e82b7475802b1934cc0c5b243e0cd2f.zip
Replace Transform with Location
Simpler, unbinds the transformation matrices for location, now done just in the shader.
Diffstat (limited to 'game/network/rail.cpp')
-rw-r--r--game/network/rail.cpp11
1 files changed, 6 insertions, 5 deletions
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}};
}