summaryrefslogtreecommitdiff
path: root/game/vehicles/railVehicle.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-11 17:37:57 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-11 17:37:57 +0000
commit5e25d79beef19c39537b0f15982a175fec45bb3e (patch)
tree011cdd78c661757bab03cfd8ede11e6a58047968 /game/vehicles/railVehicle.cpp
parentAdd BufferedLocation method for getting the rotation only transform (diff)
downloadilt-5e25d79beef19c39537b0f15982a175fec45bb3e.tar.bz2
ilt-5e25d79beef19c39537b0f15982a175fec45bb3e.tar.xz
ilt-5e25d79beef19c39537b0f15982a175fec45bb3e.zip
Refactor BufferedLocationT to use a callback
Simplifies customisation in the face of multiple fields
Diffstat (limited to 'game/vehicles/railVehicle.cpp')
-rw-r--r--game/vehicles/railVehicle.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp
index fc43995..1ed904d 100644
--- a/game/vehicles/railVehicle.cpp
+++ b/game/vehicles/railVehicle.cpp
@@ -12,10 +12,19 @@
#include <ray.h>
RailVehicle::RailVehicle(RailVehicleClassPtr rvc) :
- RailVehicleClass::Instance {rvc->instances.acquire()}, rvClass {std::move(rvc)}, location {&LV::body, *this},
+ RailVehicleClass::Instance {rvc->instances.acquire()}, rvClass {std::move(rvc)},
+ location {[this](const BufferedLocation * l) {
+ this->get()->body = l->getTransform();
+ }},
bogies {{
- {&LV::front, *this, Position3D {0, rvClass->wheelBase / 2.F, 0}},
- {&LV::back, *this, Position3D {0, -rvClass->wheelBase / 2.F, 0}},
+ {[this](const BufferedLocation * l) {
+ this->get()->front = l->getTransform();
+ },
+ Position3D {0, rvClass->wheelBase / 2.F, 0}},
+ {[this](const BufferedLocation * l) {
+ this->get()->back = l->getTransform();
+ },
+ Position3D {0, -rvClass->wheelBase / 2.F, 0}},
}}
{
}