Skip to content

Commit 4034342

Browse files
authored
Merge pull request #1587 from barvirm/ComputeInitialIntersections-distance2
Replaced the use of glm::distance with glm::distance2 to improve performance by avoiding unnecessary square root calculations
2 parents 09416e0 + 8920760 commit 4034342

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/cpp/web-ifc/geometry/operations/boolean-utils/shared-position.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "is-inside-mesh.h"
2525
#include "is-inside-boundary.h"
2626

27+
#define GLM_ENABLE_EXPERIMENTAL
28+
#include <glm/gtx/norm.hpp>
29+
2730
using Vec2 = glm::dvec2;
2831
using Vec3 = glm::dvec3;
2932

@@ -1579,17 +1582,16 @@ namespace fuzzybools
15791582

15801583
inline std::vector<double> ComputeInitialIntersections(Plane &p, SharedPosition &sp, const Line &lineA)
15811584
{
1582-
double size = 1.0E+04; // TODO: this is bad
1585+
double size = 1.0E+08; // TODO: this is bad
15831586

15841587
for (auto &point : sp.points)
15851588
{
1586-
double d = glm::distance(lineA.origin, point.location3D);
1587-
if (size < d)
1588-
{
1589-
size = d;
1590-
}
1589+
const auto d2 = glm::distance2(lineA.origin, point.location3D);
1590+
size = std::max(size, d2);
15911591
}
15921592

1593+
size = std::sqrt(size);
1594+
15931595
auto Astart = lineA.origin + lineA.direction * (size * 2);
15941596
auto Aend = lineA.origin - lineA.direction * (size * 2);
15951597

0 commit comments

Comments
 (0)