#ifndef LLMR_TEXT_TYPES #define LLMR_TEXT_TYPES #include #include #include #include namespace llmr { typedef vec2 CollisionPoint; typedef vec2 CollisionAnchor; typedef std::array PlacementRange; typedef float CollisionAngle; typedef std::vector CollisionAngles; typedef std::array CollisionRange; typedef std::vector CollisionList; typedef std::array CollisionCorners; struct CollisionRect { CollisionPoint tl; CollisionPoint br; inline explicit CollisionRect() {} inline explicit CollisionRect(CollisionPoint::Type ax, CollisionPoint::Type ay, CollisionPoint::Type bx, CollisionPoint::Type by) : tl(ax, ay), br(bx, by) {} inline explicit CollisionRect(const CollisionPoint &tl, const CollisionPoint &br) : tl(tl), br(br) {} }; // These are the glyph boxes that we want to have placed. struct GlyphBox { explicit GlyphBox() {} explicit GlyphBox(const CollisionRect &bbox, const CollisionRect &box, float minScale) : bbox(bbox), box(box), minScale(minScale) {} explicit GlyphBox(const CollisionRect &box, float minScale, float maxScale, const CollisionAnchor &anchor, bool rotate) : anchor(anchor), box(box), rotate(rotate), minScale(minScale), maxScale(maxScale) {} CollisionAnchor anchor; CollisionRect bbox; CollisionRect box; bool rotate = false; float minScale = 0.0f; float maxScale = std::numeric_limits::infinity(); }; typedef std::vector GlyphBoxes; // TODO: Transform the vec2s to vec2 to save bytes struct PlacedGlyph { explicit PlacedGlyph(const vec2 &tl, const vec2 &tr, const vec2 &bl, const vec2 &br, const Rect &tex, float angle, const GlyphBox &glyphBox) : tl(tl), tr(tr), bl(bl), br(br), tex(tex), angle(angle), glyphBox(glyphBox) {} vec2 tl, tr, bl, br; Rect tex; float angle; GlyphBox glyphBox; }; typedef std::vector PlacedGlyphs; // These are the placed boxes contained in the rtree. struct PlacementBox { CollisionAnchor anchor; CollisionRect bbox; CollisionRect box; bool rotate = false; PlacementRange placementRange = {{0.0f, 0.0f}}; float placementScale = 0.0f; float maxScale = std::numeric_limits::infinity(); float padding = 0.0f; }; struct PlacementProperty { explicit PlacementProperty() {} explicit PlacementProperty(float zoom, const PlacementRange &rotationRange) : zoom(zoom), rotationRange(rotationRange) {} inline operator bool() const { return !isnan(zoom) && zoom != std::numeric_limits::infinity() && rotationRange[0] != rotationRange[1]; } float zoom = std::numeric_limits::infinity(); PlacementRange rotationRange = {{0.0f, 0.0f}}; }; } #endif