diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-12-22 13:53:27 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-12-22 13:53:27 +0000 |
commit | 749df22c85b83c86ec68ebc74829287e54498e26 (patch) | |
tree | 8e3635f80673c0b8d4505de3d363aa7742a2d430 /ui | |
parent | Expose network base width and surface (diff) | |
download | ilt-terrain-for-networks.tar.bz2 ilt-terrain-for-networks.tar.xz ilt-terrain-for-networks.zip |
Set terrain heights when creating new network linksterrain-for-networks
Diffstat (limited to 'ui')
-rw-r--r-- | ui/builders/freeExtend.cpp | 8 | ||||
-rw-r--r-- | ui/builders/join.cpp | 4 | ||||
-rw-r--r-- | ui/builders/straight.cpp | 4 | ||||
-rw-r--r-- | ui/editNetwork.cpp | 11 | ||||
-rw-r--r-- | ui/editNetwork.h | 3 |
5 files changed, 26 insertions, 4 deletions
diff --git a/ui/builders/freeExtend.cpp b/ui/builders/freeExtend.cpp index 904e144..fa08af6 100644 --- a/ui/builders/freeExtend.cpp +++ b/ui/builders/freeExtend.cpp @@ -61,11 +61,15 @@ BuilderFreeExtend::click( Link::CCollection BuilderFreeExtend::createJoin(Network * network, GlobalPosition3D p1, GlobalPosition3D p2) const { - return network->addJoins(p1, p2); + const auto links = network->addJoins(p1, p2); + setHeightsFor(network, links); + return links; } Link::CCollection BuilderFreeExtend::createExtend(Network * network, GlobalPosition3D p1, GlobalPosition3D p2) const { - return network->addExtend(p1, p2); + const auto links = network->addExtend(p1, p2); + setHeightsFor(network, links); + return links; } diff --git a/ui/builders/join.cpp b/ui/builders/join.cpp index 9fbbae9..ee14d63 100644 --- a/ui/builders/join.cpp +++ b/ui/builders/join.cpp @@ -49,5 +49,7 @@ BuilderJoin::click( Link::CCollection BuilderJoin::create(Network * network, const Node::Ptr & p1, const Node::Ptr & p2) const { - return network->addJoins(p1->pos, p2->pos); + const auto links = network->addJoins(p1->pos, p2->pos); + setHeightsFor(network, links); + return links; } diff --git a/ui/builders/straight.cpp b/ui/builders/straight.cpp index 014eea5..b9f1831 100644 --- a/ui/builders/straight.cpp +++ b/ui/builders/straight.cpp @@ -52,5 +52,7 @@ BuilderStraight::click( Link::CCollection BuilderStraight::create(Network * network, GlobalPosition3D p1, GlobalPosition3D p2) const { - return network->addStraight(p1, p2); + const auto links = network->addStraight(p1, p2); + setHeightsFor(network, links); + return links; } diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp index ac2d93d..50d049d 100644 --- a/ui/editNetwork.cpp +++ b/ui/editNetwork.cpp @@ -64,6 +64,17 @@ EditNetwork::Builder::render(const SceneShader & shader) const } void +EditNetwork::Builder::setHeightsFor(Network * network, const Link::CCollection & links, GeoData::SetHeightsOpts opts) +{ + opts.surface = network->getBaseSurface(); + const auto width = network->getBaseWidth(); + + for (const auto & link : links) { + gameState->geoData->setHeights(link->getBase(width), opts); + } +} + +void EditNetwork::render(const UIShader & shader, const UIComponent::Position & parentPos) const { if (builder) { diff --git a/ui/editNetwork.h b/ui/editNetwork.h index ec06fa7..2ae467d 100644 --- a/ui/editNetwork.h +++ b/ui/editNetwork.h @@ -1,5 +1,6 @@ #pragma once +#include "game/geoData.h" #include "gameMainSelector.h" #include "modeHelper.h" #include "toolbar.h" @@ -30,6 +31,8 @@ public: virtual void click(Network *, const GeoData *, const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &) = 0; virtual void move(Network *, const GeoData *, const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> &) = 0; + static void setHeightsFor(Network *, const Link::CCollection &, GeoData::SetHeightsOpts = {}); + using Ptr = std::unique_ptr<Builder>; protected: |