From a74ee2960bd8c930b91dbc897c27d134f5f2c2f0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 9 Apr 2023 15:51:47 +0100 Subject: Move remaining split/plane functions to use library --- assetFactory/faceController.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'assetFactory') diff --git a/assetFactory/faceController.cpp b/assetFactory/faceController.cpp index 37aaa4c..b305f1c 100644 --- a/assetFactory/faceController.cpp +++ b/assetFactory/faceController.cpp @@ -2,7 +2,7 @@ #include "collections.hpp" #include "maths.h" #include "modelFactoryMesh.h" -#include +#include "ray.hpp" void FaceController::apply(ModelFactoryMesh & mesh, const StyleStack & parents, const std::string & names, @@ -89,15 +89,11 @@ FaceController::split( for (size_t curIdx = 0; curIdx < vertexRelations.size(); ++curIdx) { const size_t nextIdx = (curIdx + 1) % vertexRelations.size(); const auto ¤t = vertexRelations[curIdx], next = vertexRelations[nextIdx]; - if ((current.second == GeometricPlane::PlaneRelation::Above - && next.second == GeometricPlane::PlaneRelation::Below) - || (current.second == GeometricPlane::PlaneRelation::Below - && next.second == GeometricPlane::PlaneRelation::Above)) { - const auto origin = mesh.point(current.first), dir = glm::normalize(mesh.point(next.first) - origin); - - float dist {}; - glm::intersectRayPlane(origin, dir, split.origin, split.normal, dist); - const auto newv = mesh.add_vertex(origin + (dir * dist)); + if (GeometricPlane::isIntersect(current.second, next.second)) { + const auto ray = Ray::fromPoints(mesh.point(current.first), mesh.point(next.first)); + const auto intersect = split.getRayIntersectPosition(ray); + assert(intersect); + const auto newv = mesh.add_vertex(intersect->position); auto where = vertexRelations.begin(); ++curIdx; std::advance(where, curIdx); -- cgit v1.2.3