// static void LLFrameTimer::updateFrameTime() { U64 total_time = totalTime(); sFrameDeltaTime = total_time - sTotalTime; sTotalTime = total_time; sTotalSeconds = U64_to_F64(sTotalTime) * USEC_TO_SEC_F64; sFrameTime = U64_to_F64(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64; }
void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) { LLMemType mt(LLMemType::MTYPE_OBJECT); // Update globals gVelocityInterpolate = gSavedSettings.getBOOL("VelocityInterpolate"); gPingInterpolate = gSavedSettings.getBOOL("PingInterpolate"); gAnimateTextures = gSavedSettings.getBOOL("AnimateTextures"); // update global timer F32 last_time = gFrameTimeSeconds; U64 time = totalTime(); // this will become the new gFrameTime when the update is done // Time _can_ go backwards, for example if the user changes the system clock. // It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here. // llassert(time > gFrameTime); F64 time_diff = U64_to_F64(time - gFrameTime)/(F64)SEC_TO_MICROSEC; gFrameTime = time; F64 time_since_start = U64_to_F64(gFrameTime - gStartTime)/(F64)SEC_TO_MICROSEC; gFrameTimeSeconds = (F32)time_since_start; gFrameIntervalSeconds = gFrameTimeSeconds - last_time; if (gFrameIntervalSeconds < 0.f) { gFrameIntervalSeconds = 0.f; } //clear avatar LOD change counter LLVOAvatar::sNumLODChangesThisFrame = 0; const F64 frame_time = LLFrameTimer::getElapsedSeconds(); std::vector<LLViewerObject*> kill_list; S32 num_active_objects = 0; LLViewerObject *objectp = NULL; // Make a copy of the list in case something in idleUpdate() messes with it std::vector<LLViewerObject*> idle_list; idle_list.reserve( mActiveObjects.size() ); for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin(); active_iter != mActiveObjects.end(); active_iter++) { objectp = *active_iter; if (objectp) { idle_list.push_back( objectp ); } else { // There shouldn't be any NULL pointers in the list, but they have caused // crashes before. This may be idleUpdate() messing with the list. llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl; } } if (gSavedSettings.getBOOL("FreezeTime")) { for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin(); iter != idle_list.end(); iter++) { objectp = *iter; if (objectp->getPCode() == LLViewerObject::LL_VO_CLOUDS || objectp->isAvatar()) { objectp->idleUpdate(agent, world, frame_time); } } } else { for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin(); idle_iter != idle_list.end(); idle_iter++) { objectp = *idle_iter; if (!objectp->idleUpdate(agent, world, frame_time)) { // If Idle Update returns false, kill object! kill_list.push_back(objectp); } else { num_active_objects++; } } for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin(); kill_iter != kill_list.end(); kill_iter++) { objectp = *kill_iter; killObject(objectp); } } mNumSizeCulled = 0; mNumVisCulled = 0; // compute all sorts of time-based stats // don't factor frames that were paused into the stats if (! mWasPaused) { gViewerStats->updateFrameStats(time_diff); } /* // Debugging code for viewing orphans, and orphaned parents LLUUID id; char id_str[UUID_STR_LENGTH + 20]; for (i = 0; i < mOrphanParents.count(); i++) { id = sIndexAndLocalIDToUUID[mOrphanParents[i]]; LLViewerObject *objectp = findObject(id); if (objectp) { sprintf(id_str, "Par: "); objectp->mID.toString(id_str + 5); addDebugBeacon(objectp->getPositionAgent(), id_str, LLColor4(1.f,0.f,0.f,1.f), LLColor4(1.f,1.f,1.f,1.f)); } } LLColor4 text_color; for (i = 0; i < mOrphanChildren.count(); i++) { OrphanInfo oi = mOrphanChildren[i]; LLViewerObject *objectp = findObject(oi.mChildInfo); if (objectp) { if (objectp->getParent()) { sprintf(id_str, "ChP: "); text_color = LLColor4(0.f, 1.f, 0.f, 1.f); } else { sprintf(id_str, "ChNoP: "); text_color = LLColor4(1.f, 0.f, 0.f, 1.f); } id = sIndexAndLocalIDToUUID[oi.mParentInfo]; objectp->mID.toString(id_str + 8); addDebugBeacon(objectp->getPositionAgent() + LLVector3(0.f, 0.f, -0.25f), id_str, LLColor4(0.25f,0.25f,0.25f,1.f), text_color); } i++; } */ mNumObjectsStat.addValue(mObjects.count()); mNumActiveObjectsStat.addValue(num_active_objects); mNumSizeCulledStat.addValue(mNumSizeCulled); mNumVisCulledStat.addValue(mNumVisCulled); }
// static // Return seconds since the current frame started F32 LLFrameTimer::getCurrentFrameTime() { U64 frame_time = totalTime() - sTotalTime; return (F32)(U64_to_F64(frame_time) * USEC_TO_SEC_F64); }
// static F32 LLFrameTimer::getFrameDeltaTimeF32() { return (F32)(U64_to_F64(sFrameDeltaTime) * USEC_TO_SEC_F64); }
F64 LLFrameTimer::expiresAt() const { F64 expires_at = U64_to_F64(sStartTotalTime) * USEC_TO_SEC_F64; expires_at += mExpiry; return expires_at; }
#include "linden_common.h" #include "u64.h" #include "llframetimer.h" // Local constants. static F64 const USEC_PER_SECOND = 1000000.0; static F64 const USEC_TO_SEC_F64 = 0.000001; // Static members U64 const LLFrameTimer::sStartTotalTime = totalTime(); // Application start in microseconds since epoch. U64 LLFrameTimer::sTotalTime = LLFrameTimer::sStartTotalTime; // Current time in microseconds since epoch, updated at least once per frame. F64 LLFrameTimer::sTotalSeconds = // Current time in seconds since epoch, updated together with LLFrameTimer::sTotalTime. U64_to_F64(LLFrameTimer::sTotalTime) * USEC_TO_SEC_F64; F64 LLFrameTimer::sFrameTime = 0.0; // Current time in seconds since application start, updated together with LLFrameTimer::sTotalTime. // Updated exactly once per frame: S32 LLFrameTimer::sFrameCount = 0; // Current frame number (number of frames since application start). U64 LLFrameTimer::sPrevTotalTime = LLFrameTimer::sStartTotalTime; // Previous (frame) time in microseconds since epoch, updated once per frame. U64 LLFrameTimer::sFrameDeltaTime = 0; // Microseconds between last two calls to LLFrameTimer::updateFrameTimeAndCount. // static void LLFrameTimer::updateFrameTime() { sTotalTime = totalTime(); sTotalSeconds = U64_to_F64(sTotalTime) * USEC_TO_SEC_F64; sFrameTime = U64_to_F64(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64; } // static