Skip to content

Commit 31acd3a

Browse files
committed
Fixed a compiler error when enabling CLIPPER2_HI_PRECISION.
1 parent 76fa070 commit 31acd3a

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

CPP/Clipper2Lib/include/clipper2/clipper.core.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
22
* Author : Angus Johnson *
3-
* Date : 13 December 2023 *
3+
* Date : 22 December 2023 *
44
* Website : http://www.angusj.com *
55
* Copyright : Angus Johnson 2010-2023 *
66
* Purpose : Core Clipper Library structures and functions *
@@ -754,21 +754,32 @@ namespace Clipper2Lib
754754
T bb1miny = CC_MIN(ln2a.y, ln2b.y);
755755
T bb1maxx = CC_MAX(ln2a.x, ln2b.x);
756756
T bb1maxy = CC_MAX(ln2a.y, ln2b.y);
757-
T originx = (CC_MIN(bb0maxx, bb1maxx) + CC_MAX(bb0minx, bb1minx)) >> 1;
758-
T originy = (CC_MIN(bb0maxy, bb1maxy) + CC_MAX(bb0miny, bb1miny)) >> 1;
759-
double ln0c = (ln1dy * static_cast<double>(ln1a.x - originx)) +
760-
(ln1dx * static_cast<double>(ln1a.y - originy));
761-
double ln1c = (ln2dy * static_cast<double>(ln2a.x - originx)) +
762-
(ln2dx * static_cast<double>(ln2a.y - originy));
763-
double hitx = ((ln1dx * ln1c) - (ln2dx * ln0c)) / det;
764-
double hity = ((ln2dy * ln0c) - (ln1dy * ln1c)) / det;
757+
765758
if constexpr (std::numeric_limits<T>::is_integer)
766759
{
760+
int64_t originx = (CC_MIN(bb0maxx, bb1maxx) + CC_MAX(bb0minx, bb1minx)) >> 1;
761+
int64_t originy = (CC_MIN(bb0maxy, bb1maxy) + CC_MAX(bb0miny, bb1miny)) >> 1;
762+
double ln0c = (ln1dy * static_cast<double>(ln1a.x - originx)) +
763+
(ln1dx * static_cast<double>(ln1a.y - originy));
764+
double ln1c = (ln2dy * static_cast<double>(ln2a.x - originx)) +
765+
(ln2dx * static_cast<double>(ln2a.y - originy));
766+
double hitx = ((ln1dx * ln1c) - (ln2dx * ln0c)) / det;
767+
double hity = ((ln2dy * ln0c) - (ln1dy * ln1c)) / det;
768+
767769
ip.x = originx + (T)nearbyint(hitx);
768770
ip.y = originy + (T)nearbyint(hity);
769771
}
770772
else
771773
{
774+
double originx = (CC_MIN(bb0maxx, bb1maxx) + CC_MAX(bb0minx, bb1minx)) / 2.0;
775+
double originy = (CC_MIN(bb0maxy, bb1maxy) + CC_MAX(bb0miny, bb1miny)) / 2.0;
776+
double ln0c = (ln1dy * static_cast<double>(ln1a.x - originx)) +
777+
(ln1dx * static_cast<double>(ln1a.y - originy));
778+
double ln1c = (ln2dy * static_cast<double>(ln2a.x - originx)) +
779+
(ln2dx * static_cast<double>(ln2a.y - originy));
780+
double hitx = ((ln1dx * ln1c) - (ln2dx * ln0c)) / det;
781+
double hity = ((ln2dy * ln0c) - (ln1dy * ln1c)) / det;
782+
772783
ip.x = originx + static_cast<T>(hitx);
773784
ip.y = originy + static_cast<T>(hity);
774785
}

0 commit comments

Comments
 (0)