summaryrefslogtreecommitdiff
path: root/application
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-02-24 01:19:58 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-02-24 01:19:58 +0000
commit93a8b53c5d915498f9abac93e0c5b69916a1fc3a (patch)
treeabfcb0e0146a29deead395b0a730acaf8b01dc47 /application
parentDon't rely on triangle centroid not already having a surface (diff)
downloadilt-93a8b53c5d915498f9abac93e0c5b69916a1fc3a.tar.bz2
ilt-93a8b53c5d915498f9abac93e0c5b69916a1fc3a.tar.xz
ilt-93a8b53c5d915498f9abac93e0c5b69916a1fc3a.zip
New hardcoded test rail network
Diffstat (limited to 'application')
-rw-r--r--application/main.cpp66
1 files changed, 41 insertions, 25 deletions
diff --git a/application/main.cpp b/application/main.cpp
index 2c0d96f..723f3d2 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -11,6 +11,7 @@
#include <game/network/link.h>
#include <game/network/rail.h>
#include <game/objective.h>
+#include <game/objectives/freeroam.h>
#include <game/objectives/goto.h>
#include <game/orders.h>
#include <game/scenary/foliage.h>
@@ -25,8 +26,13 @@
#include <glm/gtx/transform.hpp> // IWYU pragma: keep
#include <memory>
#include <random>
+#include <ranges>
#include <special_members.h>
+#include <stream_support.h>
#include <ui/applicationBase.h>
+#include <ui/builders/freeExtend.h>
+#include <ui/builders/join.h>
+#include <ui/builders/straight.h>
#include <ui/gameMainWindow.h>
#include <ui/window.h>
@@ -46,36 +52,46 @@ public:
{
auto rl = world.create<RailLinks>();
- const GlobalPosition3D j {-1120000, -1100000, 3000}, k {-1100000, -1000000, 15000},
- l {-1000000, -800000, 20000}, m {-900000, -600000, 30000}, n {-600000, -500000, 32000},
- o {-500000, -800000, 30000}, p {-600000, -900000, 25000}, q {-1025000, -1175000, 10000},
- r {-925000, -1075000, 10000}, s {-1100000, -500000, 15000}, t {-1100000, -450000, 15000},
- u {-1000000, -400000, 15000};
- auto l3 = rl->addLinksBetween(j, k);
- rl->addLinksBetween(k, l);
- rl->addLinksBetween(l, m);
- rl->addLinksBetween(m, n);
- rl->addLinksBetween(n, o);
- rl->addLinksBetween(o, p);
- // branch 1
- rl->addLinksBetween(p, q);
- rl->addLinksBetween(q, j);
- // branch 2
- rl->addLinksBetween(p, r);
- rl->addLinksBetween(r, j);
- // early loop
- rl->addLinksBetween(s, t);
- rl->addLinksBetween(l, s);
- rl->addLinksBetween(t, u);
- rl->addLinksBetween(u, m);
- const std::shared_ptr<Train> train = world.create<Train>(l3);
+ const auto nodes = materializeRange(std::vector<GlobalPosition2D> {
+ {315103000, 491067000},
+ {315977000, 490777000},
+ {316312000, 490557000},
+ {316885000, 491330000},
+ {316510934, 491255979},
+ {316129566, 490893054},
+ {315825622, 490833929},
+ {315106182, 491073714},
+ }
+ | std::views::transform([this](const auto n) {
+ return terrain->positionAt(n);
+ }));
+ auto l3 = BuilderStraight {}.create(rl.get(), terrain.get(), *nodes.begin(), *++nodes.begin()).front();
+ for (const auto & [from, to] : nodes | std::views::drop(1) | std::views::pairwise) {
+ const auto links = BuilderFreeExtend {}.createExtend(rl.get(), terrain.get(), from, to);
+ }
+ for (const auto & [from, to] : std::initializer_list<std::pair<GlobalPosition2D, GlobalPosition2D>> {
+ {{315103000, 491067000}, {315003434, 491076253}},
+ {{315103000, 491067000}, {315016495, 491019224}},
+ {{315016495, 491019224}, {314955393, 490999023}},
+ }) {
+ const auto links = BuilderFreeExtend {}.createExtend(
+ rl.get(), terrain.get(), terrain->positionAt(from), terrain->positionAt(to));
+ }
+ for (const auto & [from, to] : std::initializer_list<std::pair<GlobalPosition2D, GlobalPosition2D>> {
+ {{315106182, 491073714}, {314955393, 490999023}},
+ }) {
+ auto p1 = rl->intersectRayNodes({from || 0, up})->pos;
+ auto p2 = rl->intersectRayNodes({to || 0, up})->pos;
+ const auto links = BuilderFreeExtend {}.createJoin(rl.get(), terrain.get(), p1, p2);
+ }
+
+ const std::shared_ptr<Train> train = world.create<Train>(l3, 800000);
auto b47 = std::dynamic_pointer_cast<RailVehicleClass>(assets.at("brush-47"));
for (int N = 0; N < 6; N++) {
train->create<RailVehicle>(b47);
}
train->orders.removeAll();
- train->orders.create<GoTo>(
- &train->orders, l3->ends[1], l3->length, rl->findNodeAt({-1100000, -450000, 15000}));
+ train->orders.create<FreeRoam>(&train->orders);
train->currentActivity = train->orders.current()->createActivity();
std::random_device randomdev {};