void CCharacterPhysicsSupport::CreateSkeleton(CPhysicsShell* &pShell) { R_ASSERT2(!pShell,"pShell already initialized!!"); if (!m_EntityAlife.Visual()) return; #ifdef DEBUG CTimer t;t.Start(); #endif pShell = P_create_Shell(); IKinematics* k = smart_cast<IKinematics*>(m_EntityAlife.Visual()); phys_shell_verify_object_model ( m_EntityAlife ); pShell->preBuild_FromKinematics(k); pShell->mXFORM.set(mXFORM); pShell->SmoothElementsInertia(0.3f); pShell->set_PhysicsRefObject(&m_EntityAlife); SAllDDOParams disable_params; disable_params.Load(smart_cast<IKinematics*>(m_EntityAlife.Visual())->LL_UserData()); pShell->set_DisableParams(disable_params); pShell->Build(); #ifdef DEBUG Msg("shell for %s[%d] created in %f ms",*m_EntityAlife.cName(),m_EntityAlife.ID(),t.GetElapsed_sec()*1000.f); #endif }
bool execution_lightmaps::execute( net_task_callback &net_callback ) { #ifdef COLLECT_EXECUTION_STATS CTimer gtimer; gtimer.Start(); //net_callback.agent().GetSessionCacheDirectory( net_callback.session(), statistics.dir ); DWORD sz = sizeof(statistics.dir); GetComputerName( statistics.dir, &sz ); #endif for(u32 i = from; i< to; ++i ) { #ifdef COLLECT_EXECUTION_STATS CTimer timer; timer.Start(); #endif CDeflector *D = inlc_global_data()->g_deflectors()[i]; VERIFY( D ); lm_layer &lm = D->layer; lm.create( lm.width, lm.height ); D->_net_session = &net_callback; light_execute().run(*D); D->_net_session = 0; #ifdef COLLECT_EXECUTION_STATS D->time_stat.m_time = timer.GetElapsed_sec (); #endif if(net_callback.break_all()) break; } #ifdef COLLECT_EXECUTION_STATS statistics.time_stats.m_time = gtimer.GetElapsed_sec (); #endif return !net_callback.break_all(); }
void __cdecl GetDataCallback(const char* dataDesc, IGenericStream** stream) { clMsg( "GetDataCallback: send start" ); VERIFY(xr_strcmp(dataDesc,"global_data")==0); CTimer time; time.Start(); R_ASSERT(gl_data_write); *stream = CreateGenericStream(); //*stream = gl_data_write->net_stream(); gl_data_write->send_not_clear(*stream); //*stream->Release(); clMsg( "GetDataCallback: send end time elapsed sec: %f, ", time.GetElapsed_sec() ); //(*stream) = new TGenericStream(20000000); //(*stream)->Write(globalDataStream->GetBasePointer(), globalDataStream->GetLength()); }
void CAI_Space::load (LPCSTR level_name) { // Msg ("level %s",level_name); unload (true); #ifdef DEBUG Memory.mem_compact (); u32 mem_usage = Memory.mem_usage(); CTimer timer; timer.Start (); #endif m_level_graph = xr_new<CLevelGraph>(); m_cross_table = xr_new<CGameLevelCrossTable>(); R_ASSERT2 (cross_table().header().level_guid() == level_graph().header().guid(), "cross_table doesn't correspond to the AI-map"); R_ASSERT2 (cross_table().header().game_guid() == game_graph().header().guid(), "graph doesn't correspond to the cross table"); m_graph_engine = xr_new<CGraphEngine>( _max( game_graph().header().vertex_count(), level_graph().header().vertex_count() ) ); const CGameGraph::SLevel ¤t_level = game_graph().header().level(level_name); R_ASSERT2 (current_level.guid() == level_graph().header().guid(), "graph doesn't correspond to the AI-map"); #ifdef DEBUG if (!xr_strcmp(current_level.name(),level_name)) validate (current_level.id()); #endif level_graph().level_id (current_level.id()); game_graph().set_current_level(current_level.id()); m_cover_manager->compute_static_cover (); #ifdef DEBUG Msg ("* Loading ai space is successfully completed (%.3fs, %7.3f Mb)",timer.GetElapsed_sec(),float(Memory.mem_usage() - mem_usage)/1048576.0); #endif }
bool EScene::Load(LPCSTR map_name, bool bUndo) { u32 version = 0; if (!map_name||(0==map_name[0])) return false; xr_string full_name; full_name = map_name; ELog.Msg( mtInformation, "EScene: loading '%s'", map_name); if (FS.exist(full_name.c_str())) { CTimer T; T.Start(); // read main level IReader* F = FS.r_open(full_name.c_str()); VERIFY(F); // Version R_ASSERT (F->r_chunk(CHUNK_VERSION, &version)); if (version!=CURRENT_FILE_VERSION) { ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); FS.r_close(F); return false; } // Lev. ops. IReader* LOP = F->open_chunk(CHUNK_LEVELOP); if (LOP) { m_LevelOp.Read (*LOP); LOP->close (); }else { ELog.DlgMsg (mtError, "Skipping old version of level options.\nCheck level options after loading."); } // if (F->find_chunk(CHUNK_CAMERA)) { Fvector hpb, pos; F->r_fvector3 (hpb); F->r_fvector3 (pos); EDevice.m_Camera.Set(hpb,pos); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); } if (F->find_chunk(CHUNK_TOOLS_GUID)) { F->r (&m_GUID,sizeof(m_GUID)); } if (F->find_chunk(CHUNK_LEVEL_TAG)) { F->r_stringZ (m_OwnerName); F->r (&m_CreateTime,sizeof(m_CreateTime)); }else { m_OwnerName = ""; m_CreateTime = 0; } DWORD obj_cnt = 0; if (F->find_chunk(CHUNK_OBJECT_COUNT)) obj_cnt = F->r_u32(); SPBItem* pb = UI->ProgressStart(obj_cnt,"Loading objects..."); ReadObjectsStream (*F,CHUNK_OBJECT_LIST,OnLoadAppendObject,pb); UI->ProgressEnd (pb); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if (_I->second) { IReader* chunk = F->open_chunk(CHUNK_TOOLS_DATA+_I->first); if (chunk){ _I->second->LoadStream(*chunk); chunk->close (); }else{ if (!bUndo && _I->second->IsEnabled() && (_I->first!=OBJCLASS_DUMMY)) { LoadLevelPart (_I->second,LevelPartName(map_name,_I->first).c_str()); } } } } // snap list if (F->find_chunk(CHUNK_SNAPOBJECTS)) { shared_str buf; int cnt = F->r_u32(); if (cnt) { for (int i=0; i<cnt; ++i) { F->r_stringZ (buf); CCustomObject* O = FindObjectByName(buf.c_str(),OBJCLASS_SCENEOBJECT); if (!O) ELog.Msg(mtError,"EScene: Can't find snap object '%s'.",buf.c_str()); else m_ESO_SnapObjects.push_back(O); } } UpdateSnapList(); } Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec() ); UI->UpdateScene(true); FS.r_close(F); SynchronizeObjects(); if (!bUndo) m_RTFlags.set(flRT_Unsaved|flRT_Modified,FALSE); return true; }else { ELog.Msg(mtError,"Can't find file: '%s'",map_name); } return false; }
//---------------------------------------------------- bool EScene::LoadLTX(LPCSTR map_name, bool bUndo) { DWORD version = 0; if (!map_name||(0==map_name[0])) return false; xr_string full_name; full_name = map_name; ELog.Msg( mtInformation, "EScene: loading '%s'", map_name); if (FS.exist(full_name.c_str())) { CTimer T; T.Start(); // lock main level CInifile ini(full_name.c_str()); version = ini.r_u32("version","value"); if (version!=CURRENT_FILE_VERSION) { ELog.DlgMsg( mtError, "EScene: unsupported file version. Can't load Level."); UI->UpdateScene(); return false; } m_LevelOp.ReadLTX (ini); Fvector hpb, pos; pos = ini.r_fvector3("camera","pos"); hpb = ini.r_fvector3("camera","hpb"); EDevice.m_Camera.Set(hpb,pos); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); EDevice.m_Camera.SetStyle(EDevice.m_Camera.GetStyle()); m_GUID.LoadLTX (ini,"guid","guid"); m_OwnerName = ini.r_string("level_tag","owner"); m_CreateTime = ini.r_u32("level_tag","create_time"); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if (_I->second) { { if (!bUndo && _I->second->IsEnabled() && (_I->first!=OBJCLASS_DUMMY)) { xr_string fn = LevelPartName(map_name, _I->first).c_str(); LoadLevelPartLTX (_I->second, fn.c_str()); } } } } if(ini.section_exist("snap_objects")) { CInifile::Sect& S = ini.r_section("snap_objects"); CInifile::SectCIt Si = S.Data.begin(); CInifile::SectCIt Se = S.Data.end(); for(;Si!=Se; ++Si) { CCustomObject* O = FindObjectByName(Si->first.c_str(),OBJCLASS_SCENEOBJECT); if (!O) ELog.Msg(mtError,"EScene: Can't find snap object '%s'.",Si->second.c_str()); else m_ESO_SnapObjects.push_back(O); } UpdateSnapList(); } Msg("EScene: %d objects loaded, %3.2f sec", ObjCount(), T.GetElapsed_sec() ); UI->UpdateScene(true); SynchronizeObjects(); if (!bUndo) m_RTFlags.set(flRT_Unsaved|flRT_Modified,FALSE); return true; }else { ELog.Msg(mtError,"Can't find file: '%s'",map_name); } return false; }
void EScene::SaveLTX(LPCSTR map_name, bool bForUndo, bool bForceSaveAll) { VERIFY (map_name); R_ASSERT (!bForUndo); CTimer T; T.Start (); xr_string full_name; full_name = map_name; xr_string part_prefix; bool bSaveMain = true; if (!bForUndo) { if (bSaveMain) { EFS.MarkFile (full_name.c_str(),true); } part_prefix = LevelPartPath(full_name.c_str()); } CInifile ini(full_name.c_str(),FALSE,FALSE,TRUE); if (bSaveMain) { ini.w_u32 ("version","value",CURRENT_FILE_VERSION); m_LevelOp.SaveLTX (ini); m_GUID.SaveLTX (ini,"guid","guid"); ini.w_string ("level_tag","owner",m_OwnerName.c_str()); ini.w_u32 ("level_tag","create_time",m_CreateTime); ini.w_fvector3 ("camera","hpb",EDevice.m_Camera.GetHPB()); ini.w_fvector3 ("camera","pos",EDevice.m_Camera.GetPosition()); for(ObjectIt SO=m_ESO_SnapObjects.begin(); SO!=m_ESO_SnapObjects.end(); ++SO) { ini.w_string ("snap_objects",(*SO)->Name,NULL); } } m_SaveCache.clear (); SceneToolsMapPairIt _I = m_SceneTools.begin(); SceneToolsMapPairIt _E = m_SceneTools.end(); for (; _I!=_E; ++_I) { if ( (_I->first!=OBJCLASS_DUMMY) && _I->second && _I->second->IsEnabled() && _I->second->IsEditable() ) { if (bForUndo) { if (_I->second->IsNeedSave()) _I->second->SaveStream (m_SaveCache); }else { // !ForUndo xr_string part_name = part_prefix + _I->second->ClassName() + ".part"; if(_I->second->can_use_inifile()) { EFS.MarkFile (part_name.c_str(),true); SaveToolLTX (_I->second->ClassID, part_name.c_str()); } //can_use_ini_file else { _I->second->SaveStream (m_SaveCache); EFS.MarkFile (part_name.c_str(),true); IWriter* FF = FS.w_open (part_name.c_str()); R_ASSERT (FF); FF->open_chunk (CHUNK_TOOLS_GUID); FF->w (&m_GUID,sizeof(m_GUID)); FF->close_chunk (); FF->open_chunk (CHUNK_TOOLS_DATA+_I->first); FF->w (m_SaveCache.pointer(),m_SaveCache.size()); FF->close_chunk (); FS.w_close (FF); }// ! can_use_ini_file } m_SaveCache.clear (); } } if (!bForUndo) { m_RTFlags.set (flRT_Unsaved,FALSE); Msg ("Saving time: %3.2f sec",T.GetElapsed_sec()); } }
bool ESceneAIMapTool::GenerateMap(bool bFromSelectedOnly) { std::sort(m_ignored_materials.begin(),m_ignored_materials.end()); bool bRes = false; if (!GetSnapList()->empty()){ if (!RealUpdateSnapList()) return false; if (m_Nodes.empty()){ ELog.DlgMsg(mtError,"Append at least one node."); return false; } if (!m_Flags.is(flSlowCalculate)){ // evict resources ExecCommand (COMMAND_EVICT_OBJECTS); ExecCommand (COMMAND_EVICT_TEXTURES); // prepare collision model u32 avg_face_cnt = 0; u32 avg_vert_cnt = 0; u32 mesh_cnt = 0; Fbox snap_bb; { snap_bb.invalidate (); for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++){ CSceneObject* S = dynamic_cast<CSceneObject*>(*o_it); VERIFY(S); avg_face_cnt += S->GetFaceCount(); avg_vert_cnt += S->GetVertexCount(); mesh_cnt += S->Meshes()->size(); Fbox bb; S->GetBox (bb); snap_bb.merge (bb); } } SPBItem* pb = UI->ProgressStart(mesh_cnt,"Prepare collision model..."); CDB::Collector* CL = ETOOLS::create_collector(); Fvector verts[3]; for (ObjectIt o_it=m_SnapObjects.begin(); o_it!=m_SnapObjects.end(); o_it++) { CSceneObject* S = dynamic_cast<CSceneObject*>(*o_it); VERIFY(S); CEditableObject* E = S->GetReference(); VERIFY(E); EditMeshVec& _meshes = E->Meshes(); for (EditMeshIt m_it=_meshes.begin(); m_it!=_meshes.end(); m_it++) { pb->Inc(AnsiString().sprintf("%s [%s]",S->Name,(*m_it)->Name().c_str()).c_str()); const SurfFaces& _sfaces = (*m_it)->GetSurfFaces(); for (SurfFaces::const_iterator sp_it=_sfaces.begin(); sp_it!=_sfaces.end(); sp_it++) { CSurface* surf = sp_it->first; // test passable //. SGameMtl* mtl = GMLib.GetMaterialByID(surf->_GameMtl()); //. if (mtl->Flags.is(SGameMtl::flPassable))continue; Shader_xrLC* c_sh = Device.ShaderXRLC.Get(surf->_ShaderXRLCName()); if (!c_sh->flags.bCollision) continue; // collect tris const IntVec& face_lst = sp_it->second; for (IntVec::const_iterator it=face_lst.begin(); it!=face_lst.end(); it++) { E->GetFaceWorld (S->_Transform(),*m_it,*it,verts); ETOOLS::collector_add_face_d(CL,verts[0],verts[1],verts[2], surf->_GameMtl() /* *it */); if (surf->m_Flags.is(CSurface::sf2Sided)) ETOOLS::collector_add_face_d(CL,verts[2],verts[1],verts[0], surf->_GameMtl() /* *it */); } } } } UI->ProgressEnd(pb); UI->SetStatus ("Building collision model..."); // create CFModel m_CFModel = ETOOLS::create_model_cl(CL); ETOOLS::destroy_collector(CL); } // building Scene->lock (); CTimer tm; tm.Start(); BuildNodes (bFromSelectedOnly); tm.GetElapsed_sec(); Scene->unlock (); //. Log("-test time: ", g_tm.GetElapsed_sec()); Log("-building time: ",tm.GetElapsed_sec()); //. Msg("-Rate: %3.2f Count: %d",(g_tm.GetElapsed_sec()/tm.GetElapsed_sec())*100.f,g_tm.count); // unload CFModel ETOOLS::destroy_model(m_CFModel); Scene->UndoSave (); bRes = true; UI->SetStatus (""); }else{ ELog.DlgMsg(mtError,"Fill snap list before generating slots!"); } return bRes; }
CCommandVar CActorTools::CommandSave(CCommandVar p1, CCommandVar p2) { if (p2==1){ xr_string temp_fn = ATools->m_LastFileName.c_str(); if (EFS.GetSaveName ( _objects_, temp_fn )){ temp_fn = EFS.ChangeFileExt(temp_fn,".object"); return ExecCommand(COMMAND_SAVE,temp_fn,0); } }else{ if (p1.IsInteger()) return ExecCommand(COMMAND_SAVE,xr_string(ATools->m_LastFileName.c_str()),0); xr_string temp_fn = xr_string(p1); if (temp_fn.empty()){ return ExecCommand(COMMAND_SAVE,temp_fn,1); }else{ xr_strlwr (temp_fn); EFS.UnlockFile (temp_fn.c_str()); CTimer T; T.Start(); CCommandVar res; if (Tools->Save(temp_fn.c_str())){ ELog.Msg (mtInformation,"Object '%s' successfully saved. Saving time - %3.2f(s).",m_LastFileName.c_str(),T.GetElapsed_sec()); m_LastFileName = temp_fn.c_str(); EPrefs->AppendRecentFile (m_LastFileName.c_str()); ExecCommand (COMMAND_UPDATE_CAPTION); res = TRUE; }else{ res = FALSE; } EFS.LockFile (temp_fn.c_str()); return res; } } return FALSE; }
//--------------------------------------------------------------------------- // actor commands //--------------------------------------------------------------------------- CCommandVar CActorTools::CommandLoad(CCommandVar p1, CCommandVar p2) { xr_string temp_fn = p1.IsString()?xr_string(p1):xr_string(""); if(!p1.IsString()){ temp_fn = ChangeFileExt(m_LastFileName,"").c_str(); if (!EFS.GetOpenName ( _objects_, temp_fn )) return FALSE; } if( temp_fn.size() ){ xr_strlwr (temp_fn); if (!IfModified()) return FALSE; if (!FS.exist(temp_fn.c_str())){ Msg ("#!Can't load file: %s",temp_fn.c_str()); return FALSE; } ExecCommand (COMMAND_CLEAR); BOOL bReadOnly = !FS.can_modify_file(temp_fn.c_str()); m_Flags.set (flReadOnlyMode,bReadOnly); if (bReadOnly || EFS.CheckLocking(temp_fn.c_str(),false,true)) Msg ("#!Object '%s' opened in readonly mode.",temp_fn.c_str()); /* shared_str locker; if ((false==bReadOnly) && EFS.CheckLocking(_objects_,temp_fn.c_str(),false,true,&locker)){ Log ("#!Object opened in readonly mode. Locked by user:"******"#!You don't have permisions to modify object:",temp_fn.c_str()); } */ // set enable ... m_Props->SetReadOnly (bReadOnly); fraLeftBar->SetReadOnly (bReadOnly); CTimer T; T.Start(); if (!Load(temp_fn.c_str())){ return FALSE; } m_LastFileName = temp_fn.c_str(); ELog.Msg(mtInformation,"Object '%s' successfully loaded. Loading time - %3.2f(s).",m_LastFileName.c_str(),T.GetElapsed_sec()); EPrefs->AppendRecentFile(m_LastFileName.c_str()); ExecCommand (COMMAND_UPDATE_CAPTION); ExecCommand (COMMAND_UPDATE_PROPERTIES); // lock if (!bReadOnly) EFS.LockFile(m_LastFileName.c_str()); UndoClear(); UndoSave(); } return TRUE; }
CCommandVar CActorTools::CommandImport(CCommandVar p1, CCommandVar p2) { xr_string temp_fn = p1.IsString()?xr_string(p1):xr_string(""); if(p1.IsString()||EFS.GetOpenName(_import_,temp_fn)) { FS_Path* pp = FS.get_path(_import_); if (temp_fn.npos!=temp_fn.find(pp->m_Path)) { //. andy temp_fn = xr_string(temp_fn.c_str()+strlen(FS.get_path(_import_)->m_Path)); xr_strlwr(temp_fn); if (!Tools->IfModified()) return FALSE; ExecCommand( COMMAND_CLEAR ); CTimer T; T.Start(); if (!ATools->Import(NULL/*_import_*/,temp_fn.c_str())) return FALSE; m_LastFileName = temp_fn.c_str(); ELog.Msg(mtInformation,"Object '%s' successfully imported. Loading time - %3.2f(s).",m_LastFileName.c_str(),T.GetElapsed_sec()); if (ExecCommand( COMMAND_SAVE,temp_fn,1 )){ xr_string mfn; mfn = temp_fn; //. andy FS.update_path(mfn,_import_,temp_fn.c_str()); EFS.MarkFile(mfn.c_str(),true); }else{ ExecCommand( COMMAND_CLEAR ); } return TRUE; }else{ ELog.Msg (mtError,"Invalid file path. "); } } return FALSE; }
bool CALifeStorageManager::load (LPCSTR save_name_no_check) { LPCSTR game_saves_path = FS.get_path("$game_saves$")->m_Path; string_path save_name; strncpy_s (save_name, sizeof(save_name), save_name_no_check, sizeof(save_name)-5-xr_strlen(SAVE_EXTENSION)-xr_strlen(game_saves_path)); CTimer timer; timer.Start (); string_path save; xr_strcpy (save,m_save_name); if (!save_name) { if (!xr_strlen(m_save_name)) R_ASSERT2 (false,"There is no file name specified!"); } else { strconcat (sizeof(m_save_name), m_save_name, save_name, SAVE_EXTENSION); } string_path file_name; FS.update_path (file_name,"$game_saves$",m_save_name); xr_strcpy (g_last_saved_game, save_name); xr_strcpy (g_bug_report_file, file_name); IReader *stream; stream = FS.r_open(file_name); if (!stream) { Msg ("* Cannot find saved game %s",file_name); xr_strcpy (m_save_name,save); return (false); } CHECK_OR_EXIT (CSavedGameWrapper::valid_saved_game(*stream),make_string("%s\nSaved game version mismatch or saved game is corrupted",file_name)); /* string512 temp; strconcat (sizeof(temp),temp,CStringTable().translate("st_loading_saved_game").c_str()," \"",save_name,SAVE_EXTENSION,"\""); g_pGamePersistent->LoadTitle(temp); */ g_pGamePersistent->LoadTitle(); unload (); reload (m_section); u32 source_count = stream->r_u32(); void *source_data = xr_malloc(source_count); rtc_decompress (source_data,source_count,stream->pointer(),stream->length() - 3*sizeof(u32)); FS.r_close (stream); load (source_data, source_count, file_name); xr_free (source_data); groups().on_after_game_load (); VERIFY (graph().actor()); Msg ("* Game %s is successfully loaded from file '%s' (%.3fs)",save_name, file_name,timer.GetElapsed_sec()); return (true); }
void capped_cylinder_ray_collision_test() { Fcylinder c; c.m_center.set(0,0,0); c.m_direction.set(0,0,1); c.m_height=2; c.m_radius=1; //ray Fvector dir,pos;float R; dir.set(1,0,0);pos.set(0,0,0);R=3; //inside RAYvsCYLINDER(c,pos,dir,R,FALSE);//true , 1 RAYvsCYLINDER(c,pos,dir,R,TRUE);//false , dir.set(0,0,1); RAYvsCYLINDER(c,pos,dir,R,FALSE);//true , 2 RAYvsCYLINDER(c,pos,dir,R,TRUE);//false //outside pos.set(-3,0,0);dir.set(1,0,0);R=4; RAYvsCYLINDER(c,pos,dir,R,FALSE);//true , 2 RAYvsCYLINDER(c,pos,dir,R,TRUE);//true , 2 R=1; RAYvsCYLINDER(c,pos,dir,R,FALSE);//false pos.set(0,0,-3);dir.set(0,0,1);R=4; RAYvsCYLINDER(c,pos,dir,R,FALSE);//true , 1 RAYvsCYLINDER(c,pos,dir,R,TRUE);//true, 1 pos.set(-3,-3,-3);dir.set(1,1,1);dir.normalize();R=10; RAYvsCYLINDER(c,pos,dir,R,TRUE);//true, ? float ir[2]; c.intersect(pos,dir,ir); // pos.set(0,0,0); RAYvsCYLINDER(c,pos,dir,R,FALSE);//true, ? c.intersect(pos,dir,ir); RAYvsCYLINDER(c,pos,dir,R,TRUE);//false CTimer t;t.Start(); for(int i=0;i<1000000;i++) { Fcylinder c; c.m_center.random_point(Fvector().set(2,2,2)); c.m_direction.random_dir(); c.m_height=Random.randF(0.2f,2.f); c.m_radius=Random.randF(0.1f,2.f); //ray Fvector dir,pos;float R=Random.randF(0.1f,2.f); dir.random_dir();pos.random_point(Fvector().set(2,2,2)); RAYvsCYLINDER(c,pos,dir,R,TRUE); } Msg("my RAYvsCYLINDE time %f ms",t.GetElapsed_sec()*1000.f); t.Start(); for(int i=0;i<1000000;i++) { Fcylinder c; c.m_center.random_point(Fvector().set(2,2,2)); c.m_direction.random_dir(); c.m_height=Random.randF(0.2f,2.f); c.m_radius=Random.randF(0.1f,2.f); //ray Fvector dir,pos;//float R=Random.randF(0.1f,2.f); dir.random_dir();pos.random_point(Fvector().set(2,2,2)); c.intersect(pos,dir,ir); } Msg("current intersect time %f ms",t.GetElapsed_sec()*1000.f); }
virtual void Execute(LPCSTR args) { #if 0 if (!Level().autosave_manager().ready_for_autosave()) { Msg ("! Cannot save the game right now!"); return; } #endif if(!IsGameTypeSingle()){ Msg("for single-mode only"); return; } if(!g_actor || !Actor()->g_Alive()) { Msg("cannot make saved game because actor is dead :("); return; } string_path S,S1; S[0] = 0; //. sscanf (args ,"%s",S); strcpy_s (S,args); #ifdef DEBUG CTimer timer; timer.Start (); #endif if (!xr_strlen(S)){ strconcat (sizeof(S),S,Core.UserName,"_","quicksave"); NET_Packet net_packet; net_packet.w_begin (M_SAVE_GAME); net_packet.w_stringZ(S); net_packet.w_u8 (0); Level().Send (net_packet,net_flags(TRUE)); }else{ if(!valid_file_name(S)){ Msg("invalid file name"); return; } NET_Packet net_packet; net_packet.w_begin (M_SAVE_GAME); net_packet.w_stringZ(S); net_packet.w_u8 (1); Level().Send (net_packet,net_flags(TRUE)); } #ifdef DEBUG Msg ("Game save overhead : %f milliseconds",timer.GetElapsed_sec()*1000.f); #endif SDrawStaticStruct* _s = HUD().GetUI()->UIGame()->AddCustomStatic("game_saved", true); _s->m_endTime = Device.fTimeGlobal+3.0f;// 3sec string_path save_name; strconcat (sizeof(save_name),save_name,*CStringTable().translate("st_game_saved"),": ", S); _s->wnd()->SetText (save_name); strcat (S,".dds"); FS.update_path (S1,"$game_saves$",S); #ifdef DEBUG timer.Start (); #endif MainMenu()->Screenshot (IRender_interface::SM_FOR_GAMESAVE,S1); #ifdef DEBUG Msg ("Screenshot overhead : %f milliseconds",timer.GetElapsed_sec()*1000.f); #endif }