diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-03-23 18:04:57 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-03-23 18:04:57 +0000 |
commit | c6c0d8005880d73b8560bcb10c34a6e8b2da703e (patch) | |
tree | 6e33f8f41154c2731435222856378d2c020893a9 | |
parent | Add helper constructors to Arc (diff) | |
download | ilt-c6c0d8005880d73b8560bcb10c34a6e8b2da703e.tar.bz2 ilt-c6c0d8005880d73b8560bcb10c34a6e8b2da703e.tar.xz ilt-c6c0d8005880d73b8560bcb10c34a6e8b2da703e.zip |
Extract vector_normal helper into lib
-rw-r--r-- | game/geoData.cpp | 8 | ||||
-rw-r--r-- | lib/maths.h | 7 |
2 files changed, 9 insertions, 6 deletions
diff --git a/game/geoData.cpp b/game/geoData.cpp index aaa2548..4273be6 100644 --- a/game/geoData.cpp +++ b/game/geoData.cpp @@ -417,17 +417,13 @@ GeoData::setHeights(const std::span<const GlobalPosition3D> triangleStrip) std::vector<Extrusion> extrusionExtents; std::for_each(boundary.begin(), boundary.end(), [this, &extrusionExtents](const auto boundaryHeh) { - const auto vectorNormal = []<typename T, glm::qualifier Q>(const glm::vec<2, T, Q> & v) -> glm::vec<2, T, Q> { - return {-v.y, v.x}; - }; - const auto boundaryVertex = from_vertex_handle(boundaryHeh); const auto nextBoundaryVertex = to_vertex_handle(boundaryHeh); const auto p0 = point(from_vertex_handle(prev_halfedge_handle(boundaryHeh))); const auto p1 = point(boundaryVertex); const auto p2 = point(nextBoundaryVertex); - const auto e0 = glm::normalize(vectorNormal(RelativePosition2D(p1 - p0))); - const auto e1 = glm::normalize(vectorNormal(RelativePosition2D(p2 - p1))); + const auto e0 = glm::normalize(vector_normal(RelativePosition2D(p1 - p0))); + const auto e1 = glm::normalize(vector_normal(RelativePosition2D(p2 - p1))); const auto doExtrusion = [this](VertexHandle & extrusionVertex, Direction2D direction, GlobalPosition3D boundaryVertex, RelativeDistance vert) { diff --git a/lib/maths.h b/lib/maths.h index 656fefd..63b752a 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -98,6 +98,13 @@ glm::mat4 rotate_ypr(Rotation3D); float vector_yaw(const Direction2D & diff); float vector_pitch(const Direction3D & diff); +template<typename T, glm::qualifier Q> +glm::vec<2, T, Q> +vector_normal(const glm::vec<2, T, Q> & v) +{ + return {-v.y, v.x}; +}; + float round_frac(const float & v, const float & frac); template<typename T> |