summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-01-07 13:04:31 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-01-07 13:04:31 +0000
commit6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6 (patch)
tree46c42bcbef1f12c4f46d53b4e0c4736bea506b51 /ui
parentUnified crossProduct (diff)
downloadilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.tar.bz2
ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.tar.xz
ilt-6a1df3dfbae98a05e74c646cc216fbc19ffdb6d6.zip
Template Ray on position type
Diffstat (limited to 'ui')
-rw-r--r--ui/builders/freeExtend.cpp6
-rw-r--r--ui/builders/freeExtend.h6
-rw-r--r--ui/builders/join.cpp5
-rw-r--r--ui/builders/join.h6
-rw-r--r--ui/builders/straight.cpp6
-rw-r--r--ui/builders/straight.h6
-rw-r--r--ui/editNetwork.cpp4
-rw-r--r--ui/editNetwork.h10
-rw-r--r--ui/gameMainSelector.cpp6
-rw-r--r--ui/gameMainSelector.h8
10 files changed, 37 insertions, 26 deletions
diff --git a/ui/builders/freeExtend.cpp b/ui/builders/freeExtend.cpp
index 1520421..47356c3 100644
--- a/ui/builders/freeExtend.cpp
+++ b/ui/builders/freeExtend.cpp
@@ -11,7 +11,8 @@ BuilderFreeExtend::hint() const
}
void
-BuilderFreeExtend::move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent &, const Ray & ray)
+BuilderFreeExtend::move(
+ Network * network, const GeoData * geoData, const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> & ray)
{
if (p1) {
if (const auto p = network->intersectRayNodes(ray)) {
@@ -30,7 +31,8 @@ BuilderFreeExtend::move(Network * network, const GeoData * geoData, const SDL_Mo
}
void
-BuilderFreeExtend::click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray & ray)
+BuilderFreeExtend::click(
+ Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray<GlobalPosition3D> & ray)
{
switch (e.button) {
case SDL_BUTTON_LEFT:
diff --git a/ui/builders/freeExtend.h b/ui/builders/freeExtend.h
index b276426..127fdc6 100644
--- a/ui/builders/freeExtend.h
+++ b/ui/builders/freeExtend.h
@@ -6,8 +6,10 @@ class GeoData;
class BuilderFreeExtend : public EditNetwork::Builder {
std::string hint() const override;
- void click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray & ray) override;
- void move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent & e, const Ray & ray) override;
+ void click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e,
+ const Ray<GlobalPosition3D> & ray) override;
+ void move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent & e,
+ const Ray<GlobalPosition3D> & ray) override;
std::optional<Position3D> p1;
};
diff --git a/ui/builders/join.cpp b/ui/builders/join.cpp
index caa635f..7474c5b 100644
--- a/ui/builders/join.cpp
+++ b/ui/builders/join.cpp
@@ -11,7 +11,7 @@ BuilderJoin::hint() const
}
void
-BuilderJoin::move(Network * network, const GeoData *, const SDL_MouseMotionEvent &, const Ray & ray)
+BuilderJoin::move(Network * network, const GeoData *, const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> & ray)
{
if (p1) {
if (const auto p = network->intersectRayNodes(ray)) {
@@ -24,7 +24,8 @@ BuilderJoin::move(Network * network, const GeoData *, const SDL_MouseMotionEvent
}
void
-BuilderJoin::click(Network * network, const GeoData *, const SDL_MouseButtonEvent & e, const Ray & ray)
+BuilderJoin::click(
+ Network * network, const GeoData *, const SDL_MouseButtonEvent & e, const Ray<GlobalPosition3D> & ray)
{
switch (e.button) {
case SDL_BUTTON_LEFT:
diff --git a/ui/builders/join.h b/ui/builders/join.h
index bb0bd4c..dd57895 100644
--- a/ui/builders/join.h
+++ b/ui/builders/join.h
@@ -6,8 +6,10 @@ class GeoData;
class BuilderJoin : public EditNetwork::Builder {
std::string hint() const override;
- void click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray & ray) override;
- void move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent & e, const Ray & ray) override;
+ void click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e,
+ const Ray<GlobalPosition3D> & ray) override;
+ void move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent & e,
+ const Ray<GlobalPosition3D> & ray) override;
void create(Network * network, const Node::Ptr & p1, const Node::Ptr & p2) const;
diff --git a/ui/builders/straight.cpp b/ui/builders/straight.cpp
index 9b262bb..866705a 100644
--- a/ui/builders/straight.cpp
+++ b/ui/builders/straight.cpp
@@ -11,7 +11,8 @@ BuilderStraight::hint() const
}
void
-BuilderStraight::move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent &, const Ray & ray)
+BuilderStraight::move(
+ Network * network, const GeoData * geoData, const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> & ray)
{
if (p1) {
if (const auto p = geoData->intersectRay(ray)) {
@@ -24,7 +25,8 @@ BuilderStraight::move(Network * network, const GeoData * geoData, const SDL_Mous
}
void
-BuilderStraight::click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray & ray)
+BuilderStraight::click(
+ Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray<GlobalPosition3D> & ray)
{
switch (e.button) {
case SDL_BUTTON_LEFT:
diff --git a/ui/builders/straight.h b/ui/builders/straight.h
index cf99a1d..63f9a40 100644
--- a/ui/builders/straight.h
+++ b/ui/builders/straight.h
@@ -6,8 +6,10 @@ class GeoData;
class BuilderStraight : public EditNetwork::Builder {
std::string hint() const override;
- void click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e, const Ray & ray) override;
- void move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent & e, const Ray & ray) override;
+ void click(Network * network, const GeoData * geoData, const SDL_MouseButtonEvent & e,
+ const Ray<GlobalPosition3D> & ray) override;
+ void move(Network * network, const GeoData * geoData, const SDL_MouseMotionEvent & e,
+ const Ray<GlobalPosition3D> & ray) override;
void create(Network * network, Position3D p1, Position3D p2) const;
diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp
index 754053b..7fbde32 100644
--- a/ui/editNetwork.cpp
+++ b/ui/editNetwork.cpp
@@ -22,7 +22,7 @@ EditNetwork::EditNetwork(Network * n) :
}
bool
-EditNetwork::click(const SDL_MouseButtonEvent & e, const Ray & ray)
+EditNetwork::click(const SDL_MouseButtonEvent & e, const Ray<GlobalPosition3D> & ray)
{
if (builder && (e.button == SDL_BUTTON_LEFT || e.button == SDL_BUTTON_MIDDLE)) {
builder->click(network, gameState->geoData.get(), e, ray);
@@ -32,7 +32,7 @@ EditNetwork::click(const SDL_MouseButtonEvent & e, const Ray & ray)
}
bool
-EditNetwork::move(const SDL_MouseMotionEvent & e, const Ray & ray)
+EditNetwork::move(const SDL_MouseMotionEvent & e, const Ray<GlobalPosition3D> & ray)
{
if (builder) {
builder->move(network, gameState->geoData.get(), e, ray);
diff --git a/ui/editNetwork.h b/ui/editNetwork.h
index e1aaa61..c8a2f13 100644
--- a/ui/editNetwork.h
+++ b/ui/editNetwork.h
@@ -9,14 +9,14 @@
#include <gfx/models/texture.h>
#include <optional>
-class Ray;
+template<typename> class Ray;
class EditNetwork : public GameMainSelector::Component, public WorldOverlay {
public:
explicit EditNetwork(Network *);
- bool click(const SDL_MouseButtonEvent & e, const Ray &) override;
- bool move(const SDL_MouseMotionEvent & e, const Ray &) override;
+ bool click(const SDL_MouseButtonEvent & e, const Ray<GlobalPosition3D> &) override;
+ bool move(const SDL_MouseMotionEvent & e, const Ray<GlobalPosition3D> &) override;
bool handleInput(const SDL_Event & e, const UIComponent::Position &) override;
void render(const SceneShader &) const override;
void render(const UIShader & shader, const UIComponent::Position & pos) const override;
@@ -28,8 +28,8 @@ public:
virtual ~Builder() = default;
virtual void render(const SceneShader & shader) const;
virtual std::string hint() const = 0;
- virtual void click(Network *, const GeoData *, const SDL_MouseButtonEvent &, const Ray &) = 0;
- virtual void move(Network *, const GeoData *, const SDL_MouseMotionEvent &, const Ray &) = 0;
+ 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;
using Ptr = std::unique_ptr<Builder>;
diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp
index 703cfab..a577838 100644
--- a/ui/gameMainSelector.cpp
+++ b/ui/gameMainSelector.cpp
@@ -71,7 +71,7 @@ GameMainSelector::handleInput(const SDL_Event & e, const Position & parentPos)
}
void
-GameMainSelector::defaultClick(const Ray & ray)
+GameMainSelector::defaultClick(const Ray<GlobalPosition3D> & ray)
{
BaryPosition baryPos {};
RelativeDistance distance {};
@@ -90,13 +90,13 @@ GameMainSelector::defaultClick(const Ray & ray)
}
bool
-GameMainSelector::Component::click(const SDL_MouseButtonEvent &, const Ray &)
+GameMainSelector::Component::click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &)
{
return false;
}
bool
-GameMainSelector::Component::move(const SDL_MouseMotionEvent &, const Ray &)
+GameMainSelector::Component::move(const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> &)
{
return false;
}
diff --git a/ui/gameMainSelector.h b/ui/gameMainSelector.h
index 88db34b..cc30707 100644
--- a/ui/gameMainSelector.h
+++ b/ui/gameMainSelector.h
@@ -10,7 +10,7 @@
#include <string>
class SceneShader;
-class Ray;
+template<typename> class Ray;
class UIShader;
class Camera;
@@ -20,8 +20,8 @@ public:
public:
virtual ~Component() = default;
- virtual bool click(const SDL_MouseButtonEvent &, const Ray &);
- virtual bool move(const SDL_MouseMotionEvent &, const Ray &);
+ virtual bool click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &);
+ virtual bool move(const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> &);
virtual bool handleInput(const SDL_Event &, const Position & pos);
virtual void render(const UIShader & shader, const Position & pos) const;
virtual void render(const SceneShader &) const;
@@ -34,7 +34,7 @@ public:
bool handleInput(const SDL_Event & e, const Position &) override;
- void defaultClick(const Ray & ray);
+ void defaultClick(const Ray<GlobalPosition3D> & ray);
std::unique_ptr<Component> target;