summaryrefslogtreecommitdiff
path: root/game/vehicles
diff options
context:
space:
mode:
Diffstat (limited to 'game/vehicles')
-rw-r--r--game/vehicles/railloco.cpp16
-rw-r--r--game/vehicles/railloco.h6
-rw-r--r--game/vehicles/vehicle.h4
3 files changed, 13 insertions, 13 deletions
diff --git a/game/vehicles/railloco.cpp b/game/vehicles/railloco.cpp
index bc62d43..de47ebb 100644
--- a/game/vehicles/railloco.cpp
+++ b/game/vehicles/railloco.cpp
@@ -1,6 +1,5 @@
#include "railloco.h"
#include "gfx/gl/shader.h"
-#include "gfx/gl/transform.h"
#include "gfx/models/obj.h"
#include "gfx/models/texture.h"
#include <algorithm>
@@ -10,6 +9,7 @@
#include <glm/glm.hpp>
#include <iterator>
#include <lib/resource.h>
+#include <location.hpp>
#include <map>
#include <maths.h>
#include <memory>
@@ -23,10 +23,10 @@ RailVehicle::render(const Shader & shader) const
{
texture->Bind();
for (const auto & bogie : bogies) {
- shader.setModel(bogie.location.GetModel());
+ shader.setModel(bogie.location);
bogie.mesh->Draw();
}
- shader.setModel(location.GetModel());
+ shader.setModel(location);
bodyMesh->Draw();
}
@@ -39,7 +39,7 @@ RailLoco::move(TickDuration dur)
while (linkDist > curLink.first->length) {
location = curLink.first->positionAt(curLink.first->length, curLink.second);
auto nexts {curLink.first->nexts[1 - curLink.second]};
- auto last = std::remove_if(nexts.begin(), nexts.end(), [ang = location.GetRot().y](const Link::Next & n) {
+ auto last = std::remove_if(nexts.begin(), nexts.end(), [ang = location.rot.y](const Link::Next & n) {
return std::abs(normalize(n.first.lock()->ends[n.second].second - ang)) > 0.1F;
});
if (last != nexts.begin()) {
@@ -54,7 +54,7 @@ RailLoco::move(TickDuration dur)
}
}
-Transform
+Location
RailLoco::getBogiePosition(float linkDist, float dist) const
{
float b2linkDist {};
@@ -68,9 +68,9 @@ RailLoco::updateRailVehiclePosition(RailVehicle * w, float trailBy) const
const auto overhang {(w->length - w->wheelBase) / 2};
const auto & b1Pos = w->bogies[0].location = getBogiePosition(linkDist, trailBy += overhang);
const auto & b2Pos = w->bogies[1].location = getBogiePosition(linkDist, trailBy + wheelBase);
- const auto diff = glm::normalize(b2Pos.GetPos() - b1Pos.GetPos());
- w->location.GetPos() = (b1Pos.GetPos() + b2Pos.GetPos()) / 2.F;
- w->location.GetRot() = {-vector_pitch(diff), vector_yaw(diff), 0};
+ const auto diff = glm::normalize(b2Pos.pos - b1Pos.pos);
+ w->location.pos = (b1Pos.pos + b2Pos.pos) / 2.F;
+ w->location.rot = {-vector_pitch(diff), vector_yaw(diff), 0};
}
void
diff --git a/game/vehicles/railloco.h b/game/vehicles/railloco.h
index ddc706f..f08de05 100644
--- a/game/vehicles/railloco.h
+++ b/game/vehicles/railloco.h
@@ -1,9 +1,9 @@
#include "game/network/link.h"
#include "game/vehicles/vehicle.h"
#include "game/worldobject.h"
-#include "gfx/gl/transform.h"
#include "gfx/models/mesh.h"
#include <array>
+#include <location.hpp>
#include <memory>
#include <vector>
@@ -13,7 +13,7 @@ class Texture;
class RailVehicle : public Vehicle {
public:
struct Bogie {
- Transform location;
+ Location location;
MeshPtr mesh;
};
@@ -45,7 +45,7 @@ public:
private:
void move(TickDuration dur);
- [[nodiscard]] Transform getBogiePosition(float linkDist, float dist) const;
+ [[nodiscard]] Location getBogiePosition(float linkDist, float dist) const;
void updateRailVehiclePosition(RailVehicle *, float trailBy) const;
void updateWagons() const;
};
diff --git a/game/vehicles/vehicle.h b/game/vehicles/vehicle.h
index 228f15a..a511d3c 100644
--- a/game/vehicles/vehicle.h
+++ b/game/vehicles/vehicle.h
@@ -1,10 +1,10 @@
#ifndef VEHICLE_H
#define VEHICLE_H
-#include "gfx/gl/transform.h"
#include <game/network/link.h>
#include <game/worldobject.h>
#include <gfx/renderable.h>
+#include <location.hpp>
#include <memory>
#include <utility>
#include <vector>
@@ -28,7 +28,7 @@ public:
float linkDist; // distance long current link
float speed {50}; // speed in m/s (~75 km/h)
- Transform location;
+ Location location;
protected:
LinkHistory linkHist;