summaryrefslogtreecommitdiff
path: root/game/network/link.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-11-26 13:51:33 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-11-26 14:14:13 +0000
commit7fba471728f2216d7e3b7900297fc3b3531e286c (patch)
tree5caef3b2efc23aefccb215ec9005cd8e7d2e91b8 /game/network/link.cpp
parentFix todo for handling a terrain walk from outside the mesh (diff)
parentModel positions as integers (diff)
downloadilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.bz2
ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.xz
ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.zip
Merge branch 'ints' into terrain
Conflicts fix, compiles, some test failures remain. Trees not added, possibility of OM invalid handle assertion failures, normals broken due to integer overflow in Newell's method.
Diffstat (limited to 'game/network/link.cpp')
-rw-r--r--game/network/link.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/game/network/link.cpp b/game/network/link.cpp
index bb27a52..498afe4 100644
--- a/game/network/link.cpp
+++ b/game/network/link.cpp
@@ -8,10 +8,10 @@
Link::Link(End a, End b, float l) : ends {{std::move(a), std::move(b)}}, length {l} { }
-LinkCurve::LinkCurve(glm::vec3 c, float r, Arc a) : centreBase {c}, radius {r}, arc {std::move(a)} { }
+LinkCurve::LinkCurve(Position3D c, float r, Arc a) : centreBase {c}, radius {r}, arc {std::move(a)} { }
bool
-operator<(const glm::vec3 & a, const glm::vec3 & b)
+operator<(const Position3D & a, const Position3D & b)
{
// NOLINTNEXTLINE(hicpp-use-nullptr,modernize-use-nullptr)
return std::tie(a.x, a.y, a.z) < std::tie(b.x, b.y, b.z);
@@ -48,7 +48,7 @@ LinkCurve::positionAt(float dist, unsigned char start) const
const auto ang {as.first + ((as.second - as.first) * frac)};
const auto relPos {!sincosf(ang) * radius};
const auto relClimb {vehiclePositionOffset()
- + glm::vec3 {0, 0, es.first->pos.z - centreBase.z + ((es.second->pos.z - es.first->pos.z) * frac)}};
+ + Position3D {0, 0, es.first->pos.z - centreBase.z + ((es.second->pos.z - es.first->pos.z) * frac)}};
const auto pitch {vector_pitch({0, 0, (es.second->pos.z - es.first->pos.z) / length})};
return Location {relPos + relClimb + centreBase, {pitch, normalize(ang + dirOffset[start]), 0}};
}
@@ -60,14 +60,14 @@ LinkCurve::intersectRay(const Ray & ray) const
const auto & e1p {ends[1].node->pos};
const auto slength = round_frac(length / 2.F, 5.F);
const auto segs = std::round(15.F * slength / std::pow(radius, 0.7F));
- const auto step {glm::vec3 {arc_length(arc), e1p.z - e0p.z, slength} / segs};
+ const auto step {Position3D {arc_length(arc), e1p.z - e0p.z, slength} / segs};
const auto trans {glm::translate(centreBase)};
auto segCount = static_cast<std::size_t>(std::lround(segs)) + 1;
- std::vector<glm::vec3> points;
+ std::vector<Position3D> points;
points.reserve(segCount);
- for (glm::vec3 swing = {arc.first, centreBase.z - e0p.z, 0.F}; segCount; swing += step, --segCount) {
- const auto t {trans * glm::rotate(half_pi - swing.x, up) * glm::translate(glm::vec3 {radius, 0.F, swing.y})};
+ for (Position3D swing = {arc.first, centreBase.z - e0p.z, 0.F}; segCount; swing += step, --segCount) {
+ const auto t {trans * glm::rotate(half_pi - swing.x, up) * glm::translate(Position3D {radius, 0.F, swing.y})};
points.emplace_back(t * glm::vec4 {0, 0, 0, 1});
}
return ray.passesCloseToEdges(points, 1.F);