| 14 | {} |
| 15 | |
| 16 | void BaseGrid::addPoint(Point& p) |
| 17 | { |
| 18 | if (sampling()) |
| 19 | { |
| 20 | handleSamplePoint(p); |
| 21 | return; |
| 22 | } |
| 23 | // find the hexagon that the point is contained within |
| 24 | HexId h = findHexagon(p); |
| 25 | |
| 26 | // add the hexagon to the grid, and increment its count if it exists. |
| 27 | int count = increment(h); |
| 28 | |
| 29 | // if the hexagon of interest has reached the density threshold, we see if it |
| 30 | // has neighbors at edge 0. If not, it's added to our list of possible starting points |
| 31 | // for path finding (m_possibleRoots). If the hexagon at edge 3 was in m_possibleRoots we |
| 32 | // remove it since it no longer has a non-dense neighbor at edge 0. |
| 33 | if (count == m_denseLimit) |
| 34 | { |
| 35 | HexId above = edgeHex(h, 0); |
| 36 | HexId below = edgeHex(h, 3); |
| 37 | if (!isDense(above)) |
| 38 | addRoot(h); |
| 39 | removeRoot(below); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | void BaseGrid::setHexes(const std::vector<HexId>& ids) |
| 44 | { |