BOOL QuadFit(u32 Base, u32 Size) { // ***** build horizontal line vecDW BaseLine; BaseLine.reserve(Size); // middle vertex& BaseNode = g_nodes[Base]; BaseLine.push_back(Base); // right expansion for (; BaseLine.size()<Size; ) { vertex& B = g_nodes[BaseLine.back()]; u32 RP = B.nRight(); if (RP==InvalidNode) break; if (used[RP]) break; if (!NodeSimilar(BaseNode,g_nodes[RP])) break; BaseLine.push_back(RP); } if (BaseLine.size()<Size) return FALSE; // down expansion BestQuad.clear (); BestQuad_Count = 0; BestQuad.reserve (Size); BestQuad.push_back (BaseLine); for (; BestQuad.size() < Size;) { // create _new list BestQuad.push_back (vecDW()); vecDW& src = BestQuad[BestQuad.size()-2]; vecDW& dest = BestQuad[BestQuad.size()-1]; dest.reserve (Size); // iterate on it vecDW_it I = src.begin (); vecDW_it E = src.end (); for (; I!=E; I++) { u32 id = g_nodes[*I].nBack(); if (id==InvalidNode) return FALSE; if (used[id]) return FALSE; if (!NodeSimilar(g_nodes[id],BaseNode)) return FALSE; dest.push_back (id); } } return TRUE; }
void CDeflector::RemapUV (xr_vector<UVtri>& dest, u32 base_u, u32 base_v, u32 size_u, u32 size_v, u32 lm_u, u32 lm_v, BOOL bRotate) { dest.clear (); dest.reserve(UVpolys.size()); // UV rect (actual) Fvector2 a_min,a_max,a_size; GetRect (a_min,a_max); a_size.sub (a_max,a_min); // UV rect (dedicated) Fvector2 d_min,d_max,d_size; d_min.x = (float(base_u)+.5f)/float(lm_u); d_min.y = (float(base_v)+.5f)/float(lm_v); d_max.x = (float(base_u+size_u)-.5f)/float(lm_u); d_max.y = (float(base_v+size_v)-.5f)/float(lm_v); if (d_min.x>=d_max.x) { d_min.x=d_max.x=(d_min.x+d_max.x)/2; d_min.x-=EPS_S; d_max.x+=EPS_S; } if (d_min.y>=d_max.y) { d_min.y=d_max.y=(d_min.y+d_max.y)/2; d_min.y-=EPS_S; d_max.y+=EPS_S; } d_size.sub (d_max,d_min); // Remapping Fvector2 tc; UVtri tnew; if (bRotate) { for (UVIt it = UVpolys.begin(); it!=UVpolys.end(); it++) { UVtri& T = *it; tnew.owner = T.owner; for (int i=0; i<3; i++) { tc.x = ((T.uv[i].y-a_min.y)/a_size.y)*d_size.x + d_min.x; tc.y = ((T.uv[i].x-a_min.x)/a_size.x)*d_size.y + d_min.y; tnew.uv[i].set(tc); } dest.push_back (tnew); } } else { for (UVIt it = UVpolys.begin(); it!=UVpolys.end(); it++) { UVtri& T = *it; tnew.owner = T.owner; for (int i=0; i<3; i++) { tc.x = ((T.uv[i].x-a_min.x)/a_size.x)*d_size.x + d_min.x; tc.y = ((T.uv[i].y-a_min.y)/a_size.y)*d_size.y + d_min.y; tnew.uv[i].set(tc); } dest.push_back (tnew); } } }
template <class T> IC void CCar::fill_wheel_vector(LPCSTR S,xr_vector<T>& type_wheels) { IKinematics* pKinematics =smart_cast<IKinematics*>(Visual()); string64 S1; int count = _GetItemCount(S); for (int i=0 ;i<count; ++i) { _GetItem (S,i,S1); u16 bone_id = pKinematics->LL_BoneID(S1); type_wheels.push_back (T()); T& twheel = type_wheels.back(); BONE_P_PAIR_IT J = bone_map.find(bone_id); if (J == bone_map.end()) { bone_map.insert(mk_pair(bone_id,physicsBone())); SWheel& wheel = (m_wheels_map.insert(mk_pair(bone_id,SWheel(this)))).first->second; wheel.bone_id = bone_id; twheel.pwheel = &wheel; wheel .Load(S1); twheel .Load(S1); } else { twheel.pwheel = &(m_wheels_map.find(bone_id))->second; twheel .Load(S1); } } }
CUIWindow::CUIWindow() { //. m_dbg_flag.zero (); m_pFont = NULL; m_pParentWnd = NULL; m_pMouseCapturer = NULL; m_pOrignMouseCapturer = NULL; m_pMessageTarget = NULL; m_pKeyboardCapturer = NULL; SetWndRect (0,0,0,0); m_bAutoDelete = false; Show (true); Enable (true); m_bCursorOverWindow = false; m_bClickable = false; m_bPP = false; m_dwFocusReceiveTime = 0; #ifdef LOG_ALL_WNDS ListWndCount++; m_dbg_id = ListWndCount; dbg_list_wnds.push_back(DBGList()); dbg_list_wnds.back().num = m_dbg_id; dbg_list_wnds.back().closed = false; #endif }
float CLevelGraph::mark_nodes_in_direction(u32 start_vertex_id, const Fvector &start_point, const Fvector &finish_point, xr_vector<u32> &tpaStack, xr_vector<bool> *tpaMarks) const { SContour _contour; const_iterator I,E; int saved_index, iPrevIndex = -1, iNextNode; Fvector temp_point = start_point; float fDistance = start_point.distance_to(finish_point), fCurDistance = 0.f; u32 dwCurNode = start_vertex_id; while (!inside(vertex(dwCurNode),finish_point) && (fCurDistance < (fDistance + EPS_L))) { begin (dwCurNode,I,E); saved_index = -1; contour (_contour,dwCurNode); for ( ; I != E; ++I) { iNextNode = value(dwCurNode,I); if (valid_vertex_id(iNextNode) && (iPrevIndex != iNextNode)) choose_point(start_point,finish_point,_contour, iNextNode,temp_point,saved_index); } if (saved_index > -1) { fCurDistance = start_point.distance_to_xz(temp_point); iPrevIndex = dwCurNode; dwCurNode = saved_index; } else return(fCurDistance); if (tpaMarks) (*tpaMarks)[dwCurNode] = true; tpaStack.push_back (dwCurNode); } return (fCurDistance); }
int CompressSelected() { if (g_selected.size()>1) { std::sort (g_selected.begin(),g_selected.end()); vecW_IT I = std::unique (g_selected.begin(),g_selected.end()); g_selected.erase(I,g_selected.end()); } // Search placeholder u32 sz = g_selected.size(); u32 sz_bytes = sz*sizeof(u16); treeCompressPair Range = g_compress_tree.equal_range(sz); for (treeCompressIt it=Range.first; it!=Range.second; it++) { treeCompressType &V = *it; u32 entry = V.second; vecW &entry_data = g_pvs[entry]; if (0!=memcmp(entry_data.begin(),g_selected.begin(),sz_bytes)) continue; // Ok-Ob :) return entry; } // If we get here - need to register _new set of data u32 entry = g_pvs.size(); g_pvs.push_back(g_selected); g_compress_tree.insert(mk_pair(sz,entry)); return entry; }
u16 RegisterShader (LPCSTR T) { for (u32 it=0; it<g_Shaders.size(); it++) if (0==stricmp(T,g_Shaders[it])) return it; g_Shaders.push_back (xr_strdup(T)); return g_Shaders.size ()-1; }
void CPolterTele::tele_find_objects(xr_vector<CObject*> &objects, const Fvector &pos) { m_nearest.clear_not_free (); Level().ObjectSpace.GetNearest (m_nearest, pos, m_pmt_radius, NULL); for (u32 i=0;i<m_nearest.size();i++) { CPhysicsShellHolder *obj = smart_cast<CPhysicsShellHolder *>(m_nearest[i]); CCustomMonster *custom_monster = smart_cast<CCustomMonster *>(m_nearest[i]); if (!obj || !obj->PPhysicsShell() || !obj->PPhysicsShell()->isActive()|| custom_monster || (obj->spawn_ini() && obj->spawn_ini()->section_exist("ph_heavy")) || (obj->m_pPhysicsShell->getMass() < m_pmt_object_min_mass) || (obj->m_pPhysicsShell->getMass() > m_pmt_object_max_mass) || (obj == m_object) || m_object->CTelekinesis::is_active_object(obj) || !obj->m_pPhysicsShell->get_ApplyByGravity()) continue; Fvector center; Actor()->Center(center); if (trace_object(obj, center) || trace_object(obj, get_head_position(Actor()))) objects.push_back(obj); } }
u32 PlaceData(xr_vector<vecW> &C, vecW &P) { if (P.size()>1) { std::sort (P.begin(),P.end()); vecW::iterator I = std::unique (P.begin(),P.end()); P.erase(I,P.end()); } // Search placeholder u32 sz = P.size(); u32 pos = 0; for (xr_vector<vecW>::iterator it=C.begin(); it!=C.end(); it++) { u32 S = it->size(); if (S!=sz) { pos+=S+1; continue; } if (0!=memcmp(it->begin(),P.begin(),S*sizeof(u16))) { pos+=S+1; continue; } // Ok-Ob :) goto exit; } // If we get here - need to register _new set of data C.push_back(P); exit: P.clear(); return pos*sizeof(u16); }
void format_register(LPCSTR ext) { if (ext&&ext[0]){ for (u32 i=0; i<exts.size(); i++) if (0==stricmp(exts[i],ext)) return; exts.push_back(xr_strdup(ext)); } }
void fill_needed_levels (LPSTR levels, xr_vector<LPCSTR> &result) { LPSTR I = levels; for (LPSTR J = I; ; ++I) { if (*I != ',') { if (*I) continue; result.push_back(J); break; } *I = 0; result.push_back (J); J = I + 1; } }
void sort_tlist_mat ( xr_vector<mapMatrixTextures::TNode*,render_alloc<mapMatrixTextures::TNode*> >& lst, xr_vector<mapMatrixTextures::TNode*,render_alloc<mapMatrixTextures::TNode*> >& temp, mapMatrixTextures& textures, BOOL bSSA ) { int amount = textures.begin()->key->size(); if (bSSA) { if (amount<=1) { // Just sort by SSA textures.getANY_P (lst); std::sort (lst.begin(), lst.end(), cmp_textures_ssa_mat); } else { // Split into 2 parts mapMatrixTextures::TNode* _it = textures.begin (); mapMatrixTextures::TNode* _end = textures.end (); for (; _it!=_end; _it++) { if (_it->val.ssa > r_ssaHZBvsTEX) lst.push_back (_it); else temp.push_back (_it); } // 1st - part - SSA, 2nd - lexicographically std::sort (lst.begin(), lst.end(), cmp_textures_ssa_mat); if (2==amount) std::sort (temp.begin(), temp.end(), cmp_textures_lex2_mat); else if (3==amount) std::sort (temp.begin(), temp.end(), cmp_textures_lex3_mat); else std::sort (temp.begin(), temp.end(), cmp_textures_lexN_mat); // merge lists lst.insert (lst.end(),temp.begin(),temp.end()); } } else { textures.getANY_P (lst); if (2==amount) std::sort (lst.begin(), lst.end(), cmp_textures_lex2_mat); else if (3==amount) std::sort (lst.begin(), lst.end(), cmp_textures_lex3_mat); else std::sort (lst.begin(), lst.end(), cmp_textures_lexN_mat); } }
CUIXml::CUIXml() { #ifdef LOG_ALL_XMLS ListXmlCount++; m_dbg_id = ListXmlCount; dbg_list_xmls.push_back(DBGList_()); dbg_list_xmls.back().num = m_dbg_id; dbg_list_xmls.back().closed = false; #endif }
CUILine::CUILine(const CUILine& other){ m_subLines = other.m_subLines; m_tmpLine = NULL; #ifdef LOG_ALL_LINES ListLinesCount++; dbg_list_lines.push_back(DBGList()); dbg_list_lines.back().wnd = this; dbg_list_lines.back().num = ListLinesCount; #endif }
void game_cl_ArtefactHunt::GetMapEntities(xr_vector<SZoneMapEntityData>& dst) { inherited::GetMapEntities(dst); SZoneMapEntityData D; u32 color_enemy_with_artefact = 0xffff0000; u32 color_artefact = 0xffffffff; u32 color_friend_with_artefact = 0xffffff00; s16 local_team = local_player->team; CObject* pObject = Level().Objects.net_Find(artefactID); if(!pObject) return; CArtefact* pArtefact = smart_cast<CArtefact*>(pObject); VERIFY(pArtefact); CObject* pParent = pArtefact->H_Parent(); if(!pParent){// Artefact alone D.color = color_artefact; D.pos = pArtefact->Position(); dst.push_back(D); return; }; if (pParent && pParent->ID() == artefactBearerID && GetPlayerByGameID(artefactBearerID)){ CObject* pBearer = Level().Objects.net_Find(artefactBearerID); VERIFY(pBearer); D.pos = pBearer->Position(); game_PlayerState* ps = GetPlayerByGameID (artefactBearerID); (ps->team==local_team)? D.color=color_friend_with_artefact:D.color=color_enemy_with_artefact; //remove previous record about this actor !!! dst.push_back(D); return; } }
CUILine::CUILine(){ m_tmpLine = NULL; m_animation.SetColorAnimation("ui_map_area_anim"); m_animation.Cyclic(true); #ifdef LOG_ALL_LINES ListLinesCount++; dbg_list_lines.push_back(DBGList()); dbg_list_lines.back().wnd = this; dbg_list_lines.back().num = ListLinesCount; #endif }
void construct_restriction_vector(shared_str restrictions, xr_vector<ALife::_OBJECT_ID> &result) { result.clear(); string64 temp; u32 n = _GetItemCount(*restrictions); for (u32 i=0; i<n; ++i) { CObject *object = Level().Objects.FindObjectByName(_GetItem(*restrictions,i,temp)); if (!object) continue; result.push_back(object->ID()); } }
void CPda::ActivePDAContacts(xr_vector<CPda*>& res) { res.clear_not_free (); xr_vector<CObject*>::iterator it = m_active_contacts.begin(); xr_vector<CObject*>::iterator it_e = m_active_contacts.end(); for(;it!=it_e;++it) { CPda* p = GetPdaFromOwner(*it); if(p) res.push_back(p); } }
void OGF::adjacent_select (xr_vector<u32>& dest, xr_vector<bool>& vmark, xr_vector<bool>& fmark) { // 0. Search for the group for (u32 fit=0; fit<faces.size(); fit++) { OGF_Face& F = faces [fit]; if (fmark[fit]) continue; // already registered // new face - if empty - just put it in, else check connectivity if (dest.empty()) { fmark[fit] = true ; dest.push_back (F.v[0]); vmark[F.v[0]]=true; dest.push_back (F.v[1]); vmark[F.v[1]]=true; dest.push_back (F.v[2]); vmark[F.v[2]]=true; } else { // check connectivity BOOL bConnected = FALSE; for (u32 vid=0; vid<3; vid++) { u32 id = F.v [vid]; // search in already registered verts for (u32 sid=0; sid<dest.size(); sid++) { if (id==dest[sid]) { bConnected = TRUE; // this face shares at least one vertex with already selected faces break; } } if (bConnected) break; } if (bConnected) { // add this face's vertices fmark[fit] = true ; if (!vmark[F.v[0]]) { dest.push_back (F.v[0]); vmark[F.v[0]]=true; } if (!vmark[F.v[1]]) { dest.push_back (F.v[1]); vmark[F.v[1]]=true; } if (!vmark[F.v[2]]) { dest.push_back (F.v[2]); vmark[F.v[2]]=true; } } } } }
void base_lighting::select (xr_vector<R_Light>& dest, xr_vector<R_Light>& src, Fvector& P, float R) { Fsphere Sphere; Sphere.set (P,R); dest.clear (); R_Light* L = &*src.begin(); for (; L!=&*src.end(); L++) { if (L->type==LT_POINT) { float dist = Sphere.P.distance_to(L->position); if (dist>(Sphere.R+L->range)) continue; } dest.push_back(*L); } }
BOOL CLevelChanger::net_Spawn (CSE_Abstract* DC) { m_entrance_time = 0; CCF_Shape *l_pShape = xr_new<CCF_Shape>(this); collidable.model = l_pShape; CSE_Abstract *l_tpAbstract = (CSE_Abstract*)(DC); CSE_ALifeLevelChanger *l_tpALifeLevelChanger = smart_cast<CSE_ALifeLevelChanger*>(l_tpAbstract); R_ASSERT (l_tpALifeLevelChanger); m_game_vertex_id = l_tpALifeLevelChanger->m_tNextGraphID; m_level_vertex_id = l_tpALifeLevelChanger->m_dwNextNodeID; m_position = l_tpALifeLevelChanger->m_tNextPosition; m_angles = l_tpALifeLevelChanger->m_tAngles; m_bSilentMode = !!l_tpALifeLevelChanger->m_bSilentMode; if (ai().get_level_graph()) { //. this information should be computed in xrAI ai_location().level_vertex (ai().level_graph().vertex(u32(-1),Position())); ai_location().game_vertex (ai().cross_table().vertex(ai_location().level_vertex_id()).game_vertex_id()); } feel_touch.clear (); for (u32 i=0; i < l_tpALifeLevelChanger->shapes.size(); ++i) { CSE_Shape::shape_def &S = l_tpALifeLevelChanger->shapes[i]; switch (S.type) { case 0 : { l_pShape->add_sphere(S.data.sphere); break; } case 1 : { l_pShape->add_box(S.data.box); break; } } } BOOL bOk = inherited::net_Spawn(DC); if (bOk) { l_pShape->ComputeBounds (); Fvector P; XFORM().transform_tiny (P,CFORM()->getSphere().P); setEnabled (TRUE); } g_lchangers.push_back (this); return (bOk); }
void xrSaveNodes(LPCSTR N, LPCSTR out_name) { Msg ("NS: %d, CNS: %d, ratio: %f%%",sizeof(vertex),sizeof(CLevelGraph::CVertex),100*float(sizeof(CLevelGraph::CVertex))/float(sizeof(vertex))); Msg ("Renumbering nodes..."); string_path fName; strconcat (sizeof(fName),fName,N,out_name); IWriter *fs = FS.w_open(fName); // Header Status ("Saving header..."); hdrNODES H; H.version = XRAI_CURRENT_VERSION; H.count = g_nodes.size(); H.size = g_params.fPatchSize; H.size_y = CalculateHeight(H.aabb); H.guid = generate_guid(); fs->w (&H,sizeof(H)); // fs->w_u32 (g_covers_palette.size()); // for (u32 j=0; j<g_covers_palette.size(); ++j) // fs->w (&g_covers_palette[j],sizeof(g_covers_palette[j])); // All nodes Status ("Saving nodes..."); for (u32 i=0; i<g_nodes.size(); ++i) { vertex &N = g_nodes[i]; NodeCompressed NC; Compress (NC,N,H); compressed_nodes.push_back(NC); } xr_vector<u32> sorted; xr_vector<u32> renumbering; CNodeRenumberer A(compressed_nodes,sorted,renumbering); for (u32 i=0; i<g_nodes.size(); ++i) { fs->w (&compressed_nodes[i],sizeof(NodeCompressed)); Progress (float(i)/float(g_nodes.size())); } // Stats u32 SizeTotal = fs->tell(); Msg ("%dK saved",SizeTotal/1024); FS.w_close (fs); }
static void save_fixes( IKinematics *K ) { VERIFY( K ); saved_fixes.clear(); u16 nbb = K->LL_BoneCount(); for(u16 i = 0; i < nbb; ++i ) { CBoneInstance &bi = K->LL_GetBoneInstance( i ); if( bi.callback() == anim_bone_fix::callback ) { VERIFY( bi.callback_param()); anim_bone_fix* fix = (anim_bone_fix*) bi.callback_param(); VERIFY( fix->bone == &bi ); saved_fixes.push_back( fix ); } } }
void CBuild::Light() { //****************************************** Implicit { FPU::m64r (); Phase ("LIGHT: Implicit..."); mem_Compact (); ImplicitLighting(); } //****************************************** Lmaps { FPU::m64r (); Phase ("LIGHT: LMaps..."); mem_Compact (); // Randomize deflectors std::random_shuffle (g_deflectors.begin(),g_deflectors.end()); for (u32 dit = 0; dit<g_deflectors.size(); dit++) task_pool.push_back(dit); // Main process (4 threads) Status ("Lighting..."); CThreadManager threads; const u32 thNUM = 6; CTimer start_time; start_time.Start(); for (int L=0; L<thNUM; L++) threads.start(xr_new<CLMThread> (L)); threads.wait (500); clMsg ("%f seconds",start_time.GetElapsed_sec()); } //****************************************** Vertex FPU::m64r (); Phase ("LIGHT: Vertex..."); mem_Compact (); LightVertex (); //****************************************** Merge LMAPS { FPU::m64r (); Phase ("LIGHT: Merging lightmaps..."); mem_Compact (); xrPhase_MergeLM (); } }
void xrServer::Perform_connect_spawn(CSE_Abstract* E, xrClientData* CL, NET_Packet& P) { xr_vector<u16>::iterator it = std::find(g_perform_spawn_ids.begin(), g_perform_spawn_ids.end(), E->ID); if(it!=g_perform_spawn_ids.end()) return; g_perform_spawn_ids.push_back(E->ID); if (E->net_Processed) return; if (E->s_flags.is(M_SPAWN_OBJECT_PHANTOM)) return; // Connectivity order CSE_Abstract* Parent = ID_to_entity (E->ID_Parent); if (Parent) Perform_connect_spawn (Parent,CL,P); // Process Flags16 save = E->s_flags; //------------------------------------------------- E->s_flags.set (M_SPAWN_UPDATE,TRUE); if (0==E->owner) { // PROCESS NAME; Name this entity if (E->s_flags.is(M_SPAWN_OBJECT_ASPLAYER)) { CL->owner = E; E->set_name_replace (*CL->name); } // Associate E->owner = CL; E->Spawn_Write (P,TRUE ); E->UPDATE_Write (P); } else { // Just inform E->Spawn_Write (P,FALSE); E->UPDATE_Write (P); } //----------------------------------------------------- E->s_flags = save; SendTo (CL->ID,P,net_flags(TRUE,TRUE)); E->net_Processed = TRUE; }
void ProcessFolder(xr_vector<char*>& list, LPCSTR path) { xr_vector<char*>* i_list = FS.file_list_open ("$target_folder$",path,FS_ListFiles|FS_RootOnly); if (!i_list){ Log ("ERROR: Unable to open file list:", path); return; } xr_vector<char*>::iterator it = i_list->begin(); xr_vector<char*>::iterator itE = i_list->end(); for (;it!=itE;++it){ xr_string tmp_path = xr_string(path)+xr_string(*it); if (!testSKIP(tmp_path.c_str())){ list.push_back (xr_strdup(tmp_path.c_str())); //. Msg ("+f: %s",tmp_path.c_str()); }else{ Msg ("-f: %s",tmp_path.c_str()); } } FS.file_list_close (i_list); }
void CUIMMShniaga::CreateList(xr_vector<CUIStatic*>& lst, CUIXml& xml_doc, LPCSTR path){ CGameFont* pF; u32 color; float button_height = xml_doc.ReadAttribFlt("button", 0, "h"); R_ASSERT (button_height); CUIXmlInit::InitFont (xml_doc, path, 0, color, pF); R_ASSERT (pF); int nodes_num = xml_doc.GetNodesNum(path, 0, "btn"); XML_NODE* tab_node = xml_doc.NavigateToNode(path,0); xml_doc.SetLocalRoot (tab_node); CUIStatic* st; for (int i = 0; i < nodes_num; ++i) { st = new CUIStatic(); st->SetWndPos (Fvector2().set(0,0)); st->SetWndSize (Fvector2().set(m_view->GetDesiredChildWidth(), button_height)); st->SetTextComplexMode (false); st->SetTextST (xml_doc.ReadAttrib ("btn", i, "caption")); if (pF) st->SetFont (pF); float font_height = st->GetFont()->GetHeight(); UI()->ClientToScreenScaledHeight(font_height); st->SetTextY ( (button_height-font_height)/2.0f ); st->SetTextColor (color); st->SetTextAlignment (CGameFont::alCenter); st->SetWindowName (xml_doc.ReadAttrib("btn", i, "name")); st->SetMessageTarget (this); lst.push_back(st); } xml_doc.SetLocalRoot(xml_doc.GetRoot()); }
void AddOne (const char *split) { logCS.Enter (); #ifdef DEBUG OutputDebugString (split); OutputDebugString ("\n"); #endif // DUMP_PHASE; { shared_str temp = shared_str(split); // DUMP_PHASE; LogFile.push_back (temp); } //exec CallBack if (LogExecCB&&LogCB)LogCB(split); logCS.Leave (); }
void game_cl_TeamDeathmatch::GetMapEntities(xr_vector<SZoneMapEntityData>& dst) { SZoneMapEntityData D; u32 color_self_team = 0xff00ff00; D.color = color_self_team; s16 local_team = local_player->team; PLAYERS_MAP_IT it = players.begin(); for(;it!=players.end();++it){ if(local_team == it->second->team){ u16 id = it->second->GameID; CObject* pObject = Level().Objects.net_Find(id); if (!pObject) continue; if (!pObject || pObject->CLS_ID != CLSID_OBJECT_ACTOR) continue; VERIFY(pObject); D.pos = pObject->Position(); dst.push_back(D); } } }
//---------------------------------------------------------------------- int CObjectSpace::GetNearest ( xr_vector<ISpatial*>& q_spatial, xr_vector<CObject*>& q_nearest, const Fvector &point, float range, CObject* ignore_object ) { q_spatial.clear_not_free ( ); // Query objects q_nearest.clear_not_free ( ); Fsphere Q; Q.set (point,range); Fvector B; B.set (range,range,range); g_SpatialSpace->q_box(q_spatial,0,STYPE_COLLIDEABLE,point,B); // Iterate xr_vector<ISpatial*>::iterator it = q_spatial.begin (); xr_vector<ISpatial*>::iterator end = q_spatial.end (); for (; it!=end; it++) { CObject* O = (*it)->dcast_CObject (); if (0==O) continue; if (O==ignore_object) continue; Fsphere mS = { O->spatial.sphere.P, O->spatial.sphere.R }; if (Q.intersect(mS)) q_nearest.push_back(O); } return q_nearest.size(); }