From f9f6e353779d6893d0e3745fb9dd1f3257b804ea Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Tue, 30 Aug 2016 10:46:37 +0200 Subject: [core] #6055 - naive attempt to rotate query box --- src/mbgl/text/collision_tile.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mbgl/text/collision_tile.cpp b/src/mbgl/text/collision_tile.cpp index 982dff1688..272d8834b9 100644 --- a/src/mbgl/text/collision_tile.cpp +++ b/src/mbgl/text/collision_tile.cpp @@ -159,8 +159,23 @@ std::vector CollisionTile::queryRenderedSymbols(const mapbox: std::unordered_map> sourceLayerFeatures; auto anchor = util::matrixMultiply(rotationMatrix, convertPoint(box.min)); - CollisionBox queryBox(anchor, 0, 0, box.max.x - box.min.x, box.max.y - box.min.y, scale); - auto predicates = bgi::intersects(getTreeBox(anchor, queryBox)); + + const Point tl = { 0, 0 }; + const Point tr = { float(box.max.x - box.min.x), 0 }; + const Point bl = { 0, float(box.max.y - box.min.y) }; + const Point br = { float(box.max.x - box.min.x), float(box.max.y - box.min.y) }; + const Point rtl = util::matrixMultiply(rotationMatrix, tl); + const Point rtr = util::matrixMultiply(rotationMatrix, tr); + const Point rbl = util::matrixMultiply(rotationMatrix, bl); + const Point rbr = util::matrixMultiply(rotationMatrix, br); + CollisionBox queryBox(anchor, + ::fmin(::fmin(rtl.x, rtr.x), ::fmin(rbl.x, rbr.x)), + ::fmin(::fmin(rtl.y, rtr.y), ::fmin(rbl.y, rbr.y)), + ::fmax(::fmax(rtl.x, rtr.x), ::fmax(rbl.x, rbr.x)), + ::fmax(::fmax(rtl.y, rtr.y), ::fmax(rbl.y, rbr.y)), + scale); + Box treeBox = getTreeBox(anchor, queryBox); + auto predicates = bgi::intersects(treeBox); auto fn = [&] (const Tree& tree_) { for (auto it = tree_.qbegin(predicates); it != tree_.qend(); ++it) { -- cgit v1.2.1