change coordinate to use null struct

This commit is contained in:
Konstantin Käfer
2014-01-28 17:27:20 +01:00
parent 918a68f5dd
commit 4c08a9081b
5 changed files with 11 additions and 14 deletions

View File

@@ -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;
};
/*

View File

@@ -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);
}
};

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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>