diff --git a/source/simulation2/components/CCmpPathfinder_Vertex.cpp b/source/simulation2/components/CCmpPathfinder_Vertex.cpp
index 1ab8932..55400d0 100644
a
|
b
|
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
577 | 577 | vertexes.push_back(end); |
578 | 578 | const size_t GOAL_VERTEX_ID = 1; |
579 | 579 | |
580 | | // Add terrain obstructions |
581 | | { |
582 | | u16 i0, j0, i1, j1; |
583 | | Pathfinding::NearestNavcell(rangeXMin, rangeZMin, i0, j0, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); |
584 | | Pathfinding::NearestNavcell(rangeXMax, rangeZMax, i1, j1, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); |
585 | | AddTerrainEdges(edges, vertexes, i0, j0, i1, j1, passClass, *m_TerrainOnlyGrid); |
586 | | } |
587 | | |
588 | 580 | // Find all the obstruction squares that might affect us |
589 | 581 | CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); |
590 | 582 | std::vector<ICmpObstructionManager::ObstructionSquare> squares; |
… |
… |
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
623 | 615 | vert.quadInward = QUADRANT_NONE; |
624 | 616 | vert.quadOutward = QUADRANT_ALL; |
625 | 617 | vert.p.X = center.X - hd0.Dot(u); vert.p.Y = center.Y + hd0.Dot(v); if (aa) vert.quadInward = QUADRANT_BR; vertexes.push_back(vert); |
| 618 | if (vert.p.X < rangeXMin) rangeXMin = vert.p.X; if (vert.p.Y < rangeZMin) rangeZMin = vert.p.Y; |
| 619 | if (vert.p.X > rangeXMax) rangeXMax = vert.p.X; if (vert.p.Y > rangeZMax) rangeZMax = vert.p.Y; |
626 | 620 | vert.p.X = center.X - hd1.Dot(u); vert.p.Y = center.Y + hd1.Dot(v); if (aa) vert.quadInward = QUADRANT_TR; vertexes.push_back(vert); |
| 621 | if (vert.p.X < rangeXMin) rangeXMin = vert.p.X; if (vert.p.Y < rangeZMin) rangeZMin = vert.p.Y; |
| 622 | if (vert.p.X > rangeXMax) rangeXMax = vert.p.X; if (vert.p.Y > rangeZMax) rangeZMax = vert.p.Y; |
627 | 623 | vert.p.X = center.X + hd0.Dot(u); vert.p.Y = center.Y - hd0.Dot(v); if (aa) vert.quadInward = QUADRANT_TL; vertexes.push_back(vert); |
| 624 | if (vert.p.X < rangeXMin) rangeXMin = vert.p.X; if (vert.p.Y < rangeZMin) rangeZMin = vert.p.Y; |
| 625 | if (vert.p.X > rangeXMax) rangeXMax = vert.p.X; if (vert.p.Y > rangeZMax) rangeZMax = vert.p.Y; |
628 | 626 | vert.p.X = center.X + hd1.Dot(u); vert.p.Y = center.Y - hd1.Dot(v); if (aa) vert.quadInward = QUADRANT_BL; vertexes.push_back(vert); |
| 627 | if (vert.p.X < rangeXMin) rangeXMin = vert.p.X; if (vert.p.Y < rangeZMin) rangeZMin = vert.p.Y; |
| 628 | if (vert.p.X > rangeXMax) rangeXMax = vert.p.X; if (vert.p.Y > rangeZMax) rangeZMax = vert.p.Y; |
629 | 629 | |
630 | 630 | // Add the edges: |
631 | 631 | |
… |
… |
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
650 | 650 | // to reduce the search space |
651 | 651 | } |
652 | 652 | |
| 653 | // Add terrain obstructions |
| 654 | { |
| 655 | u16 i0, j0, i1, j1; |
| 656 | Pathfinding::NearestNavcell(rangeXMin, rangeZMin, i0, j0, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); |
| 657 | Pathfinding::NearestNavcell(rangeXMax, rangeZMax, i1, j1, m_MapSize*Pathfinding::NAVCELLS_PER_TILE, m_MapSize*Pathfinding::NAVCELLS_PER_TILE); |
| 658 | AddTerrainEdges(edges, vertexes, i0, j0, i1, j1, passClass, *m_TerrainOnlyGrid); |
| 659 | } |
| 660 | |
653 | 661 | // Clip out vertices that are inside an edgeSquare (i.e. trivially unreachable) |
654 | 662 | for (size_t i = 0; i < edgeSquares.size(); ++i) |
655 | 663 | { |
… |
… |
void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
|
829 | 837 | continue; |
830 | 838 | } |
831 | 839 | |
832 | | bool visible = true; |
833 | | u16 i, j; |
834 | | Pathfinding::NearestNavcell(vertexes[curr.id].p.X, vertexes[curr.id].p.Y, i, j, m_Grid->m_W, m_Grid->m_H); |
835 | | if (!IS_PASSABLE(m_Grid->get(i, j), passClass)) |
836 | | { |
837 | | Pathfinding::NearestNavcell(npos.X, npos.Y, i, j, m_Grid->m_W, m_Grid->m_H); |
838 | | // Do not allow path between two impassable vertexes to prevent cases |
839 | | // where a path along an obstruction will end up in an impassable region |
840 | | if (!IS_PASSABLE(m_Grid->get(i, j), passClass)) |
841 | | visible = false; |
842 | | } |
843 | | |
844 | | visible = visible && |
| 840 | bool visible = |
845 | 841 | CheckVisibilityLeft(vertexes[curr.id].p, npos, edgesLeft) && |
846 | 842 | CheckVisibilityRight(vertexes[curr.id].p, npos, edgesRight) && |
847 | 843 | CheckVisibilityBottom(vertexes[curr.id].p, npos, edgesBottom) && |