fix boolean operators

This commit is contained in:
Konstantin Käfer
2014-08-04 18:46:43 +02:00
parent 36181b0922
commit 056b4a988c
5 changed files with 8 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -225,7 +225,7 @@ Placement Placement::getGlyphs(Anchor &anchor, const vec2<float> &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;