diff --git a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp index b7454db77e..f309fe4673 100644 --- a/src/aliceVision/fuseCut/DelaunayGraphCut.cpp +++ b/src/aliceVision/fuseCut/DelaunayGraphCut.cpp @@ -1277,7 +1277,7 @@ DelaunayGraphCut::GeometryIntersection DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection& inGeometry, const Point3d& originPt, const Point3d& dirVect, Point3d& intersectPt, - const float epsilon, const Point3d& lastIntersectPt) const + const double epsilonFactor, const Point3d& lastIntersectPt) const { switch (inGeometry.type) @@ -1295,7 +1295,7 @@ DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection const Facet intersectionFacet(tetrahedronIndex, i); - const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, intersectionFacet, intersectPt, epsilon, &lastIntersectPt); + const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, intersectionFacet, intersectPt, epsilonFactor, &lastIntersectPt); if (result.type != EGeometryType::None) return result; } @@ -1315,7 +1315,7 @@ DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection // Define the facet to intersect const Facet facet(adjCellIndex, localVertexIndex); - const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilon, &lastIntersectPt); + const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilonFactor, &lastIntersectPt); if (result.type != EGeometryType::None) return result; } @@ -1339,7 +1339,7 @@ DelaunayGraphCut::intersectNextGeom(const DelaunayGraphCut::GeometryIntersection for (const Facet& facet : opositeFacets) { - const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilon, &lastIntersectPt); + const GeometryIntersection result = rayIntersectTriangle(originPt, dirVect, facet, intersectPt, epsilonFactor, &lastIntersectPt); if (result.type != EGeometryType::None) return result; } @@ -1358,7 +1358,7 @@ DelaunayGraphCut::GeometryIntersection DelaunayGraphCut::rayIntersectTriangle(co const Point3d& DirVec, const DelaunayGraphCut::Facet& facet, Point3d& intersectPt, - const float epsilon, const Point3d* lastIntersectPt) const + const double epsilonFactor, const Point3d* lastIntersectPt) const { const VertexIndex AvertexIndex = getVertexIndex(facet, 0); const VertexIndex BvertexIndex = getVertexIndex(facet, 1); @@ -1368,6 +1368,7 @@ DelaunayGraphCut::GeometryIntersection DelaunayGraphCut::rayIntersectTriangle(co const Point3d* B = &_verticesCoords[BvertexIndex]; const Point3d* C = &_verticesCoords[CvertexIndex]; + const double epsilon = std::min(std::min((*A - *B).size(), (*B - *C).size()), (*A - *C).size()) * epsilonFactor; Point3d tempIntersectPt; const Point2d triangleUv = getLineTriangleIntersectBarycCoords(&tempIntersectPt, A, B, C, &originPt, &DirVec); diff --git a/src/aliceVision/fuseCut/DelaunayGraphCut.hpp b/src/aliceVision/fuseCut/DelaunayGraphCut.hpp index 478e5c79be..af96720e60 100644 --- a/src/aliceVision/fuseCut/DelaunayGraphCut.hpp +++ b/src/aliceVision/fuseCut/DelaunayGraphCut.hpp @@ -378,12 +378,13 @@ class DelaunayGraphCut * @param originPt ray origin point * @param dirVect ray direction * @param intersectPt a reference that will store the computed intersection point for the intersected geometry - * @param epsilon used to define the boundary when we have to consider either a collision with an edge/vertex or a facet + * @param epsilonFactor a multiplicative factor on the smaller side of the facet used to define the boundary when we + * have to consider either a collision with an edge/vertex or a facet. * @param lastIntersectPt constant reference to the last intersection point used to test the direction. * @return */ GeometryIntersection intersectNextGeom(const GeometryIntersection& inGeometry, const Point3d& originPt, - const Point3d& dirVect, Point3d& intersectPt, const float epsilon, const Point3d& lastIntersectPt) const; + const Point3d& dirVect, Point3d& intersectPt, const double epsilonFactor, const Point3d& lastIntersectPt) const; /** * @brief Function that returns the next geometry intersected by the ray on a given facet or None if there are no intersected geometry. @@ -393,12 +394,13 @@ class DelaunayGraphCut * @param DirVec ray direction * @param facet the given facet to intersect with * @param intersectPt a reference that will store the computed intersection point for the next intersecting geometry - * @param epsilon used to define the boundary when we have to consider either a collision with an edge/vertex or a facet + * @param epsilonFactor a multiplicative factor on the smaller side of the facet used to define the boundary when we + * have to consider either a collision with an edge/vertex or a facet. * @param lastIntersectPt pointer to the last intersection point used to test the direction (if not nulllptr) * @return */ GeometryIntersection rayIntersectTriangle(const Point3d& originPt, const Point3d& DirVec, const Facet& facet, - Point3d& intersectPt, const float epsilon, const Point3d* lastIntersectPt = nullptr) const; + Point3d& intersectPt, const double epsilonFactor, const Point3d* lastIntersectPt = nullptr) const; float distFcn(float maxDist, float dist, float distFcnHeight) const;