summaryrefslogtreecommitdiff
path: root/thirdparty/msdfgen/core/SignedDistance.cpp
blob: 18c9d2c42446e93147d0c374e62009a420784db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#include "SignedDistance.h"

#include <cmath>

namespace msdfgen {

const SignedDistance SignedDistance::INFINITE(-1e240, 1);

SignedDistance::SignedDistance() : distance(-1e240), dot(1) { }

SignedDistance::SignedDistance(double dist, double d) : distance(dist), dot(d) { }

bool operator<(SignedDistance a, SignedDistance b) {
    return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);
}

bool operator>(SignedDistance a, SignedDistance b) {
    return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);
}

bool operator<=(SignedDistance a, SignedDistance b) {
    return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot);
}

bool operator>=(SignedDistance a, SignedDistance b) {
    return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);
}

}