void RuntimeScene::ManageObjectsAfterEvents() { //Delete objects that were removed. RuntimeObjList allObjects = objectsInstances.GetAllObjects(); for (unsigned int id = 0;id<allObjects.size();++id) { if ( allObjects[id]->GetName().empty() ) { for (unsigned int i = 0;i<extensionsToBeNotifiedOnObjectDeletion.size();++i) extensionsToBeNotifiedOnObjectDeletion[i]->ObjectDeletedFromScene(*this, allObjects[id].get()); objectsInstances.RemoveObject(allObjects[id]); //Remove from objects instances, not from the temporary list! } } //Update objects positions, forces and automatisms allObjects = objectsInstances.GetAllObjects(); for (unsigned int id = 0;id<allObjects.size();++id) { allObjects[id]->SetX( allObjects[id]->GetX() + ( allObjects[id]->TotalForceX() * static_cast<double>(GetElapsedTime())/1000000.0 )); allObjects[id]->SetY( allObjects[id]->GetY() + ( allObjects[id]->TotalForceY() * static_cast<double>(GetElapsedTime())/1000000.0 )); allObjects[id]->UpdateTime( static_cast<double>(GetElapsedTime())/1000000.0 ); allObjects[id]->UpdateForce( static_cast<double>(GetElapsedTime())/1000000.0 ); allObjects[id]->DoAutomatismsPostEvents(*this); } }
void GpuProfilerD3D11::Report(const char* reportFile) { FILE* f = fopen(reportFile, "w"); if (f) { HQTime frameTime = GetElapsedTime(m_frameTimeQuery); fprintf(f, "total time = %f ms\nfps = %f\n", frameTime * 1000.f, 1.0f / frameTime); HQTime collectedSubframesTime = 0.f; for (std::unordered_map<std::string, SubframeQuery>::iterator ite = m_subframes.begin(); ite != m_subframes.end(); ++ite) { HQTime seconds = GetElapsedTime(ite->second); collectedSubframesTime += seconds; float ms = seconds * 1000.f; fprintf(f, "%s = %f ms\n", ite->first.c_str(), ms); } fprintf(f, "collected subframes time = %f ms\n", collectedSubframesTime * 1000.f); fprintf(f, "uncollected subframes time = %f ms\n", (frameTime - collectedSubframesTime) * 1000.f); } fclose(f); }
// 指定距離移動 void ExtraStageLookUp::MoveDist( char cLRsw, // ライントレース位置 'L':左、'R':右、'N':トレースなし int nDist, // 移動距離 mm単位 float fTailAngle, int nForward ) { //-----ログ出力----- char* cLogBuff = m_pUIGet->GetBlueT()->pcLogBuff; //------------------ DV dv; int32_t nLmotorCountS = m_pDeviceInterface->m_pCLeftMotor->getCount(); int32_t nRmotorCountS = m_pDeviceInterface->m_pCRightMotor->getCount(); int32_t nMotorCountS = ( nLmotorCountS + nRmotorCountS ) / 2; while(1){ int32_t nLmotorCountN = m_pDeviceInterface->m_pCLeftMotor->getCount(); int32_t nRmotorCountN = m_pDeviceInterface->m_pCRightMotor->getCount(); int32_t nMotorCountN = ( nLmotorCountN + nRmotorCountN ) / 2; int32_t nRunCount = nMotorCountN - nMotorCountS; double dRunDist = GetRunDistance(nRunCount); //オフセット付き角位置から距離mmに変換 if( dRunDist >= (double)nDist ){ //-----ログ出力----- sprintf(cLogBuff,"MoveDist %lu, nDist=%d, nRunCount=%ld, dRunDist=%f\n", GetElapsedTime(), nDist, nRunCount, dRunDist); m_pUIGet->WriteLog(cLogBuff); //------------------ break; } // ライントレース制御 dv = CalcuTraceMoterPower( cLRsw, nForward ); // モータードライブ m_pMotorDrive->TailMotorDrive(fTailAngle); m_pMotorDrive->LRMotorDrive( dv.Lmotor_pwm, dv.Rmotor_pwm ); //ログ出力 sprintf(cLogBuff,"ExtraRun MoveDist %lu, cLRsw=[%c], nDist=%d, fTailAngle=%f, nForward=%d, color=%d, Lmotor_pwm=%d, Rmotor_pwm=%d\n", GetElapsedTime(), cLRsw, nDist, fTailAngle, nForward, dv.color, dv.Lmotor_pwm, dv.Rmotor_pwm ); m_pDeviceInterface->m_pCClock->sleep(4); // 4msec周期起動 if( IsKeyBreak(fTailAngle) ) break; } }
// ゲートに行く void ExtraStageLookUp::GoGate( char cLRsw, // ライントレース位置 'L':左、'R':右、'N':トレースなし float fTailAngle ) { //-----ログ出力----- char* cLogBuff = m_pUIGet->GetBlueT()->pcLogBuff; //------------------ DV dv; int nForward = 10; // 走行速度 // int16_t nDistanceMin = 5; // ソナーセンサー距離cm int16_t nDistanceMin = 7; // ソナーセンサー距離cm int16_t nDistance = m_pDeviceInterface->m_pCSonarSensor->getDistance(); for(int i=0 ; ; i++ ){ if( i % 10 == 9 ){ // 40ミリ秒毎にソナー検出 nDistance = m_pDeviceInterface->m_pCSonarSensor->getDistance(); } if( nDistance <= nDistanceMin ){ // ゲート前に到着 //ログ出力 sprintf(cLogBuff,"ExtraRun GoGate %lu, nDistance=%d\n", GetElapsedTime(), nDistance); m_pUIGet->WriteLog(cLogBuff); break; } // ライントレース制御 dv = CalcuTraceMoterPower( cLRsw, nForward ); // モータードライブ m_pMotorDrive->TailMotorDrive(fTailAngle); m_pMotorDrive->LRMotorDrive(dv.Lmotor_pwm, dv.Rmotor_pwm); //ログ出力 sprintf(cLogBuff,"ExtraRun GoGate %lu, cLRsw=[%c], nDistance=%d, fTailAngle=%f, nForward=%d, color=%d, Lmotor_pwm=%d, Rmotor_pwm=%d\n", GetElapsedTime(), cLRsw, nDistance, fTailAngle, nForward, dv.color, dv.Lmotor_pwm, dv.Rmotor_pwm ); m_pUIGet->WriteLog(cLogBuff); m_pDeviceInterface->m_pCClock->sleep(4); // 4msec周期起動 if( IsKeyBreak(fTailAngle) ) break; } }
void Body::UpdateBody(void) { if(IsUnmovable()) { m_linearVelocity = Vector2(0.0f,0.0f); m_angularVelocity = 0.0f; return; } float elapsedTime = GetElapsedTime(); // Apply damping m_linearVelocity -= m_linearVelocity * m_linearDamping * elapsedTime; m_angularVelocity -= m_angularVelocity * m_angularDamping * elapsedTime; // Apply damping forces //m_force -= m_linearVelocity * m_linearDamping * elapsedTime; //m_torque -= m_angularVelocity * m_angularDamping * elapsedTime; // Euler (First Order Taylor Expansion) // Integrate position //m_position += m_linearVelocity * elapsedTime; //m_orientation += m_angularVelocity * elapsedTime; // Integrate velocity //m_linearVelocity += m_force * (m_inverseMass * elapsedTime); //m_angularVelocity += m_torque * (m_inverseInertia * elapsedTime); // Second Order Taylor Expansion // Integrate position m_position += m_linearVelocity * GetElapsedTime() + 0.5f * m_force * m_inverseMass * elapsedTime * elapsedTime; m_orientation += m_angularVelocity * GetElapsedTime() + 0.5f * m_torque * m_inverseInertia * elapsedTime * elapsedTime; // Remove accumulated rotation while(m_orientation > M_PI*2) m_orientation -= M_PI*2; // Integrate velocity m_linearVelocity += m_force * m_inverseMass * elapsedTime; m_angularVelocity += m_torque * m_inverseInertia * elapsedTime; // Clear forces m_force.SetEmpty(); m_torque = 0.0f; // Integrator stability test //Sleep(rand() % 40); }
void StarSystem::Update( float priority ) { Unit *unit; bool firstframe = true; //No time compression here float normal_simulation_atom = SIMULATION_ATOM; time += GetElapsedTime(); _Universe->pushActiveStarSystem( this ); if ( time/SIMULATION_ATOM >= (1./PHY_NUM) ) { while ( time/SIMULATION_ATOM >= (1.) ) { //Chew up all SIMULATION_ATOMs that have elapsed since last update ExecuteDirector(); TerrainCollide(); Unit::ProcessDeleteQueue(); current_stage = MISSION_SIMULATION; collidetable->Update(); for (un_iter iter = drawList.createIterator(); (unit = *iter); ++iter) unit->SetNebula( NULL ); UpdateMissiles(); //do explosions UpdateUnitPhysics( firstframe ); firstframe = false; } time -= SIMULATION_ATOM; } SIMULATION_ATOM = normal_simulation_atom; _Universe->popActiveStarSystem(); }
void Emitter::UpdateParticles(void) { static const float linearDamping = 0.2f; for(unsigned long i = 0; i < _countof(m_particles); ++i) { if(m_particles[i].m_velocity.GetLength() < 0.0001f) continue; // Linear Taylor Expansion m_particles[i].m_position += m_particles[i].m_velocity * GetElapsedTime(); // Simple velocity damping m_particles[i].m_velocity -= m_particles[i].m_velocity * linearDamping * GetElapsedTime(); } }
void CNetGame::Process() { float fElapsedTime = GetElapsedTime(); UpdateNetwork(); if(this->gameState == 1) { if(this->playerPool) this->playerPool->Process(fElapsedTime); if(this->vehiclePool) this->vehiclePool->Process(fElapsedTime); if(this->objectPool) this->objectPool->Process(fElapsedTime); if(this->gamemodeManager) this->gamemodeManager->Frame(fElapsedTime); if(this->scriptTimerManager) this->scriptTimerManager->Process((uint32_t)(fElapsedTime * 1000.0f)); if(this->scriptHttpManager) this->scriptHttpManager->Process(); if ( __ElementFactory ) __ElementFactory->Process ( fElapsedTime ); } else if(this->gameState == 2) { fRestartWaitTime += fElapsedTime; if(fRestartWaitTime > 12.0f) { ReInitWhenRestarting(); } } if (__Console->GetBoolVar("announce")) MasterServerAnnounce(fElapsedTime); __Plugins->DoProcessTick(); #ifndef WIN32 this->elapsedTime += (double)fElapsedTime; #endif }
void MenuElement::DrawTooltip( void ) { #if 0 //FIXME: re-implement after redesigning menu elements if ( common.hidden ) { return; } const real64_t currentTime = GetElapsedTime(); if ( tooltip.mouseHovering ) { tooltip.lastMouseTime = currentTime; } const real64_t fadeTime = 333.0; if ( /*!updatingValue &&*/ tooltip.lastMouseTime > currentTime - fadeTime ) { const real32_t alpha = static_cast<real32_t>( 1.0 - ((currentTime - tooltip.lastMouseTime) / fadeTime) ); static const vector4 colour = { 1.0f, 1.0f, 1.0f, alpha }; const vector2 pos = { (tooltip.lastMousePos[0] + 0.03333f) * Renderer::rdState.window.width, tooltip.lastMousePos[1] * Renderer::rdState.window.height }; tooltip.font->Draw( pos, tooltip.text, tooltip.pointSize, &colour ); } #endif }
int GetFrame() { // Acquire frame printf("Acquiring from webcam frame number %d\n",frame_counter); gettimeofday(&step_start_time,NULL); if ( AcquisitionLoopV4L2(fg_v4l2,fr) != 0) { printf("Unexpexted error when acquiring frame v4l2 device \n"); return -1; } gettimeofday(&step_end_time,NULL); GetElapsedTime("Frame acquisition", &step_start_time, &step_end_time, &acquisition_time ); // If required, save one out of n_save_frame frames in a .ppm file if ( SAVE_FRAMES ) { if ( (frame_counter%n_save_frame) == 0){ snprintf( frame_fname, sizeof(frame_fname), "frame_%d.ppm",frame_counter ); SaveFrame(fr, frame_fname); printf("Frame %d saved to file \n",frame_counter); } } return 0; }
/** * Give the async task time to do its work * Can only be called on the async task manager thread */ void FOnlineAsyncTaskSteamLogoffServer::Tick() { if (!bInit) { // @TODO ONLINE Listen Servers need to unset rich presence //SteamFriends()->SetRichPresence("connect", ""); for master server sessions SteamGameServer()->EnableHeartbeats(false); SteamGameServer()->LogOff(); bInit = true; } // Wait for the disconnect FOnlineSessionSteamPtr SessionInt = StaticCastSharedPtr<FOnlineSessionSteam>(Subsystem->GetSessionInterface()); if (!SessionInt->bSteamworksGameServerConnected && !SessionInt->GameServerSteamId.IsValid()) { bIsComplete = true; bWasSuccessful = true; } else { // Fallback timeout in case we don't hear from Steam if (GetElapsedTime() >= ASYNC_TASK_TIMEOUT) { SessionInt->bSteamworksGameServerConnected = false; SessionInt->GameServerSteamId = NULL; bIsComplete = true; bWasSuccessful = false; } } }
// IdleFunc() // Idle function for between frames void IdleFunc(void) { float deltaTime; // Mark time MarkTimeThisTick(); deltaTime = GetElapsedTime() * GAME_SPEED; // Call the display routine next time through the main loop glutPostRedisplay(); HUDClearScreen(); HUDPrintToScreen( "There is nothing to see but these text strings!!!\n\n" ); HUDPrintToScreen( "This app shows a bare minimum AI engine implemented.\n" ); HUDPrintToScreen( "Below you'll see the states of forty different game\n" ); HUDPrintToScreen( "objects as they wander around in space. See if you\n" ); HUDPrintToScreen( "can find a pattern. Then check the code to see if\n" ); HUDPrintToScreen( "you're right. Hint: Great AI makes the player believe\n" ); HUDPrintToScreen( "that the game is smarter than it really is.\n\n\n" ); //Send any messages that have been waiting SendDelayedMessages(); // Update all game objects in the AI engine GODBUpdate(); GODBOutputStateInfoToHUD(); }
void System::gameLoop(){ SDL_Event Event; bool running = true; while(running) { while(SDL_PollEvent(&Event)) { switch( Event.type ){ case SDL_KEYDOWN: case SDL_KEYUP: mInputHandler->KeyDown( Event.key.keysym.sym , Event.key.state == SDL_PRESSED ); break; case SDL_MOUSEMOTION: mInputHandler->MouseMoved( Event.motion.x, Event.motion.y ); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: mInputHandler->MouseDown( Event.button.button, Event.button.state == SDL_PRESSED, Event.button.x, Event.button.y ); break; case SDL_QUIT: running = false; break; default: break; } } mObjectMgr->Update(GetElapsedTime()); mRenderer->drawScene(); } return; }
RetCode StmtHandler::Execute(ExecutedResult* exec_result) { GETCURRENTTIME(start_time); RetCode ret = rSuccess; sql_parser_ = new Parser(sql_stmt_); AstNode* raw_ast = sql_parser_->GetRawAST(); if (NULL == raw_ast) { exec_result->error_info_ = "Parser Error"; exec_result->status_ = false; exec_result->result_ = NULL; return rParserError; } raw_ast->Print(); ret = GenerateStmtExec(raw_ast); if (rSuccess != ret) { return ret; } ret = stmt_exec_->Execute(exec_result); if (rSuccess != ret) { return ret; } double exec_time_ms = GetElapsedTime(start_time); if (NULL != exec_result->result_) exec_result->result_->query_time_ = exec_time_ms / 1000.0; cout << "execute time: " << exec_time_ms / 1000.0 << " sec" << endl; return rSuccess; }
bool PointStarVlist::BeginDrawState (const QVector ¢er, const Vector & velocity, const Vector & torque, bool roll, bool yawpitch, int whichTexture) { UpdateGraphics(); static bool StarStreaks=XMLSupport::parse_bool(vs_config->getVariable("graphics","star_streaks","false")); GFXColorMaterial(AMBIENT|DIFFUSE); bool ret=false; if (StarStreaks) { Matrix rollMatrix; static float velstreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_scale","5")); static float minstreak= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_min","1")); static float fov_smoothing=XMLSupport::parse_float(vs_config->getVariable("graphics","warp.fovlink.smoothing",".4")); float fov_smoot = pow(double(fov_smoothing),GetElapsedTime()); Vector vel (-velocity*velstreakscale); float speed = vel.Magnitude(); if ((smoothstreak>=minstreak||vel.MagnitudeSquared()>=minstreak*minstreak)&&(speed>1.0e-7)) { ret=true; vel*=1./speed; speed = fov_smoot*speed + (1-fov_smoot)*smoothstreak; if (speed<minstreak) speed=minstreak; static float streakcap = XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_max","100")); if (speed>streakcap) { speed=streakcap; } vel=vel*speed; smoothstreak=speed; GFXColorVertex * v = vlist->BeginMutate(0)->colors; int numvertices = vlist->GetNumVertices(); static float torquestreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","torque_star_streak_scale","1")); for (int j=0; j<numvertices-1; j+=2) { int i=j; // if (SlowStarStreaks) // i=((rand()%numvertices)/2)*2; Vector vpoint (v[i+1].x,v[i+1].y,v[i+1].z); Vector recenter =(vpoint-center.Cast()); if (roll) { RotateAxisAngle(rollMatrix,torque,torque.Magnitude()*torquestreakscale*.003); vpoint = Transform(rollMatrix,recenter)+center.Cast(); } v[i].x=vpoint.i-vel.i; v[i].y=vpoint.j-vel.j; v[i].z=vpoint.k-vel.k; // static float NumSlowStarStreaks=XMLSupport::parse_float(vs_config->getVariable("graphics","num_star_streaks",".05")); // if (SlowStarStreaks&&j<NumSlowStarStreaks*numvertices) // break; } vlist->EndMutate(); } } if (ret) { vlist->LoadDrawState(); vlist->BeginDrawState(); } else { nonstretchvlist->LoadDrawState(); nonstretchvlist->BeginDrawState(); } return ret; }
//Stop Timining void CStopWatch::Stop() { if(m_bIsRunning) { m_dElapsedTime += GetElapsedTime(); m_bIsRunning = false; } }
void CInstance::CheckTime(uint32 tick) { if (m_lastTimeCheck + 1000 <= tick && !Failed()) { luautils::OnInstanceTimeUpdate(m_zone, this, GetElapsedTime(tick)); m_lastTimeCheck = tick; } }
void StopWatch::Pause() { if (m_paused) { return; } m_elapsed += GetElapsedTime(); m_paused = true; }
void SplashState::UpdateFixed(void) { // Drop our state after 10 seconds have elapsed if(false == IsPaused() && GetElapsedTime() > mSplashDelay) { mApp.mStateManager.RemoveActiveState(); } }
Uint32 StopWatch::Time() const { Uint32 ret = m_t0 + m_elapsed; if (!m_paused) { ret += GetElapsedTime(); } return ret; }
wxULongLong wxDownloadEvent::GetDownloadSpeed() const { wxTimeSpan sec = GetElapsedTime(); if (sec.GetSeconds() == 0) return 0; // avoid division by zero // returned value is in bytes per second return (wxULongLong_t)(m_curr.ToDouble() / sec.GetSeconds().ToDouble()); }
void GpuProfilerD3D11::IterateCollectedSubframes(SubframeIteratorListener* listener) { for (std::unordered_map<std::string, SubframeQuery>::iterator ite = m_subframes.begin(); ite != m_subframes.end(); ++ite) { float seconds = GetElapsedTime(ite->second); listener->CollectSubframeReport(ite->first.c_str(), seconds); } }
void MusicRenderer::RenderToSpeaker() { SoundEvent currentSoundEvent; unsigned int duration = m_header.Duration[m_difficulty] * 1000 + 1000; std::vector<SoundEvent>::size_type eventCtr = 0, totalEvents = m_soundEvents->size(); unsigned int elapsed = 0; int percentage = 0; printf("0%%"); BeginTimer(); while(elapsed < duration) { if(eventCtr < totalEvents) { currentSoundEvent = m_soundEvents->at(eventCtr); if(currentSoundEvent.Time <= elapsed) { if(currentSoundEvent.NoteType != 3) { int sampleIndex = -1; if(currentSoundEvent.NoteType == 4) sampleIndex = GetSample(currentSoundEvent.RefID + 1000); else sampleIndex = GetSample(currentSoundEvent.RefID); if(sampleIndex >= 0) { Sample sample = m_samples->at(sampleIndex); FMOD_RESULT result = m_fmod->playSound(FMOD_CHANNEL_FREE, sample.Data, false, 0); } } eventCtr++; } } m_fmod->update(); UpdateTimer(); elapsed = GetElapsedTime(); if(percentage < 10) printf("\b\b"); else if(percentage < 100) printf("\b\b\b"); else printf("\b\b\b\b"); percentage = (int)((float)elapsed / (float)duration * 100.f); printf("%d%%", percentage); } StopTimer(); }
void GreenState::UpdateFixed(void) { // Check our App pointer assert(NULL != game && "SplashState::UpdateFixed() bad app pointer, init must be called first"); // Drop our state after 10 seconds have elapsed if(false == IsPaused() && GetElapsedTime() > 10.0f) { game->stateManager.RemoveActiveState(); } }
//-------------------------------------------------------------------------- /// Retrieve basic timing and API usage information by filling in a FrameInfo /// instance. /// \param outFrameInfo The FrameInfo structure that will be populated with data. //-------------------------------------------------------------------------- void DX12LayerManager::GetFrameInfo(FrameInfo& outFrameInfo) { outFrameInfo.mTotalElapsedTime = GetElapsedTime(); outFrameInfo.mFrameDuration = GetCPUFrameDuration(); // @TODO: For now, use the DX12TraceAnalyzerLayer to retrieve the number of API calls. // In the future, we should be able to query the Frame Capture system's database for this info. DX12TraceAnalyzerLayer* traceAnalyzer = DX12TraceAnalyzerLayer::Instance(); outFrameInfo.mAPICallCount = traceAnalyzer->GetNumTracedAPICalls(); outFrameInfo.mDrawCallCount = traceAnalyzer->GetNumTracedDrawCalls(); }
void CTimer::Toc(CTString strTitle) { _ftime( &timebuffer_end);//获取结束时间 double dElapsed_time = GetElapsedTime();//获取消耗时间; if(stream == NULL) return; fprintf( stream, strTitle + " \nElapsed time :%.4f seconds\n\n",dElapsed_time ); _ftime( &timebuffer_begin);//chon获取结束时间 }
U32 C_TIMER::GetRemainedTime() { U32 elapsedTime = GetElapsedTime(); if(countMs <= elapsedTime) { return 0; } else { return countMs - elapsedTime; } }
static NTSTATUS CompleteOriginalIrp (EncryptedIoQueueItem *item, NTSTATUS status, ULONG_PTR information) { #ifdef TC_TRACE_IO_QUEUE Dump ("< %I64d [%I64d] %c status=%x info=%I64d\n", item->OriginalIrpOffset, GetElapsedTime (&item->Queue->LastPerformanceCounter), item->Write ? 'W' : 'R', status, (int64) information); #endif TCCompleteDiskIrp (item->OriginalIrp, status, information); item->Status = status; OnItemCompleted (item, TRUE); return status; }
HRESULT CGraphics::Update(void) { AUTO_SECTION(m_UpdateSection); FLOAT factor = min(GetElapsedTime() * m_Speed,1.0f); if(IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) { // Update the levels for(UINT i = 0; i < VISUALIZATION_BARCOUNT; i += 4) { //SSELerpArr(m_Levels + i,m_Levels + i,m_LevelsBuffer + i,factor); _mm_store_ps(m_Levels + i,_mm_add_ps(_mm_mul_ps(_mm_sub_ps(_mm_load_ps(m_LevelsBuffer + i),_mm_load_ps(m_Levels + i)),_mm_load_ps1(&factor)),_mm_load_ps(m_Levels + i))); } // Update the waveform for(UINT i = 0; i < SA_BUFFER_SIZE; i += 4) { //SSELerpArr(m_Waveform + i,m_Waveform + i,m_WaveformBuffer + i,factor); _mm_store_ps(m_Waveform + i,_mm_add_ps(_mm_mul_ps(_mm_sub_ps(_mm_load_ps(m_WaveformBuffer + i),_mm_load_ps(m_Waveform + i)),_mm_load_ps1(&factor)),_mm_load_ps(m_Waveform + i))); } } else { // Update the levels for(UINT i = 0; i < VISUALIZATION_BARCOUNT; ++i) m_Levels[i] = m_Levels[i] + min(GetElapsedTime() * m_Speed,1.0f) * (m_LevelsBuffer[i] - m_Levels[i]); // Update the waveform for(UINT i = 0; i < SA_BUFFER_SIZE; ++i) m_Waveform[i] = m_Waveform[i] + min(GetElapsedTime() * m_Speed,1.0f) * (m_WaveformBuffer[i] - m_Waveform[i]); } // Go through all the peaks and update each for(UINT i = 0; i < VISUALIZATION_BARCOUNT; ++i) { // Update the position and velocity if(m_Peaks[i].timeout <= 0.0f) { m_Peaks[i].position += m_Peaks[i].velocity * min(GetElapsedTime(),1.0f); m_Peaks[i].velocity += m_PeakGravity * min(GetElapsedTime(),1.0f); } else m_Peaks[i].timeout -= min(GetElapsedTime(),1.0f); // Check if it has collided with a bar if(m_Peaks[i].position < m_Levels[i]) { m_Peaks[i].position = m_Levels[i]; m_Peaks[i].velocity = 0.0f; m_Peaks[i].timeout = m_PeakTimeout; } } return S_OK; }
/*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ std::string PowerStats::Measure() { std::string response("{"); response += "\"elapsed_time\":" + GetElapsedTime(); // CPU busy time (seconds) response += ",\"cpu_time\":" + GetCPUTime(); // Power Data (including elapsed time) response += GetPowerData(); response += "}"; return response; }