From 056b4a988c1bc68399cc15bf2860a71f7ef068be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 4 Aug 2014 18:46:43 +0200 Subject: [PATCH] fix boolean operators --- include/mbgl/text/glyph.hpp | 4 ++-- include/mbgl/util/rect.hpp | 2 +- src/renderer/symbol_bucket.cpp | 2 +- src/text/collision.cpp | 6 +++--- src/text/placement.cpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/mbgl/text/glyph.hpp b/include/mbgl/text/glyph.hpp index 4ad2e9367..38f9e116a 100644 --- a/include/mbgl/text/glyph.hpp +++ b/include/mbgl/text/glyph.hpp @@ -16,7 +16,7 @@ GlyphRange getGlyphRange(char32_t glyph); struct GlyphMetrics { operator bool() const { - return width == 0 && height == 0 && advance == 0; + return !(width == 0 && height == 0 && advance == 0); } // Glyph metrics. @@ -35,7 +35,7 @@ struct Glyph { : rect(rect), metrics(metrics) {} operator bool() const { - return !metrics && !rect; + return metrics || rect; } const Rect rect; diff --git a/include/mbgl/util/rect.hpp b/include/mbgl/util/rect.hpp index 4e524b415..dedd4afc9 100644 --- a/include/mbgl/util/rect.hpp +++ b/include/mbgl/util/rect.hpp @@ -15,7 +15,7 @@ struct Rect { return Rect(x * value, y * value, w * value, h * value); } - operator bool() const { return w == 0 || h == 0; } + operator bool() const { return w != 0 && h != 0; } }; } diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index f165515af..2009fe364 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -31,7 +31,7 @@ bool SymbolBucket::hasData() const { return hasTextData() || hasIconData(); } bool SymbolBucket::hasTextData() const { return !text.groups.empty(); } -bool SymbolBucket::hasIconData() const { return !icon.groups.empty() > 0; } +bool SymbolBucket::hasIconData() const { return !icon.groups.empty(); } void SymbolBucket::addGlyphsToAtlas(uint64_t tileid, const std::string stackname, const std::u32string &string, const FontStack &fontStack, diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 70712f065..aa4cf1c7a 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -112,7 +112,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementS const float pad = glyph.padding; if (anchor.x < 0 || anchor.x > 4096 || anchor.y < 0 || anchor.y > 4096) { - return -1; + return 0; } float minScale = std::fmax(minPlacementScale, glyph.minScale); @@ -142,7 +142,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementS // NOTE: this isn't right because there can be glyphs with // the same anchor but differing box offsets. if (na == oa) { - return -1; + return 0; } // todo: unhardcode the 8 = tileExtent/tileSize @@ -175,7 +175,7 @@ float Collision::getPlacementScale(const GlyphBoxes &glyphs, float minPlacementS } if (minPlacementScale > maxPlacementScale) { - return -1; + return 0; } } } diff --git a/src/text/placement.cpp b/src/text/placement.cpp index 448b89293..23e2a0ee8 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -225,7 +225,7 @@ Placement Placement::getGlyphs(Anchor &anchor, const vec2 &origin, const if (!glyph) continue; - if (!(rect && rect.w > 0 && rect.h > 0)) + if (!rect) continue; const float x = (origin.x + shape.x + glyph.metrics.left - buffer + rect.w / 2) * boxScale;