diff options
-rw-r--r-- | application/main.cpp | 9 | ||||
-rw-r--r-- | game/vehicles/railVehicle.cpp | 2 | ||||
-rw-r--r-- | game/vehicles/railVehicle.h | 2 | ||||
-rw-r--r-- | game/vehicles/train.cpp | 2 | ||||
-rw-r--r-- | game/vehicles/train.h | 2 | ||||
-rw-r--r-- | gfx/gl/bufferedLocation.cpp | 4 | ||||
-rw-r--r-- | gfx/gl/camera.cpp | 4 | ||||
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 2 | ||||
-rw-r--r-- | gfx/models/vertex.h | 9 | ||||
-rw-r--r-- | lib/maths.h | 13 | ||||
-rw-r--r-- | test/test-maths.cpp | 20 |
11 files changed, 35 insertions, 34 deletions
diff --git a/application/main.cpp b/application/main.cpp index 600bbe3..adaec9b 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -47,10 +47,11 @@ public: { auto rl = world.create<RailLinks>(); - const Position3D 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}; - const Position3D s {-1100000, -500000, 15000}, t {-1100000, -450000, 15000}, u {-1000000, -400000, 15000}; + 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); diff --git a/game/vehicles/railVehicle.cpp b/game/vehicles/railVehicle.cpp index 30b615c..7e4b1ee 100644 --- a/game/vehicles/railVehicle.cpp +++ b/game/vehicles/railVehicle.cpp @@ -44,7 +44,7 @@ RailVehicle::move(const Train * t, float & trailBy) } bool -RailVehicle::intersectRay(const Ray & ray, Position2D * baryPos, float * distance) const +RailVehicle::intersectRay(const Ray & ray, BaryPosition * baryPos, float * distance) const { constexpr const auto X = 1350.F; const auto Y = this->rvClass->length / 2.F; diff --git a/game/vehicles/railVehicle.h b/game/vehicles/railVehicle.h index 20d1ea1..8cbc49d 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 &, Position2D *, float *) const override; + [[nodiscard]] bool intersectRay(const Ray &, BaryPosition *, float *) const override; RailVehicleClassPtr rvClass; using LV = RailVehicleClass::LocationVertex; diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp index 4aa24dc..13905a3 100644 --- a/game/vehicles/train.cpp +++ b/game/vehicles/train.cpp @@ -20,7 +20,7 @@ Train::getBogiePosition(float linkDist, float dist) const } bool -Train::intersectRay(const Ray & ray, Position2D * baryPos, float * distance) const +Train::intersectRay(const Ray & ray, BaryPosition * baryPos, float * distance) const { return applyOne(&RailVehicle::intersectRay, ray, baryPos, distance) != end(); } diff --git a/game/vehicles/train.h b/game/vehicles/train.h index 7f0bb99..c77cd23 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 &, Position2D *, float *) const override; + [[nodiscard]] bool intersectRay(const Ray &, BaryPosition *, float *) const override; void tick(TickDuration elapsed) override; void doActivity(Go *, TickDuration) override; diff --git a/gfx/gl/bufferedLocation.cpp b/gfx/gl/bufferedLocation.cpp index d6a63b9..f1bedfe 100644 --- a/gfx/gl/bufferedLocation.cpp +++ b/gfx/gl/bufferedLocation.cpp @@ -25,7 +25,7 @@ BufferedLocation::position() const return loc.pos; } -Position3D +Rotation3D BufferedLocation::rotation() const { return loc.rot; @@ -41,7 +41,7 @@ BufferedLocation::setPosition(GlobalPosition3D p, bool update) } void -BufferedLocation::setRotation(Position3D r, bool update) +BufferedLocation::setRotation(Rotation3D r, bool update) { loc.rot = r; if (update) { diff --git a/gfx/gl/camera.cpp b/gfx/gl/camera.cpp index 9f40998..d362b94 100644 --- a/gfx/gl/camera.cpp +++ b/gfx/gl/camera.cpp @@ -17,14 +17,14 @@ Ray Camera::unProject(const ScreenRelCoord & mouse) const { static constexpr const glm::vec4 screen {0, 0, 1, 1}; - const auto mouseProjection = glm::lookAt(::origin, forward, up); + const auto mouseProjection = glm::lookAt({}, forward, up); return {position, glm::normalize(glm::unProject(mouse || 1.F, mouseProjection, projection, screen))}; } void Camera::updateView() { - viewProjection = projection * glm::lookAt(origin, forward, up); + viewProjection = projection * glm::lookAt({}, forward, up); inverseViewProjection = glm::inverse(viewProjection); } diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 6c8400e..1498bb0 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -130,7 +130,7 @@ ShadowMapper::update(const SceneProvider & scene, const Direction3D & dir, const glClear(GL_DEPTH_BUFFER_BIT); glCullFace(GL_FRONT); - const auto lightViewDir = glm::lookAt(origin, dir, up); + const auto lightViewDir = glm::lookAt({}, dir, up); const auto lightViewPoint = camera.getPosition(); const auto bandViewExtents = getBandViewExtents(camera, lightViewDir); diff --git a/gfx/models/vertex.h b/gfx/models/vertex.h index 5635fa1..3c6215f 100644 --- a/gfx/models/vertex.h +++ b/gfx/models/vertex.h @@ -6,16 +6,17 @@ class Vertex { public: #ifndef __cpp_aggregate_paren_init - 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} + constexpr Vertex( + RelativePosition3D 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} { } #endif bool operator==(const Vertex &) const = default; - Position3D pos {}; + RelativePosition3D pos {}; TextureRelCoord texCoord {}; Normal3D normal {}; RGBA colour {}; diff --git a/lib/maths.h b/lib/maths.h index ba8c0e6..c1bf61a 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -21,13 +21,12 @@ struct Arc : public std::pair<float, float> { } }; -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 const RelativePosition3D up {0, 0, 1}; +constexpr const RelativePosition3D down {0, 0, -1}; +constexpr const RelativePosition3D north {0, 1, 0}; +constexpr const RelativePosition3D south {0, -1, 0}; +constexpr const RelativePosition3D east {1, 0, 0}; +constexpr const RelativePosition3D 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>()}; diff --git a/test/test-maths.cpp b/test/test-maths.cpp index ede884d..b363c17 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(test_find_arcs_radius) struct TestLinkStraight : public LinkStraight { explicit TestLinkStraight(glm::vec3 v) : - Link {{std::make_shared<Node>(origin), vector_yaw(v)}, {std::make_shared<Node>(v), vector_yaw(-v)}, + Link {{std::make_shared<Node>(Position3D {}), vector_yaw(v)}, {std::make_shared<Node>(v), vector_yaw(-v)}, glm::length(v)} { } @@ -197,7 +197,7 @@ BOOST_DATA_TEST_CASE(straight1, const TestLinkStraight l(v); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {origin}); + BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {}); BOOST_CHECK_EQUAL(p.rot, glm::vec3(0, angFor, 0)); } { @@ -228,11 +228,11 @@ BOOST_DATA_TEST_CASE(curve1, e1, ctr, angFor, angBack) { { // One-way... - const TestLinkCurve l(origin, e1, ctr); + const TestLinkCurve l({}, e1, ctr); BOOST_CHECK_EQUAL(l.radius, 1.F); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, RelativePosition3D {}); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angFor, 0)); } { @@ -243,18 +243,18 @@ BOOST_DATA_TEST_CASE(curve1, } { // The other way... - const TestLinkCurve l(e1, origin, ctr); + const TestLinkCurve l(e1, {}, ctr); BOOST_CHECK_EQUAL(l.radius, 1.F); { const auto p = l.positionAt(0, 0); - const auto angForReversed = normalize(vector_yaw(origin - e1) * 2 - angFor); + const auto angForReversed = normalize(vector_yaw(-e1) * 2 - angFor); BOOST_CHECK_CLOSE_VECI(RelativePosition3D {p.pos}, e1); BOOST_CHECK_CLOSE_VECI(p.rot, glm::vec3(0, angForReversed, 0)); } { const auto p = l.positionAt(0, 1); - const auto angBackReversed = normalize(vector_yaw(e1 - origin) * 2 - angBack); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); + const auto angBackReversed = normalize(vector_yaw(e1) * 2 - angBack); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, Position3D {}); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBackReversed, 0)); } } @@ -262,10 +262,10 @@ BOOST_DATA_TEST_CASE(curve1, BOOST_AUTO_TEST_CASE(camera_clicks) { - Camera camera {::origin, ::half_pi, 1.25F, 1000, 10000000}; + Camera camera {{}, ::half_pi, 1.25F, 1000, 10000000}; constexpr float centre {0.5F}, right {0.9F}, left {0.1F}, top {1.F}, bottom {0.F}; camera.setForward(::north); - BOOST_CHECK_EQUAL(camera.unProject({centre, centre}).start, ::origin); + BOOST_CHECK_EQUAL(camera.unProject({centre, centre}).start, RelativePosition3D {}); BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, ::north); BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}).direction, glm::normalize(::north + ::west)); BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}).direction, glm::normalize(::north + ::east)); |