Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/CCmpRallyPointRenderer.cpp
Show First 20 Lines • Show All 810 Lines • ▼ Show 20 Lines | void CCmpRallyPointRenderer::GetVisibilitySegments(std::vector<SVisibilitySegment>& out, size_t index) const | ||||
CmpPtr<ICmpRangeManager> cmpRangeMgr(GetSystemEntity()); | CmpPtr<ICmpRangeManager> cmpRangeMgr(GetSystemEntity()); | ||||
player_id_t currentPlayer = static_cast<player_id_t>(GetSimContext().GetCurrentDisplayedPlayer()); | player_id_t currentPlayer = static_cast<player_id_t>(GetSimContext().GetCurrentDisplayedPlayer()); | ||||
CLosQuerier losQuerier(cmpRangeMgr->GetLosQuerier(currentPlayer)); | CLosQuerier losQuerier(cmpRangeMgr->GetLosQuerier(currentPlayer)); | ||||
// Go through the path node list, comparing each node's visibility with the previous one. If it changes, end the current segment and start | // Go through the path node list, comparing each node's visibility with the previous one. If it changes, end the current segment and start | ||||
// a new one at the next point. | // a new one at the next point. | ||||
const float terrainSize = static_cast<float>(TERRAIN_TILE_SIZE); | const float cellSize = static_cast<float>(LOS_TILE_SIZE); | ||||
bool lastVisible = losQuerier.IsExplored( | bool lastVisible = losQuerier.IsExplored( | ||||
(fixed::FromFloat(m_Path[index][0].X / terrainSize)).ToInt_RoundToNearest(), | (fixed::FromFloat(m_Path[index][0].X / cellSize)).ToInt_RoundToNearest(), | ||||
(fixed::FromFloat(m_Path[index][0].Y / terrainSize)).ToInt_RoundToNearest() | (fixed::FromFloat(m_Path[index][0].Y / cellSize)).ToInt_RoundToNearest() | ||||
); | ); | ||||
// Starting node index of the current segment | // Starting node index of the current segment | ||||
size_t curSegmentStartIndex = 0; | size_t curSegmentStartIndex = 0; | ||||
for (size_t k = 1; k < m_Path[index].size(); ++k) | for (size_t k = 1; k < m_Path[index].size(); ++k) | ||||
{ | { | ||||
// Grab tile indices for this coord | // Grab tile indices for this coord | ||||
int i = (fixed::FromFloat(m_Path[index][k].X / terrainSize)).ToInt_RoundToNearest(); | int i = (fixed::FromFloat(m_Path[index][k].X / cellSize)).ToInt_RoundToNearest(); | ||||
int j = (fixed::FromFloat(m_Path[index][k].Y / terrainSize)).ToInt_RoundToNearest(); | int j = (fixed::FromFloat(m_Path[index][k].Y / cellSize)).ToInt_RoundToNearest(); | ||||
bool nodeVisible = losQuerier.IsExplored(i, j); | bool nodeVisible = losQuerier.IsExplored(i, j); | ||||
if (nodeVisible != lastVisible) | if (nodeVisible != lastVisible) | ||||
{ | { | ||||
// Visibility changed; write out the segment that was just completed and get ready for the new one | // Visibility changed; write out the segment that was just completed and get ready for the new one | ||||
out.push_back(SVisibilitySegment(lastVisible, curSegmentStartIndex, k - 1)); | out.push_back(SVisibilitySegment(lastVisible, curSegmentStartIndex, k - 1)); | ||||
curSegmentStartIndex = k - 1; | curSegmentStartIndex = k - 1; | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator