Path: blob/master/thirdparty/msdfgen/core/SignedDistance.hpp
9903 views
1#pragma once23#include <cmath>4#include <cfloat>5#include "base.h"67namespace msdfgen {89/// Represents a signed distance and alignment, which together can be compared to uniquely determine the closest edge segment.10class SignedDistance {1112public:13double distance;14double dot;1516inline SignedDistance() : distance(-DBL_MAX), dot(0) { }17inline SignedDistance(double dist, double d) : distance(dist), dot(d) { }1819};2021inline bool operator<(const SignedDistance a, const SignedDistance b) {22return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);23}2425inline bool operator>(const SignedDistance a, const SignedDistance b) {26return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);27}2829inline bool operator<=(const SignedDistance a, const SignedDistance b) {30return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot);31}3233inline bool operator>=(const SignedDistance a, const SignedDistance b) {34return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);35}3637}383940