summaryrefslogtreecommitdiffstats
path: root/thirdparty/msdfgen/core/SignedDistance.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/msdfgen/core/SignedDistance.hpp')
-rw-r--r--thirdparty/msdfgen/core/SignedDistance.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/thirdparty/msdfgen/core/SignedDistance.hpp b/thirdparty/msdfgen/core/SignedDistance.hpp
new file mode 100644
index 0000000000..62e73c03aa
--- /dev/null
+++ b/thirdparty/msdfgen/core/SignedDistance.hpp
@@ -0,0 +1,38 @@
+
+#pragma once
+
+#include <cmath>
+#include <cfloat>
+#include "base.h"
+
+namespace msdfgen {
+
+/// Represents a signed distance and alignment, which together can be compared to uniquely determine the closest edge segment.
+class SignedDistance {
+
+public:
+ double distance;
+ double dot;
+
+ inline SignedDistance() : distance(-DBL_MAX), dot(0) { }
+ inline SignedDistance(double dist, double d) : distance(dist), dot(d) { }
+
+};
+
+inline bool operator<(const SignedDistance a, const SignedDistance b) {
+ return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);
+}
+
+inline bool operator>(const SignedDistance a, const SignedDistance b) {
+ return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);
+}
+
+inline bool operator<=(const SignedDistance a, const SignedDistance b) {
+ return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot);
+}
+
+inline bool operator>=(const SignedDistance a, const SignedDistance b) {
+ return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);
+}
+
+}