change coordinate to use null struct
This commit is contained in:
@@ -15,8 +15,11 @@ class VectorTileLayer;
|
||||
struct pbf;
|
||||
|
||||
struct Coordinate {
|
||||
struct null {};
|
||||
|
||||
Coordinate() : x(0), y(0) {}
|
||||
Coordinate(int16_t x, int16_t y) : x(x), y(y) {}
|
||||
Coordinate(null) : x(std::numeric_limits<int16_t>::min()), y(std::numeric_limits<int16_t>::min()) {}
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
|
||||
@@ -25,10 +28,8 @@ struct Coordinate {
|
||||
}
|
||||
|
||||
inline operator bool() const {
|
||||
return *this == null;
|
||||
return x != std::numeric_limits<int16_t>::min() && y != std::numeric_limits<int16_t>::min();
|
||||
}
|
||||
|
||||
static const Coordinate null;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,7 @@ struct vec2 {
|
||||
|
||||
template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0>
|
||||
inline operator bool() const {
|
||||
return isnan(x) || isnan(y);
|
||||
return !isnan(x) && !isnan(y);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
const Coordinate Coordinate::null(
|
||||
std::numeric_limits<int16_t>::min(),
|
||||
std::numeric_limits<int16_t>::min()
|
||||
);
|
||||
|
||||
VectorTile::VectorTile() {}
|
||||
|
||||
VectorTile::VectorTile(pbf tile) {
|
||||
|
||||
@@ -73,9 +73,9 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices, const Buck
|
||||
CapType beginCap = cap;
|
||||
CapType endCap = closed ? CapType::Butt : cap;
|
||||
|
||||
Coordinate currentVertex = Coordinate::null,
|
||||
prevVertex = Coordinate::null,
|
||||
nextVertex = Coordinate::null;
|
||||
Coordinate currentVertex = Coordinate::null(),
|
||||
prevVertex = Coordinate::null(),
|
||||
nextVertex = Coordinate::null();
|
||||
vec2<double> prevNormal = vec2<double>::null(),
|
||||
nextNormal = vec2<double>::null();
|
||||
|
||||
@@ -102,7 +102,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices, const Buck
|
||||
if (i + 1 < vertices.size()) {
|
||||
nextVertex = vertices[i + 1];
|
||||
} else {
|
||||
nextVertex = Coordinate::null;
|
||||
nextVertex = Coordinate::null();
|
||||
}
|
||||
|
||||
bool segment = false;
|
||||
@@ -180,7 +180,7 @@ void LineBucket::addGeometry(const std::vector<Coordinate>& vertices, const Buck
|
||||
buffer->addDegenerate();
|
||||
}
|
||||
|
||||
if (join == JoinType::Round) prevVertex = Coordinate::null;
|
||||
if (join == JoinType::Round) prevVertex = Coordinate::null();
|
||||
|
||||
prevNormal = { -nextNormal.x, -nextNormal.y };
|
||||
flip = 1;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <llmr/map/settings.hpp>
|
||||
|
||||
#include <llmr/renderer/fill_bucket.hpp>
|
||||
#include <llmr/renderer/line_bucket.hpp>
|
||||
#include <llmr/style/style.hpp>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
Reference in New Issue
Block a user