IC bool CCoverManager::edge_vertex (u32 index) { CLevelGraph::CVertex *v = ai().level_graph().vertex(index); return ( (!ai().level_graph().valid_vertex_id(v->link(0)) && (v->cover(0) < MIN_COVER_VALUE)) || (!ai().level_graph().valid_vertex_id(v->link(1)) && (v->cover(1) < MIN_COVER_VALUE)) || (!ai().level_graph().valid_vertex_id(v->link(2)) && (v->cover(2) < MIN_COVER_VALUE)) || (!ai().level_graph().valid_vertex_id(v->link(3)) && (v->cover(3) < MIN_COVER_VALUE)) ); }
void CGameGraphBuilder::fill_neighbours (const u32 &game_vertex_id) { m_marks.assign (level_graph().header().vertex_count(),false); m_current_fringe.clear (); u32 level_vertex_id = graph().vertex(game_vertex_id)->data().level_vertex_id(); CLevelGraph::const_iterator I, E; m_mark_stack.reserve (8192); m_mark_stack.push_back (level_vertex_id); for ( ; !m_mark_stack.empty(); ) { level_vertex_id = m_mark_stack.back(); m_mark_stack.resize (m_mark_stack.size() - 1); CLevelGraph::CVertex *node = level_graph().vertex(level_vertex_id); level_graph().begin (level_vertex_id,I,E); m_marks[level_vertex_id] = true; for ( ; I != E; ++I) { u32 next_level_vertex_id = node->link(I); if (!level_graph().valid_vertex_id(next_level_vertex_id)) continue; if (m_marks[next_level_vertex_id]) continue; GameGraph::_GRAPH_ID next_game_vertex_id = cross().vertex(next_level_vertex_id).game_vertex_id(); VERIFY (next_game_vertex_id < graph().vertices().size()); if (next_game_vertex_id != (GameGraph::_GRAPH_ID)game_vertex_id) { if ( std::find( m_current_fringe.begin(), m_current_fringe.end(), next_game_vertex_id ) == m_current_fringe.end() ) m_current_fringe.push_back (next_game_vertex_id); continue; } m_mark_stack.push_back (next_level_vertex_id); } } }
void vfRecurseMark(const CLevelGraph &tMap, xr_vector<bool> &tMarks, u32 dwStartNodeID) { CLevelGraph::const_iterator I, E; xr_vector<u32> l_stack; l_stack.reserve (8192); l_stack.push_back (dwStartNodeID); for (;!l_stack.empty();) { dwStartNodeID = l_stack.back(); l_stack.resize (l_stack.size() - 1); CLevelGraph::CVertex *node = tMap.vertex(dwStartNodeID); tMap.begin (dwStartNodeID,I,E); tMarks[dwStartNodeID] = true; for ( ; I != E; ++I) { u32 dwNexNodeID = node->link(I); if (tMap.valid_vertex_id(dwNexNodeID) && !tMarks[dwNexNodeID]) l_stack.push_back (dwNexNodeID); } } }
void CGameGraphBuilder::mark_vertices (u32 level_vertex_id) { CLevelGraph::const_iterator I, E; m_mark_stack.reserve (8192); m_mark_stack.push_back (level_vertex_id); for ( ; !m_mark_stack.empty(); ) { level_vertex_id = m_mark_stack.back(); m_mark_stack.resize (m_mark_stack.size() - 1); CLevelGraph::CVertex *node = level_graph().vertex(level_vertex_id); level_graph().begin (level_vertex_id,I,E); m_marks[level_vertex_id] = true; for ( ; I != E; ++I) { u32 next_level_vertex_id = node->link(I); if (!level_graph().valid_vertex_id(next_level_vertex_id)) continue; if (!m_marks[next_level_vertex_id]) m_mark_stack.push_back (next_level_vertex_id); } } }
void vfRecurseUpdate(u32 dwStartNodeID, u32 percent, u32 iVertexCount) { xr_vector<u32> curr_fringe, next_fringe; curr_fringe.reserve (g_tDistances->size()); next_fringe.reserve (g_tDistances->size()); g_tDistances->assign (g_tDistances->size(),u32(-1)); curr_fringe.push_back (dwStartNodeID); u32 curr_dist = 0, total_count = 0; Progress (float(percent)/float(iVertexCount)); for (;!curr_fringe.empty();) { xr_vector<u32>::iterator I = curr_fringe.begin(); xr_vector<u32>::iterator E = curr_fringe.end(); for ( ; I != E; ++I) { (*g_tDistances)[*I] = curr_dist; CLevelGraph::const_iterator i, e; CLevelGraph::CVertex *node = (*g_tMap).vertex(*I); (*g_tMap).begin (*I,i,e); for ( ; i != e; ++i) { u32 dwNexNodeID = node->link(i); if (!(*g_tMap).valid_vertex_id(dwNexNodeID) || (*g_tMarks)[dwNexNodeID]) continue; if ((*g_tDistances)[dwNexNodeID] > curr_dist) { next_fringe.push_back(dwNexNodeID); (*g_tMarks)[dwNexNodeID] = true; } } } I = curr_fringe.begin(); E = curr_fringe.end(); for ( ; I != E; ++I) (*g_tMarks)[*I] = false; total_count += curr_fringe.size(); curr_fringe = next_fringe; next_fringe.clear(); ++curr_dist; Progress (float(percent)/float(iVertexCount) + float(total_count)/(float(iVertexCount)*float(g_tMap->header().vertex_count()))); } }
void CGameGraphBuilder::recursive_update (const u32 &game_vertex_id, const float &start, const float &amount) { Progress (start); u32 level_vertex_id = graph().vertex(game_vertex_id)->data().level_vertex_id(); xr_vector<u32> &distances = m_distances[game_vertex_id]; m_distances[m_results[level_vertex_id]][level_vertex_id] = u32(-1); m_current_fringe.reserve (distances.size()); m_next_fringe.reserve (distances.size()); distances.assign (distances.size(),u32(-1)); m_current_fringe.push_back (level_vertex_id); u32 curr_dist = 0; u32 total_count = 0; u32 vertex_count = graph().header().vertex_count(); float amount_i = amount / ( float(vertex_count)* float(level_graph().header().vertex_count()) ); Progress (start); for ( ; !m_current_fringe.empty(); ) { xr_vector<u32>::iterator I = m_current_fringe.begin(); xr_vector<u32>::iterator E = m_current_fringe.end(); for ( ; I != E; ++I) { u32 *result = &m_results[*I]; VERIFY (curr_dist < m_distances[*result][*I]); *result = game_vertex_id; distances[*I] = curr_dist; CLevelGraph::const_iterator i, e; CLevelGraph::CVertex *node = level_graph().vertex(*I); level_graph().begin (*I,i,e); for ( ; i != e; ++i) { u32 dwNexNodeID = node->link(i); if (!level_graph().valid_vertex_id(dwNexNodeID)) continue; if (m_marks[dwNexNodeID]) continue; if (distances[dwNexNodeID] <= curr_dist) continue; if (m_distances[m_results[dwNexNodeID]][dwNexNodeID] <= (curr_dist + 1)) continue; m_next_fringe.push_back (dwNexNodeID); m_marks[dwNexNodeID] = true; } } I = m_current_fringe.begin(); E = m_current_fringe.end(); for ( ; I != E; ++I) m_marks[*I] = false; total_count += m_current_fringe.size(); m_current_fringe = m_next_fringe; m_next_fringe.clear (); ++curr_dist; Progress (start + amount_i*float(total_count)); } Progress (start + amount); }