summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--application/main.cpp5
-rw-r--r--assetFactory/factoryMesh.h3
-rw-r--r--assetFactory/mutation.h7
-rw-r--r--assetFactory/shape.h3
-rw-r--r--assetFactory/texturePacker.cpp4
-rw-r--r--assetFactory/texturePacker.h7
-rw-r--r--config/types.h34
-rw-r--r--game/geoData.h33
-rw-r--r--game/network/link.h12
-rw-r--r--game/network/network.h42
-rw-r--r--game/network/network.impl.h12
-rw-r--r--game/network/rail.h10
-rw-r--r--game/selectable.h3
-rw-r--r--game/vehicles/railVehicle.h2
-rw-r--r--game/vehicles/train.h2
-rw-r--r--gfx/gl/bufferedLocation.h14
-rw-r--r--gfx/gl/camera.cpp4
-rw-r--r--gfx/gl/camera.h25
-rw-r--r--gfx/gl/sceneRenderer.cpp2
-rw-r--r--gfx/gl/sceneRenderer.h10
-rw-r--r--gfx/gl/sceneShader.h5
-rw-r--r--gfx/gl/shadowMapper.cpp2
-rw-r--r--gfx/gl/shadowMapper.h9
-rw-r--r--gfx/gl/uiShader.h3
-rw-r--r--gfx/models/texture.cpp1
-rw-r--r--gfx/models/texture.h5
-rw-r--r--gfx/models/tga.h3
-rw-r--r--gfx/models/vertex.h12
-rw-r--r--lib/geometricPlane.h10
-rw-r--r--lib/location.h12
-rw-r--r--lib/maths.h61
-rw-r--r--lib/ray.h15
-rw-r--r--test/test-assetFactory.cpp5
-rw-r--r--test/testRenderOutput.h7
-rw-r--r--test/testStructures.h5
-rw-r--r--ui/builders/freeExtend.h2
-rw-r--r--ui/builders/straight.h4
-rw-r--r--ui/gameMainSelector.cpp2
-rw-r--r--ui/gameMainSelector.h3
-rw-r--r--ui/manualCameraController.h4
-rw-r--r--ui/window.h2
41 files changed, 231 insertions, 175 deletions
diff --git a/application/main.cpp b/application/main.cpp
index 0e880c0..ffdaf63 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -26,7 +26,6 @@
#include <ui/applicationBase.h>
#include <ui/gameMainWindow.h>
#include <ui/window.h>
-#include <vector>
static const int DISPLAY_WIDTH = 1280;
static const int DISPLAY_HEIGHT = 1024;
@@ -49,10 +48,10 @@ public:
{
auto rl = world.create<RailLinks>();
- const glm::vec3 j {-1120, -1100, 3}, k {-1100, -1000, 15}, l {-1000, -800, 20}, m {-900, -600, 30},
+ const Position3D j {-1120, -1100, 3}, k {-1100, -1000, 15}, l {-1000, -800, 20}, m {-900, -600, 30},
n {-600, -500, 32}, o {-500, -800, 30}, p {-600, -900, 25}, q {-1025, -1175, 10},
r {-925, -1075, 10};
- const glm::vec3 s {-1100, -500, 15}, t {-1100, -450, 15}, u {-1000, -400, 15};
+ const Position3D s {-1100, -500, 15}, t {-1100, -450, 15}, u {-1000, -400, 15};
auto l3 = rl->addLinksBetween(j, k);
rl->addLinksBetween(k, l);
rl->addLinksBetween(l, m);
diff --git a/assetFactory/factoryMesh.h b/assetFactory/factoryMesh.h
index f71c737..b09b54f 100644
--- a/assetFactory/factoryMesh.h
+++ b/assetFactory/factoryMesh.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "gfx/models/mesh.h"
#include "stdTypeDefs.h"
#include "use.h"
@@ -9,7 +10,7 @@ public:
Mesh::Ptr createMesh() const;
std::string id;
- glm::vec3 size;
+ Size3D size;
Use::Collection uses;
private:
diff --git a/assetFactory/mutation.h b/assetFactory/mutation.h
index 2432174..b571dea 100644
--- a/assetFactory/mutation.h
+++ b/assetFactory/mutation.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "persistence.h"
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
@@ -13,9 +14,9 @@ struct Mutation {
float relativeLevelOfDetail() const;
- glm::vec3 position {};
- glm::vec3 rotation {};
- glm::vec3 scale {1};
+ Position3D position {};
+ Rotation3D rotation {};
+ Scale3D scale {1};
protected:
bool persist(Persistence::PersistenceStore & store);
diff --git a/assetFactory/shape.h b/assetFactory/shape.h
index ea3e4e7..136e24f 100644
--- a/assetFactory/shape.h
+++ b/assetFactory/shape.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "modelFactoryMesh_fwd.h"
#include "stdTypeDefs.h"
#include <OpenMesh/Core/Mesh/Handles.hh>
@@ -21,5 +22,5 @@ public:
virtual CreatedFaces createMesh(ModelFactoryMesh &, float levelOfDetailFactor) const = 0;
static std::vector<OpenMesh::VertexHandle> addToMesh(
- ModelFactoryMesh & mesh, const std::span<const glm::vec3> vertices);
+ ModelFactoryMesh & mesh, const std::span<const Position3D> vertices);
};
diff --git a/assetFactory/texturePacker.cpp b/assetFactory/texturePacker.cpp
index dbafc4b..0d0fdb6 100644
--- a/assetFactory/texturePacker.cpp
+++ b/assetFactory/texturePacker.cpp
@@ -14,9 +14,7 @@ TexturePacker::TexturePacker(std::span<const Image> in) :
std::sort(sortedIndexes.rbegin(), sortedIndexes.rend(), [this](const auto a, const auto b) {
return area(inputImages[a]) < area(inputImages[b]);
});
- int mts;
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mts);
- maxTextureSize = static_cast<unsigned int>(mts);
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
}
TexturePacker::Result
diff --git a/assetFactory/texturePacker.h b/assetFactory/texturePacker.h
index 93413eb..05e3204 100644
--- a/assetFactory/texturePacker.h
+++ b/assetFactory/texturePacker.h
@@ -1,13 +1,14 @@
#pragma once
+#include "config/types.h"
#include <glm/vec2.hpp>
#include <span>
#include <vector>
class TexturePacker {
public:
- using Position = glm::uvec2;
- using Size = glm::uvec2;
+ using Position = TextureAbsCoord;
+ using Size = TextureAbsCoord;
struct Area {
#ifndef __cpp_aggregate_paren_init
@@ -40,5 +41,5 @@ public:
private:
std::span<const Image> inputImages;
std::vector<size_t> sortedIndexes;
- unsigned int maxTextureSize;
+ GLsizei maxTextureSize;
};
diff --git a/config/types.h b/config/types.h
new file mode 100644
index 0000000..a84be90
--- /dev/null
+++ b/config/types.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "glad/gl.h"
+#include <glm/geometric.hpp>
+
+using Distance = float;
+using Angle = float;
+
+template<glm::length_t D> using Position = glm::vec<D, Distance>;
+template<glm::length_t D> using Size = glm::vec<D, Distance>;
+template<glm::length_t D> using Scale = glm::vec<D, float>;
+template<glm::length_t D> using Direction = glm::vec<D, float>;
+template<glm::length_t D> using Normal = Direction<D>;
+template<glm::length_t D> using Rotation = glm::vec<D, Angle>;
+template<glm::length_t Channels> using Colour = glm::vec<Channels, float>;
+
+using Position2D = Position<2>;
+using Position3D = Position<3>;
+using Size2D = Size<2>;
+using Size3D = Size<3>;
+using Scale2D = Scale<2>;
+using Scale3D = Scale<3>;
+using Direction2D = Direction<2>;
+using Direction3D = Direction<3>;
+using Normal2D = Normal<2>;
+using Normal3D = Normal<3>;
+using Rotation2D = Rotation<2>;
+using Rotation3D = Rotation<3>;
+using TextureRelCoord = glm::vec<2, float>;
+using TextureAbsCoord = glm::vec<2, GLsizei>;
+using RGB = Colour<3>;
+using RGBA = Colour<4>;
+using ScreenRelCoord = glm::vec<2, float>;
+using ScreenAbsCoord = glm::vec<2, uint16_t>;
diff --git a/game/geoData.h b/game/geoData.h
index f9a7d7b..b3ec51d 100644
--- a/game/geoData.h
+++ b/game/geoData.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include <array>
#include <filesystem>
#include <glm/glm.hpp>
@@ -16,47 +17,47 @@ public:
float height {-1.5F};
};
- using Quad = std::array<glm::vec3, 4>;
+ using Quad = std::array<Position3D, 4>;
- using Limits = std::pair<glm::ivec2, glm::ivec2>;
+ using Limits = std::pair<glm::vec<2, int>, glm::vec<2, int>>;
explicit GeoData(Limits limit, float scale = 10.F);
void generateRandom();
void loadFromImages(const std::filesystem::path &, float scale);
- [[nodiscard]] glm::vec3 positionAt(glm::vec2) const;
- [[nodiscard]] std::optional<glm::vec3> intersectRay(const Ray &) const;
+ [[nodiscard]] Position3D positionAt(Position2D) const;
+ [[nodiscard]] std::optional<Position3D> intersectRay(const Ray &) const;
- [[nodiscard]] unsigned int at(glm::ivec2) const;
+ [[nodiscard]] unsigned int at(glm::vec<2, int>) const;
[[nodiscard]] unsigned int at(int x, int y) const;
- [[nodiscard]] Quad quad(glm::vec2) const;
+ [[nodiscard]] Quad quad(Position2D) const;
[[nodiscard]] Limits getLimit() const;
- [[nodiscard]] glm::uvec2 getSize() const;
+ [[nodiscard]] glm::vec<2, unsigned int> getSize() const;
[[nodiscard]] float getScale() const;
[[nodiscard]] std::span<const Node> getNodes() const;
class RayTracer {
public:
- RayTracer(glm::vec2 p0, glm::vec2 p1);
+ RayTracer(Position2D p0, Position2D p1);
- glm::vec2 next();
+ Position2D next();
private:
- RayTracer(glm::vec2 p0, glm::vec2 p1, glm::vec2 d);
- RayTracer(glm::vec2 p0, glm::vec2 d, std::pair<float, float>, std::pair<float, float>);
- static std::pair<float, float> byAxis(glm::vec2 p0, glm::vec2 p1, glm::vec2 d, glm::length_t);
+ RayTracer(Position2D p0, Position2D p1, Position2D d);
+ RayTracer(Position2D p0, Position2D d, std::pair<float, float>, std::pair<float, float>);
+ static std::pair<float, float> byAxis(Position2D p0, Position2D p1, Position2D d, glm::length_t);
- glm::vec2 p;
- const glm::vec2 d;
+ Position2D p;
+ const Position2D d;
float error;
- glm::vec2 inc;
+ Position2D inc;
};
protected:
Limits limit {}; // Base grid limits first(x,y) -> second(x,y)
- glm::uvec2 size {};
+ glm::vec<2, unsigned> size {};
float scale {1};
std::vector<Node> nodes;
};
diff --git a/game/network/link.h b/game/network/link.h
index 0d66c42..78d3e91 100644
--- a/game/network/link.h
+++ b/game/network/link.h
@@ -17,12 +17,12 @@ class Ray;
// it has location
class Node : public StdTypeDefs<Node> {
public:
- explicit Node(glm::vec3 p) noexcept : pos(p) {};
+ explicit Node(Position3D p) noexcept : pos(p) {};
virtual ~Node() noexcept = default;
NO_COPY(Node);
NO_MOVE(Node);
- glm::vec3 pos;
+ Position3D pos;
};
// Generic network link
@@ -51,14 +51,14 @@ public:
float length;
protected:
- [[nodiscard]] virtual glm::vec3
+ [[nodiscard]] virtual Position3D
vehiclePositionOffset() const
{
return {};
}
};
-bool operator<(const glm::vec3 & a, const glm::vec3 & b);
+bool operator<(const Position3D & a, const Position3D & b);
bool operator<(const Node & a, const Node & b);
class LinkStraight : public virtual Link {
@@ -77,14 +77,14 @@ LinkStraight::~LinkStraight() = default;
class LinkCurve : public virtual Link {
public:
inline ~LinkCurve() override = 0;
- LinkCurve(glm::vec3, float, Arc);
+ LinkCurve(Position3D, float, Arc);
NO_COPY(LinkCurve);
NO_MOVE(LinkCurve);
[[nodiscard]] Location positionAt(float dist, unsigned char start) const override;
[[nodiscard]] bool intersectRay(const Ray &) const override;
- glm::vec3 centreBase;
+ Position3D centreBase;
float radius;
Arc arc;
};
diff --git a/game/network/network.h b/game/network/network.h
index b9316eb..02f8c30 100644
--- a/game/network/network.h
+++ b/game/network/network.h
@@ -26,32 +26,32 @@ public:
virtual ~Network() = default;
DEFAULT_MOVE_NO_COPY(Network);
- [[nodiscard]] Node::Ptr findNodeAt(glm::vec3) const;
- [[nodiscard]] Node::Ptr nodeAt(glm::vec3);
+ [[nodiscard]] Node::Ptr findNodeAt(Position3D) const;
+ [[nodiscard]] Node::Ptr nodeAt(Position3D);
enum class NodeIs { InNetwork, NotInNetwork };
using NodeInsertion = std::pair<Node::Ptr, NodeIs>;
- [[nodiscard]] NodeInsertion newNodeAt(glm::vec3);
- [[nodiscard]] NodeInsertion candidateNodeAt(glm::vec3) const;
+ [[nodiscard]] NodeInsertion newNodeAt(Position3D);
+ [[nodiscard]] NodeInsertion candidateNodeAt(Position3D) const;
[[nodiscard]] virtual Link::Ptr intersectRayLinks(const Ray &) const = 0;
[[nodiscard]] virtual Node::Ptr intersectRayNodes(const Ray &) const;
- [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, glm::vec3) const;
+ [[nodiscard]] Link::Nexts routeFromTo(const Link::End &, Position3D) const;
[[nodiscard]] Link::Nexts routeFromTo(const Link::End &, const Node::Ptr &) const;
- virtual Link::CCollection candidateStraight(glm::vec3, glm::vec3) = 0;
- virtual Link::CCollection candidateJoins(glm::vec3, glm::vec3) = 0;
- virtual Link::CCollection candidateExtend(glm::vec3, glm::vec3) = 0;
- virtual Link::CCollection addStraight(glm::vec3, glm::vec3) = 0;
- virtual Link::CCollection addJoins(glm::vec3, glm::vec3) = 0;
- virtual Link::CCollection addExtend(glm::vec3, glm::vec3) = 0;
+ virtual Link::CCollection candidateStraight(Position3D, Position3D) = 0;
+ virtual Link::CCollection candidateJoins(Position3D, Position3D) = 0;
+ virtual Link::CCollection candidateExtend(Position3D, Position3D) = 0;
+ virtual Link::CCollection addStraight(Position3D, Position3D) = 0;
+ virtual Link::CCollection addJoins(Position3D, Position3D) = 0;
+ virtual Link::CCollection addExtend(Position3D, Position3D) = 0;
[[nodiscard]] virtual float findNodeDirection(Node::AnyCPtr) const = 0;
protected:
static void joinLinks(const Link::Ptr & l, const Link::Ptr & ol);
- static GenCurveDef genCurveDef(const glm::vec3 & start, const glm::vec3 & end, float startDir);
+ static GenCurveDef genCurveDef(const Position3D & start, const Position3D & end, float startDir);
static std::pair<GenCurveDef, GenCurveDef> genCurveDef(
- const glm::vec3 & start, const glm::vec3 & end, float startDir, float endDir);
+ const Position3D & start, const Position3D & end, float startDir, float endDir);
using Nodes = std::set<Node::Ptr, PtrMemberSorter<Node::Ptr, &Node::pos>>;
Nodes nodes;
@@ -71,7 +71,7 @@ protected:
public:
template<typename L, typename... Params>
std::shared_ptr<L>
- candidateLink(glm::vec3 a, glm::vec3 b, Params &&... params)
+ candidateLink(Position3D a, Position3D b, Params &&... params)
requires std::is_base_of_v<T, L>
{
const auto node1 = candidateNodeAt(a).first, node2 = candidateNodeAt(b).first;
@@ -80,7 +80,7 @@ public:
template<typename L, typename... Params>
std::shared_ptr<L>
- addLink(glm::vec3 a, glm::vec3 b, Params &&... params)
+ addLink(Position3D a, Position3D b, Params &&... params)
requires std::is_base_of_v<T, L>
{
const auto node1 = nodeAt(a), node2 = nodeAt(b);
@@ -89,12 +89,12 @@ public:
return l;
}
- Link::CCollection candidateStraight(glm::vec3 n1, glm::vec3 n2) override;
- Link::CCollection candidateJoins(glm::vec3, glm::vec3) override;
- Link::CCollection candidateExtend(glm::vec3, glm::vec3) override;
- Link::CCollection addStraight(glm::vec3 n1, glm::vec3 n2) override;
- Link::CCollection addJoins(glm::vec3, glm::vec3) override;
- Link::CCollection addExtend(glm::vec3, glm::vec3) override;
+ Link::CCollection candidateStraight(Position3D n1, Position3D n2) override;
+ Link::CCollection candidateJoins(Position3D, Position3D) override;
+ Link::CCollection candidateExtend(Position3D, Position3D) override;
+ Link::CCollection addStraight(Position3D n1, Position3D n2) override;
+ Link::CCollection addJoins(Position3D, Position3D) override;
+ Link::CCollection addExtend(Position3D, Position3D) override;
[[nodiscard]] float findNodeDirection(Node::AnyCPtr) const override;
diff --git a/game/network/network.impl.h b/game/network/network.impl.h
index 045335f..8e9e85c 100644
--- a/game/network/network.impl.h
+++ b/game/network/network.impl.h
@@ -54,14 +54,14 @@ NetworkOf<T>::findNodeDirection(Node::AnyCPtr n) const
template<typename T>
Link::CCollection
-NetworkOf<T>::candidateStraight(glm::vec3 n1, glm::vec3 n2)
+NetworkOf<T>::candidateStraight(Position3D n1, Position3D n2)
{
return {candidateLink<typename T::StraightLink>(n1, n2)};
}
template<typename T>
Link::CCollection
-NetworkOf<T>::candidateJoins(glm::vec3 start, glm::vec3 end)
+NetworkOf<T>::candidateJoins(Position3D start, Position3D end)
{
if (glm::distance(start, end) < 2.F) {
return {};
@@ -75,7 +75,7 @@ NetworkOf<T>::candidateJoins(glm::vec3 start, glm::vec3 end)
template<typename T>
Link::CCollection
-NetworkOf<T>::candidateExtend(glm::vec3 start, glm::vec3 end)
+NetworkOf<T>::candidateExtend(Position3D start, Position3D end)
{
const auto [cstart, cend, centre] = genCurveDef(start, end, findNodeDirection(candidateNodeAt(start).first));
return {candidateLink<typename T::CurveLink>(cstart, cend, centre)};
@@ -83,14 +83,14 @@ NetworkOf<T>::candidateExtend(glm::vec3 start, glm::vec3 end)
template<typename T>
Link::CCollection
-NetworkOf<T>::addStraight(glm::vec3 n1, glm::vec3 n2)
+NetworkOf<T>::addStraight(Position3D n1, Position3D n2)
{
return {addLink<typename T::StraightLink>(n1, n2)};
}
template<typename T>
Link::CCollection
-NetworkOf<T>::addJoins(glm::vec3 start, glm::vec3 end)
+NetworkOf<T>::addJoins(Position3D start, Position3D end)
{
if (glm::distance(start, end) < 2.F) {
return {};
@@ -103,7 +103,7 @@ NetworkOf<T>::addJoins(glm::vec3 start, glm::vec3 end)
template<typename T>
Link::CCollection
-NetworkOf<T>::addExtend(glm::vec3 start, glm::vec3 end)
+NetworkOf<T>::addExtend(Position3D start, Position3D end)
{
const auto [cstart, cend, centre] = genCurveDef(start, end, findNodeDirection(nodeAt(start)));
return {addLink<typename T::CurveLink>(cstart, cend, centre)};
diff --git a/game/network/rail.h b/game/network/rail.h
index 6684801..4a1932f 100644
--- a/game/network/rail.h
+++ b/game/network/rail.h
@@ -32,7 +32,7 @@ public:
NO_MOVE(RailLink);
protected:
- [[nodiscard]] glm::vec3 vehiclePositionOffset() const override;
+ [[nodiscard]] Position3D vehiclePositionOffset() const override;
[[nodiscard]] static Mesh::Ptr defaultMesh(const std::span<Vertex> vertices);
Mesh::Ptr mesh;
@@ -45,22 +45,22 @@ public:
RailLinkStraight(const Node::Ptr &, const Node::Ptr &);
private:
- RailLinkStraight(Node::Ptr, Node::Ptr, const glm::vec3 & diff);
+ RailLinkStraight(Node::Ptr, Node::Ptr, const Position3D & diff);
};
class RailLinkCurve : public RailLink, public LinkCurve {
public:
- RailLinkCurve(const Node::Ptr &, const Node::Ptr &, glm::vec2);
+ RailLinkCurve(const Node::Ptr &, const Node::Ptr &, Position2D);
private:
- RailLinkCurve(const Node::Ptr &, const Node::Ptr &, glm::vec3, const Arc);
+ RailLinkCurve(const Node::Ptr &, const Node::Ptr &, Position3D, const Arc);
};
class RailLinks : public NetworkOf<RailLink>, public WorldObject {
public:
RailLinks();
- std::shared_ptr<RailLink> addLinksBetween(glm::vec3 start, glm::vec3 end);
+ std::shared_ptr<RailLink> addLinksBetween(Position3D start, Position3D end);
private:
void tick(TickDuration elapsed) override;
diff --git a/game/selectable.h b/game/selectable.h
index 31287d8..9732dca 100644
--- a/game/selectable.h
+++ b/game/selectable.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include <glm/glm.hpp>
#include <special_members.h>
@@ -11,5 +12,5 @@ public:
virtual ~Selectable() = default;
DEFAULT_MOVE_COPY(Selectable);
- [[nodiscard]] virtual bool intersectRay(const Ray &, glm::vec2 *, float *) const = 0;
+ [[nodiscard]] virtual bool intersectRay(const Ray &, Position2D *, float *) const = 0;
};
diff --git a/game/vehicles/railVehicle.h b/game/vehicles/railVehicle.h
index be88142..e034852 100644
--- a/game/vehicles/railVehicle.h
+++ b/game/vehicles/railVehicle.h
@@ -17,7 +17,7 @@ public:
void move(const Train *, float & trailBy);
- [[nodiscard]] bool intersectRay(const Ray &, glm::vec2 *, float *) const override;
+ [[nodiscard]] bool intersectRay(const Ray &, Position2D *, float *) const override;
RailVehicleClassPtr rvClass;
using LV = RailVehicleClass::LocationVertex;
diff --git a/game/vehicles/train.h b/game/vehicles/train.h
index 20c3bc4..7f0bb99 100644
--- a/game/vehicles/train.h
+++ b/game/vehicles/train.h
@@ -27,7 +27,7 @@ public:
return objects.front()->location;
}
- [[nodiscard]] bool intersectRay(const Ray &, glm::vec2 *, float *) const override;
+ [[nodiscard]] bool intersectRay(const Ray &, Position2D *, float *) const override;
void tick(TickDuration elapsed) override;
void doActivity(Go *, TickDuration) override;
diff --git a/gfx/gl/bufferedLocation.h b/gfx/gl/bufferedLocation.h
index 8096489..39d3139 100644
--- a/gfx/gl/bufferedLocation.h
+++ b/gfx/gl/bufferedLocation.h
@@ -8,7 +8,7 @@
class BufferedLocation {
public:
- BufferedLocation(glm::vec3 = {}, glm::vec3 = {});
+ BufferedLocation(Position3D = {}, Rotation3D = {});
BufferedLocation(const Location &);
virtual ~BufferedLocation() = default;
@@ -16,13 +16,13 @@ public:
operator const Location &() const;
- glm::vec3 position() const;
- glm::vec3 rotation() const;
- void setPosition(glm::vec3, bool update = true);
- void setRotation(glm::vec3, bool update = true);
- void setLocation(glm::vec3, glm::vec3);
+ [[nodiscard]] Position3D position() const;
+ [[nodiscard]] Rotation3D rotation() const;
+ void setPosition(Position3D, bool update = true);
+ void setRotation(Rotation3D, bool update = true);
+ void setLocation(Position3D, Rotation3D);
- glm::mat4 getTransform() const;
+ [[nodiscard]] glm::mat4 getTransform() const;
private:
virtual void updateBuffer() = 0;
diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp
index c4c9544..80feab4 100644
--- a/gfx/gl/camera.cpp
+++ b/gfx/gl/camera.cpp
@@ -5,7 +5,7 @@
#include <maths.h>
#include <ray.h>
-Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar) :
+Camera::Camera(Position3D pos, Angle fov, Angle aspect, Distance zNear, Distance zFar) :
position {pos}, forward {::north}, up {::up}, near {zNear}, far {zFar},
projection {glm::perspective(fov, aspect, zNear, zFar)},
viewProjection {projection * glm::lookAt(position, position + forward, up)},
@@ -14,7 +14,7 @@ Camera::Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar)
}
Ray
-Camera::unProject(const glm::vec2 & mouse) const
+Camera::unProject(const ScreenRelCoord & mouse) const
{
static constexpr const glm::vec4 screen {0, 0, 1, 1};
const auto mouseProjection = glm::lookAt(::origin, forward, up);
diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h
index 7956ec3..469df0d 100644
--- a/gfx/gl/camera.h
+++ b/gfx/gl/camera.h
@@ -1,12 +1,13 @@
#pragma once
+#include "config/types.h"
#include <glm/glm.hpp>
#include <maths.h>
#include <ray.h>
class Camera {
public:
- Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar);
+ Camera(Position3D, Angle fov, Angle aspect, Distance zNear, Distance zFar);
[[nodiscard]] glm::mat4
getViewProjection() const
@@ -14,23 +15,23 @@ public:
return viewProjection;
}
- [[nodiscard]] Ray unProject(const glm::vec2 &) const;
+ [[nodiscard]] Ray unProject(const ScreenRelCoord &) const;
void
- setPosition(const glm::vec3 & p)
+ setPosition(const Position3D & p)
{
position = p;
updateView();
}
void
- setForward(const glm::vec3 & f)
+ setForward(const Direction3D & f)
{
setForward(f, upFromForward(f));
}
void
- setForward(const glm::vec3 & f, const glm::vec3 & u)
+ setForward(const Direction3D & f, const Direction3D & u)
{
forward = f;
up = u;
@@ -38,21 +39,21 @@ public:
}
void
- setView(const glm::vec3 & p, const glm::vec3 & f)
+ setView(const Position3D & p, const Direction3D & f)
{
position = p;
setForward(f);
}
void
- setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u)
+ setView(const Position3D & p, const Direction3D & f, const Direction3D & u)
{
position = p;
setView(f, u);
}
void
- lookAt(const glm::vec3 & target)
+ lookAt(const Position3D & target)
{
setForward(glm::normalize(target - position));
}
@@ -71,14 +72,14 @@ public:
[[nodiscard]] std::array<glm::vec4, 4> extentsAtDist(float) const;
- [[nodiscard]] static glm::vec3 upFromForward(const glm::vec3 & forward);
+ [[nodiscard]] static Direction3D upFromForward(const Direction3D & forward);
private:
void updateView();
- glm::vec3 position;
- glm::vec3 forward;
- glm::vec3 up;
+ Position3D position;
+ Direction3D forward;
+ Direction3D up;
float near, far;
glm::mat4 projection;
diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp
index 5799daf..218cf6d 100644
--- a/gfx/gl/sceneRenderer.cpp
+++ b/gfx/gl/sceneRenderer.cpp
@@ -14,7 +14,7 @@ static constexpr const std::array<const glm::i8vec4, 4> displayVAOdata {{
{1, -1, 1, 0},
}};
-SceneRenderer::SceneRenderer(glm::ivec2 s, GLuint o) :
+SceneRenderer::SceneRenderer(ScreenAbsCoord s, GLuint o) :
camera {{-1250.0F, -1250.0F, 35.0F}, quarter_pi, ratio(s), 0.1F, 10000.0F}, size {s}, output {o},
lighting {lighting_vs, lighting_fs}, shadowMapper {{2048, 2048}}
{
diff --git a/gfx/gl/sceneRenderer.h b/gfx/gl/sceneRenderer.h
index 55df84d..87f474b 100644
--- a/gfx/gl/sceneRenderer.h
+++ b/gfx/gl/sceneRenderer.h
@@ -11,18 +11,18 @@
class SceneRenderer {
public:
- explicit SceneRenderer(glm::ivec2 size, GLuint output);
+ explicit SceneRenderer(ScreenAbsCoord size, GLuint output);
void render(const SceneProvider &) const;
- void setAmbientLight(const glm::vec3 & colour) const;
- void setDirectionalLight(const glm::vec3 & colour, const glm::vec3 & direction, const SceneProvider &) const;
+ void setAmbientLight(const RGB & colour) const;
+ void setDirectionalLight(const RGB & colour, const Direction3D & direction, const SceneProvider &) const;
Camera camera;
private:
void renderQuad() const;
- glm::ivec2 size;
+ ScreenAbsCoord size;
GLuint output;
glFrameBuffer gBuffer;
glTexture gPosition, gNormal, gAlbedoSpec, gIllumination;
@@ -39,7 +39,7 @@ private:
DirectionalLightProgram();
using Program::use;
- void setDirectionalLight(const glm::vec3 &, const glm::vec3 &, const std::span<const glm::mat4x4>,
+ void setDirectionalLight(const RGB &, const Direction3D &, const std::span<const glm::mat4x4>,
const std::span<const glm::vec4>, std::size_t maps) const;
private:
diff --git a/gfx/gl/sceneShader.h b/gfx/gl/sceneShader.h
index ead184e..d1c6ef2 100644
--- a/gfx/gl/sceneShader.h
+++ b/gfx/gl/sceneShader.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "program.h"
#include <glArrays.h>
@@ -52,7 +53,7 @@ class SceneShader {
public:
PointLightShader();
- void add(const glm::vec3 & position, const glm::vec3 & colour, const float kq) const;
+ void add(const Position3D & position, const RGB & colour, const float kq) const;
private:
UniformLocation colourLoc;
@@ -65,7 +66,7 @@ class SceneShader {
public:
SpotLightShader();
- void add(const glm::vec3 & position, const glm::vec3 & direction, const glm::vec3 & colour, const float kq,
+ void add(const Position3D & position, const Direction3D & direction, const RGB & colour, const float kq,
const float arc) const;
private:
diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp
index 79b39c0..58f65c4 100644
--- a/gfx/gl/shadowMapper.cpp
+++ b/gfx/gl/shadowMapper.cpp
@@ -15,7 +15,7 @@
#include <tuple>
#include <vector>
-ShadowMapper::ShadowMapper(const glm::ivec2 & s) :
+ShadowMapper::ShadowMapper(const TextureAbsCoord & s) :
fixedPoint {shadowFixedPoint_vs}, dynamicPointInst {shadowDynamicPointInst_vs}, size {s}
{
glBindTexture(GL_TEXTURE_2D, depthMap);
diff --git a/gfx/gl/shadowMapper.h b/gfx/gl/shadowMapper.h
index cd1b975..e5272a3 100644
--- a/gfx/gl/shadowMapper.h
+++ b/gfx/gl/shadowMapper.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "lib/glArrays.h"
#include "program.h"
#include <glm/vec2.hpp>
@@ -11,7 +12,7 @@ class Camera;
class ShadowMapper {
public:
- explicit ShadowMapper(const glm::ivec2 & size);
+ explicit ShadowMapper(const TextureAbsCoord & size);
static constexpr std::size_t SHADOW_BANDS {4};
@@ -21,7 +22,7 @@ public:
size_t maps {};
};
- [[nodiscard]] Definitions update(const SceneProvider &, const glm::vec3 & direction, const Camera &) const;
+ [[nodiscard]] Definitions update(const SceneProvider &, const Direction3D & direction, const Camera &) const;
class FixedPoint : public Program {
public:
@@ -55,9 +56,9 @@ public:
}
private:
- [[nodiscard]] static std::vector<std::array<glm::vec3, 4>> getBandViewExtents(
+ [[nodiscard]] static std::vector<std::array<Position3D, 4>> getBandViewExtents(
const Camera &, const glm::mat4 & lightView);
glFrameBuffer depthMapFBO;
glTexture depthMap;
- glm::ivec2 size;
+ TextureAbsCoord size;
};
diff --git a/gfx/gl/uiShader.h b/gfx/gl/uiShader.h
index 2766af8..362e90c 100644
--- a/gfx/gl/uiShader.h
+++ b/gfx/gl/uiShader.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include "program.h"
#include <cstddef>
#include <glad/gl.h>
@@ -33,7 +34,7 @@ private:
class TextProgram : public UIProgram {
public:
explicit TextProgram(const glm::mat4 & vp);
- void use(const glm::vec3 & colour) const;
+ void use(const RGB & colour) const;
private:
RequiredUniformLocation colorLoc;
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index b7f1bee..f60d158 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -1,4 +1,5 @@
#include "texture.h"
+#include "config/types.h"
#include "glArrays.h"
#include "tga.h"
#include <cache.h>
diff --git a/gfx/models/texture.h b/gfx/models/texture.h
index 1b66c64..5e1b440 100644
--- a/gfx/models/texture.h
+++ b/gfx/models/texture.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include <cache.h>
#include <filesystem>
#include <glArrays.h>
@@ -42,7 +43,7 @@ public:
protected:
static void save(const glTexture &, GLenum, GLenum, uint8_t channels, const char * path, uint8_t tgaFormat);
- static glm::ivec2 getSize(const glTexture &);
+ static TextureAbsCoord getSize(const glTexture &);
glTexture m_texture;
GLenum type;
@@ -53,7 +54,7 @@ public:
TextureAtlas(GLsizei width, GLsizei height, GLuint count);
void bind(GLenum unit = GL_TEXTURE0) const override;
- GLuint add(glm::ivec2 position, glm::ivec2 size, void * data, TextureOptions = {});
+ GLuint add(TextureAbsCoord position, TextureAbsCoord size, void * data, TextureOptions = {});
private:
glTexture m_atlas;
diff --git a/gfx/models/tga.h b/gfx/models/tga.h
index 52db220..3d072fb 100644
--- a/gfx/models/tga.h
+++ b/gfx/models/tga.h
@@ -4,10 +4,11 @@
#include <glm/vec2.hpp>
struct TGAHead {
+ using XY = glm::vec<2, uint16_t>;
uint8_t idLength {}, colorMapType {}, format {};
uint16_t __attribute__((packed)) colorMapFirst {}, colorMapLength {};
uint8_t colorMapEntrySize {};
- glm::vec<2, uint16_t> origin {}, size {};
+ XY origin {}, size {};
uint8_t pixelDepth {};
uint8_t descriptor {};
};
diff --git a/gfx/models/vertex.h b/gfx/models/vertex.h
index 0464ea7..5635fa1 100644
--- a/gfx/models/vertex.h
+++ b/gfx/models/vertex.h
@@ -1,12 +1,12 @@
#pragma once
+#include "config/types.h"
#include <glad/gl.h>
-#include <glm/glm.hpp>
class Vertex {
public:
#ifndef __cpp_aggregate_paren_init
- constexpr Vertex(glm::vec3 pos, glm::vec2 texCoord, glm::vec3 normal, glm::vec4 colour = {}, GLuint material = 0) :
+ constexpr Vertex(Position3D pos, TextureRelCoord texCoord, Normal3D normal, RGBA colour = {}, GLuint material = 0) :
pos {std::move(pos)}, texCoord {std::move(texCoord)}, normal {std::move(normal)}, colour {std::move(colour)},
material {material}
{
@@ -15,9 +15,9 @@ public:
bool operator==(const Vertex &) const = default;
- glm::vec3 pos;
- glm::vec2 texCoord;
- glm::vec3 normal;
- glm::vec4 colour {};
+ Position3D pos {};
+ TextureRelCoord texCoord {};
+ Normal3D normal {};
+ RGBA colour {};
GLuint material {};
};
diff --git a/lib/geometricPlane.h b/lib/geometricPlane.h
index dc8df50..c74beff 100644
--- a/lib/geometricPlane.h
+++ b/lib/geometricPlane.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include <glm/vec3.hpp>
#include <optional>
@@ -9,14 +10,15 @@ class GeometricPlane {
public:
struct DistAndPosition {
float dist;
- glm::vec3 position;
+ Position3D position;
};
enum class PlaneRelation { Above, Below, On };
- glm::vec3 origin, normal;
+ Position3D origin;
+ Normal3D normal;
- PlaneRelation getRelation(glm::vec3 point) const;
- std::optional<DistAndPosition> getRayIntersectPosition(const Ray &) const;
+ [[nodiscard]] PlaneRelation getRelation(Position3D point) const;
+ [[nodiscard]] std::optional<DistAndPosition> getRayIntersectPosition(const Ray &) const;
static bool isIntersect(PlaneRelation a, PlaneRelation b);
};
diff --git a/lib/location.h b/lib/location.h
index 078f5d3..7f2b44d 100644
--- a/lib/location.h
+++ b/lib/location.h
@@ -1,14 +1,16 @@
#pragma once
+#include "config/types.h"
#include <glm/mat4x4.hpp>
-#include <glm/vec3.hpp>
class Location {
public:
- explicit Location(glm::vec3 pos = {}, glm::vec3 rot = {}) : pos {pos}, rot {rot} { }
+#ifndef __cpp_aggregate_paren_init
+ explicit Location(Position3D pos = {}, Rotation3D rot = {}) : pos {pos}, rot {rot} { }
+#endif
- glm::mat4 getTransform() const;
+ [[nodiscard]] glm::mat4 getTransform() const;
- glm::vec3 pos;
- glm::vec3 rot;
+ Position3D pos;
+ Rotation3D rot;
};
diff --git a/lib/maths.h b/lib/maths.h
index b95b706..67b2a15 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include <cmath>
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
@@ -9,7 +10,7 @@
struct Arc : public std::pair<float, float> {
using std::pair<float, float>::pair;
- Arc(const glm::vec3 & centre3, const glm::vec3 & e0p, const glm::vec3 & e1p);
+ Arc(const Position3D & centre3, const Position3D & e0p, const Position3D & e1p);
float
operator[](unsigned int i) const
@@ -18,19 +19,19 @@ struct Arc : public std::pair<float, float> {
}
};
-constexpr const glm::vec3 origin {0, 0, 0};
-constexpr const glm::vec3 up {0, 0, 1};
-constexpr const glm::vec3 down {0, 0, -1};
-constexpr const glm::vec3 north {0, 1, 0};
-constexpr const glm::vec3 south {0, -1, 0};
-constexpr const glm::vec3 east {1, 0, 0};
-constexpr const glm::vec3 west {-1, 0, 0};
+constexpr const Position3D origin {0, 0, 0};
+constexpr const Position3D up {0, 0, 1};
+constexpr const Position3D down {0, 0, -1};
+constexpr const Position3D north {0, 1, 0};
+constexpr const Position3D south {0, -1, 0};
+constexpr const Position3D east {1, 0, 0};
+constexpr const Position3D west {-1, 0, 0};
constexpr auto half_pi {glm::half_pi<float>()};
constexpr auto quarter_pi {half_pi / 2};
constexpr auto pi {glm::pi<float>()};
constexpr auto two_pi {glm::two_pi<float>()};
-glm::mat4 flat_orientation(const glm::vec3 & diff);
+glm::mat4 flat_orientation(const Rotation3D & diff);
// C++ wrapper for C's sincosf, but with references, not pointers
inline auto
@@ -39,10 +40,10 @@ sincosf(float a, float & s, float & c)
return sincosf(a, &s, &c);
}
-inline glm::vec2
+inline Rotation2D
sincosf(float a)
{
- glm::vec2 sc;
+ Rotation2D sc;
sincosf(a, sc.x, sc.y);
return sc;
}
@@ -51,11 +52,11 @@ glm::mat2 rotate_flat(float);
glm::mat4 rotate_roll(float);
glm::mat4 rotate_yaw(float);
glm::mat4 rotate_pitch(float);
-glm::mat4 rotate_yp(glm::vec2);
-glm::mat4 rotate_ypr(glm::vec3);
+glm::mat4 rotate_yp(Rotation2D);
+glm::mat4 rotate_ypr(Rotation3D);
-float vector_yaw(const glm::vec3 & diff);
-float vector_pitch(const glm::vec3 & diff);
+float vector_yaw(const Direction3D & diff);
+float vector_pitch(const Direction3D & diff);
float round_frac(const float & v, const float & frac);
@@ -87,26 +88,26 @@ perspective_divide(glm::vec<4, T, Q> v)
return v / v.w;
}
-constexpr inline glm::vec2
-operator!(const glm::vec3 & v)
+constexpr inline Position2D
+operator!(const Position3D & v)
{
return {v.x, v.y};
}
-constexpr inline glm::vec3
-operator^(const glm::vec2 & v, float z)
+constexpr inline Position3D
+operator^(const Position2D & v, float z)
{
return {v.x, v.y, z};
}
constexpr inline glm::vec4
-operator^(const glm::vec3 & v, float w)
+operator^(const Position3D & v, float w)
{
return {v.x, v.y, v.z, w};
}
-constexpr inline glm::vec3
-operator!(const glm::vec2 & v)
+constexpr inline Position3D
+operator!(const Position2D & v)
{
return v ^ 0.F;
}
@@ -125,15 +126,15 @@ operator||(const glm::vec<L, T, Q> v1, const T v2)
return {v1, v2};
}
-inline glm::vec3
-operator%(const glm::vec3 & p, const glm::mat4 & mutation)
+inline Position3D
+operator%(const Position3D & p, const glm::mat4 & mutation)
{
const auto p2 = mutation * (p ^ 1);
return p2 / p2.w;
}
-inline glm::vec3
-operator%=(glm::vec3 & p, const glm::mat4 & mutation)
+inline Position3D
+operator%=(Position3D & p, const glm::mat4 & mutation)
{
return p = p % mutation;
}
@@ -146,10 +147,10 @@ arc_length(const Arc & arc)
float normalize(float ang);
-std::pair<glm::vec2, bool> find_arc_centre(glm::vec2 start, float entrys, glm::vec2 end, float entrye);
-std::pair<glm::vec2, bool> find_arc_centre(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd);
-std::pair<float, float> find_arcs_radius(glm::vec2 start, float entrys, glm::vec2 end, float entrye);
-float find_arcs_radius(glm::vec2 start, glm::vec2 ad, glm::vec2 end, glm::vec2 bd);
+std::pair<Position2D, bool> find_arc_centre(Position2D start, float entrys, Position2D end, float entrye);
+std::pair<Position2D, bool> find_arc_centre(Position2D start, Position2D ad, Position2D end, Position2D bd);
+std::pair<float, float> find_arcs_radius(Position2D start, float entrys, Position2D end, float entrye);
+float find_arcs_radius(Position2D start, Position2D ad, Position2D end, Position2D bd);
template<typename T>
auto
diff --git a/lib/ray.h b/lib/ray.h
index 9bf47af..bc70c74 100644
--- a/lib/ray.h
+++ b/lib/ray.h
@@ -1,17 +1,20 @@
#pragma once
+#include "config/types.h"
#include <glm/glm.hpp>
#include <span>
class Ray {
public:
- Ray(glm::vec3 start, glm::vec3 direction) : start {start}, direction {direction} { }
+#ifndef __cpp_aggregate_paren_init
+ Ray(Position3D start, Direction3D direction) : start {start}, direction {direction} { }
+#endif
- static Ray fromPoints(glm::vec3, glm::vec3);
+ static Ray fromPoints(Position3D, Position3D);
- glm::vec3 start;
- glm::vec3 direction;
+ Position3D start;
+ Direction3D direction;
- float distanceToLine(const glm::vec3 & a, const glm::vec3 & b) const;
- bool passesCloseToEdges(const std::span<const glm::vec3> positions, float distance) const;
+ [[nodiscard]] float distanceToLine(const Position3D & a, const Position3D & b) const;
+ [[nodiscard]] bool passesCloseToEdges(const std::span<const Position3D> positions, float distance) const;
};
diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp
index 145481e..177ab6a 100644
--- a/test/test-assetFactory.cpp
+++ b/test/test-assetFactory.cpp
@@ -183,14 +183,15 @@ BOOST_AUTO_TEST_CASE(texturePacker_many, *boost::unit_test::timeout(5))
{
std::vector<TexturePacker::Image> images(256);
std::fill(images.begin(), images.end(), TexturePacker::Image {32, 32});
- const auto totalSize = std::accumulate(images.begin(), images.end(), 0U, [](auto t, const auto & i) {
+ const auto totalSize = std::accumulate(images.begin(), images.end(), 0, [](auto t, const auto & i) {
return t + TexturePacker::area(i);
});
TexturePacker tp {images};
BOOST_CHECK_EQUAL(TexturePacker::Size(32, 32), tp.minSize());
const auto result = tp.pack();
BOOST_CHECK_EQUAL(result.first.size(), images.size());
- BOOST_CHECK_GE(TexturePacker::area(result.second), TexturePacker::area(images.front()) * images.size());
+ BOOST_CHECK_GE(TexturePacker::area(result.second),
+ TexturePacker::area(images.front()) * static_cast<GLsizei>(images.size()));
BOOST_CHECK_EQUAL(totalSize, TexturePacker::area(result.second));
}
diff --git a/test/testRenderOutput.h b/test/testRenderOutput.h
index 13c380f..056d029 100644
--- a/test/testRenderOutput.h
+++ b/test/testRenderOutput.h
@@ -1,24 +1,25 @@
#pragma once
+#include "config/types.h"
#include "glArrays.h"
#include <glm/vec2.hpp>
#include <special_members.h>
class TestRenderOutput {
public:
- TestRenderOutput(glm::ivec2 size = {640, 480});
+ explicit TestRenderOutput(TextureAbsCoord size = {640, 480});
virtual ~TestRenderOutput() = default;
NO_MOVE(TestRenderOutput);
NO_COPY(TestRenderOutput);
- const glm::ivec2 size;
+ const TextureAbsCoord size;
glFrameBuffer output;
glRenderBuffer depth;
glTexture outImage;
};
-template<glm::ivec2 Size> class TestRenderOutputSize : public TestRenderOutput {
+template<TextureAbsCoord Size> class TestRenderOutputSize : public TestRenderOutput {
public:
TestRenderOutputSize() : TestRenderOutput {Size} { }
};
diff --git a/test/testStructures.h b/test/testStructures.h
index 6966052..aaaf940 100644
--- a/test/testStructures.h
+++ b/test/testStructures.h
@@ -1,5 +1,6 @@
#pragma once
+#include "config/types.h"
#include <persistence.h>
struct AbsObject : public Persistence::Persistable {
@@ -31,9 +32,9 @@ struct TestObject : public Persistence::Persistable {
float flt {};
std::string str {};
bool bl {};
- glm::vec3 pos {};
+ Position3D pos {};
std::vector<float> flts;
- std::vector<glm::vec3> poss;
+ std::vector<Position3D> poss;
std::vector<std::vector<std::vector<std::string>>> nest;
std::unique_ptr<TestObject> ptr;
std::unique_ptr<AbsObject> aptr;
diff --git a/ui/builders/freeExtend.h b/ui/builders/freeExtend.h
index 55fe7ff..b276426 100644
--- a/ui/builders/freeExtend.h
+++ b/ui/builders/freeExtend.h
@@ -9,5 +9,5 @@ class BuilderFreeExtend : public EditNetwork::Builder {
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;
- std::optional<glm::vec3> p1;
+ std::optional<Position3D> p1;
};
diff --git a/ui/builders/straight.h b/ui/builders/straight.h
index 1cde2b0..cf99a1d 100644
--- a/ui/builders/straight.h
+++ b/ui/builders/straight.h
@@ -9,7 +9,7 @@ class BuilderStraight : public EditNetwork::Builder {
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 create(Network * network, glm::vec3 p1, glm::vec3 p2) const;
+ void create(Network * network, Position3D p1, Position3D p2) const;
- std::optional<glm::vec3> p1;
+ std::optional<Position3D> p1;
};
diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp
index 6c6935c..808e0e4 100644
--- a/ui/gameMainSelector.cpp
+++ b/ui/gameMainSelector.cpp
@@ -14,7 +14,7 @@
#include <typeinfo>
#include <vector>
-GameMainSelector::GameMainSelector(const Camera * c, glm::vec2 size) : UIComponent {{{}, size}}, camera {c} { }
+GameMainSelector::GameMainSelector(const Camera * c, ScreenAbsCoord size) : UIComponent {{{}, size}}, camera {c} { }
constexpr glm::vec2 TargetPos {5, 45};
diff --git a/ui/gameMainSelector.h b/ui/gameMainSelector.h
index 98cdf53..88db34b 100644
--- a/ui/gameMainSelector.h
+++ b/ui/gameMainSelector.h
@@ -1,6 +1,7 @@
#pragma once
#include "SDL_events.h"
+#include "config/types.h"
#include "special_members.h"
#include "uiComponent.h"
#include "worldOverlay.h"
@@ -26,7 +27,7 @@ public:
virtual void render(const SceneShader &) const;
};
- GameMainSelector(const Camera * c, glm::vec2 size);
+ GameMainSelector(const Camera * c, ScreenAbsCoord size);
void render(const UIShader & shader, const Position & pos) const override;
void render(const SceneShader & shader) const override;
diff --git a/ui/manualCameraController.h b/ui/manualCameraController.h
index d15fa76..46655bc 100644
--- a/ui/manualCameraController.h
+++ b/ui/manualCameraController.h
@@ -11,7 +11,7 @@ class Camera;
class ManualCameraController : public CameraController, public UIComponent {
public:
- explicit ManualCameraController(glm::vec2 f) : UIComponent {{}}, focus {f} { }
+ explicit ManualCameraController(Position2D f) : UIComponent {{}}, focus {f} { }
bool handleInput(const SDL_Event & e, const Position &) override;
void render(const UIShader &, const Position & parentPos) const override;
@@ -20,7 +20,7 @@ public:
private:
bool ctrl {false}, mrb {false};
- glm::vec2 focus;
+ Position2D focus;
float direction {quarter_pi};
float dist {40}, pitch {quarter_pi};
};
diff --git a/ui/window.h b/ui/window.h
index 183a65a..8f2b70b 100644
--- a/ui/window.h
+++ b/ui/window.h
@@ -36,7 +36,7 @@ protected:
GLInitHelper();
};
- const glm::ivec2 size;
+ const ScreenAbsCoord size;
SDL_WindowPtr m_window;
SDL_GLContextPtr glContext;
GLInitHelper glInithelper;