From 519ebadf219ef3b6b75dd84842ef5b56589c4c3b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 Jun 2024 14:02:42 +0100 Subject: Remove conflicting glm::vec operators % and %= already exist and abusing them for simplifying perspective multiplication was always a bad idea. Here they just become named functions. --- assetFactory/faceController.cpp | 2 +- assetFactory/use.cpp | 2 +- lib/maths.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index 10a0c1e..3f75b38 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -53,7 +53,7 @@ FaceController::extrude(ModelFactoryMesh & mesh, const std::string & faceName, O // create new vertices const auto vertices = baseVertices * [&mesh, mutation = getMatrix(), centre = mesh.calc_face_centroid(faceHandle)](auto && v) { - return mesh.add_vertex(centre + ((mesh.point(v) - centre) % mutation)); + return mesh.add_vertex(centre + perspectiveMultiply((mesh.point(v) - centre), mutation)); }; // get new faces names const auto vertexCount = baseVertices.size(); diff --git a/assetFactory/use.cpp b/assetFactory/use.cpp index d5ea39d..42bc703 100644 --- a/assetFactory/use.cpp +++ b/assetFactory/use.cpp @@ -15,7 +15,7 @@ Use::createMesh(ModelFactoryMesh & mesh, Scale3D levelOfDetailFactor) const const auto fvr = mesh.fv_range(f.second); for (const auto & v : fvr) { if (!vs.contains(v)) { - mesh.point(v) %= m; + perspectiveApply(mesh.point(v), m); vs.insert(v); } } diff --git a/lib/maths.h b/lib/maths.h index 63b752a..018ef0e 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -176,7 +176,7 @@ operator||(const glm::vec v1, const T v2) template inline constexpr glm::vec -operator%(const glm::vec & p, const glm::mat & mutation) +perspectiveMultiply(const glm::vec & p, const glm::mat & mutation) { const auto p2 = mutation * (p || T(1)); return p2 / p2.w; @@ -184,9 +184,9 @@ operator%(const glm::vec & p, const glm::mat & muta template inline constexpr glm::vec -operator%=(glm::vec & p, const glm::mat & mutation) +perspectiveApply(glm::vec & p, const glm::mat & mutation) { - return p = p % mutation; + return p = perspectiveMultiply(p, mutation); } float normalize(float ang); -- cgit v1.2.3