Path: blob/master/thirdparty/msdfgen/core/ShapeDistanceFinder.h
9903 views
1#pragma once23#include <vector>4#include "Vector2.hpp"5#include "edge-selectors.h"6#include "contour-combiners.h"78namespace msdfgen {910/// Finds the distance between a point and a Shape. ContourCombiner dictates the distance metric and its data type.11template <class ContourCombiner>12class ShapeDistanceFinder {1314public:15typedef typename ContourCombiner::DistanceType DistanceType;1617// Passed shape object must persist until the distance finder is destroyed!18explicit ShapeDistanceFinder(const Shape &shape);19/// Finds the distance from origin. Not thread-safe! Is fastest when subsequent queries are close together.20DistanceType distance(const Point2 &origin);2122/// Finds the distance between shape and origin. Does not allocate result cache used to optimize performance of multiple queries.23static DistanceType oneShotDistance(const Shape &shape, const Point2 &origin);2425private:26const Shape &shape;27ContourCombiner contourCombiner;28std::vector<typename ContourCombiner::EdgeSelectorType::EdgeCache> shapeEdgeCache;2930};3132typedef ShapeDistanceFinder<SimpleContourCombiner<TrueDistanceSelector> > SimpleTrueShapeDistanceFinder;3334}3536#include "ShapeDistanceFinder.hpp"373839