diff options
author | Yury Melnichek <melnichek@gmail.com> | 2011-10-10 04:09:07 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:25:43 +0300 |
commit | 9a9f76e18510c0fd1608f8e637e4811866373db1 (patch) | |
tree | e4d2c80f9ea5c25bd195365d8559167f0ccbe7e3 /geometry | |
parent | 02bb18b2dabd83ab01c97647da7cd369f7d4c9f6 (diff) |
Fix bug in covering: pass cell depth to CoverObject().
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/covering_utils.hpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/geometry/covering_utils.hpp b/geometry/covering_utils.hpp index 711a4c09a8..0038b6d54b 100644 --- a/geometry/covering_utils.hpp +++ b/geometry/covering_utils.hpp @@ -72,16 +72,20 @@ CellObjectIntersection IntersectCellWithTriangle( template <class CellIdT, class CellIdContainerT, typename IntersectF> void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdContainerT & out, - CellIdT cell) + int cellDepth, CellIdT cell) { - uint64_t const cellArea = my::sq(uint64_t(1 << (CellIdT::DEPTH_LEVELS - 1 - cell.Level()))); + if (cell.Level() == cellDepth - 1) + { + out.push_back(cell); + return; + } + + uint64_t const cellArea = my::sq(uint64_t(1 << (cellDepth - 1 - cell.Level()))); CellObjectIntersection const intersection = intersect(cell); if (intersection == CELL_OBJECT_NO_INTERSECTION) return; - if (intersection == CELL_INSIDE_OBJECT || - cell.Level() == CellIdT::DEPTH_LEVELS - 1 || - cellPenaltyArea >= cellArea) + if (intersection == CELL_INSIDE_OBJECT || cellPenaltyArea >= cellArea) { out.push_back(cell); return; @@ -89,7 +93,7 @@ void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdC buffer_vector<CellIdT, 32> subdiv; for (uint8_t i = 0; i < 4; ++i) - CoverObject(intersect, cellPenaltyArea, subdiv, cell.Child(i)); + CoverObject(intersect, cellPenaltyArea, subdiv, cellDepth, cell.Child(i)); uint64_t subdivArea = 0; for (size_t i = 0; i < subdiv.size(); ++i) |