本文整理汇总了C++中Timer::GetMs方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetMs方法的具体用法?C++ Timer::GetMs怎么用?C++ Timer::GetMs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetMs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessParticles
/// Integrates all particles.
void PrecipitationSystem::ProcessParticles(float & timeInSeconds)
{
Timer timer;
timer.Start();
#ifdef USE_SSE
__m128 sseTime = _mm_load1_ps(&timeInSeconds);
#endif
/// Move/Process all alive particles
const Vector3f wind = weather->globalWind;
for (int i = 0; i < aliveParticles; ++i)
{
#ifdef SSE_PARTICLES
positionsSSE[i].data = _mm_add_ps(positionsSSE[i].data, _mm_mul_ps(sseTime, _mm_add_ps(velocitiesSSE[i].data, wind.data)));
#else // Not SSE_PARTICLES
// Using SSE commands straight away reduced computation time to like 1 ms from 150ms when many particles were around (towards 500k somewhere)
#ifdef USE_SSE
positions[i].data = _mm_add_ps(positions[i].data, _mm_mul_ps(sseTime, _mm_add_ps(velocities[i].data, weather->globalWind.data)));
#else
positions[i] += (velocities[i] + weather->globalWind)* timeInSeconds;
#endif // USE_SSE
#endif // SSE_PARTICLES
}
timer.Stop();
FrameStats.particleProcessingIntegrate += timer.GetMs();
timer.Start();
for (int i = 0; i < aliveParticles; ++i)
{
#ifdef SSE_PARTICLES
ldsSSE[i].y += timeInSeconds;
#else // Not SSE_PARTICLES
// No velocity decay.
lifeDurations[i] += timeInSeconds;
#endif // SSE_PARTICLES
}
timer.Stop();
FrameStats.particleProcessingOldify = timer.GetMs();
timer.Start();
for (int i = 0; i < aliveParticles; ++i)
{
#ifdef SSE_PARTICLES
if (ldsSSE[i].y > ldsSSE[i].x)
{
int lastIndex = aliveParticles - 1;
positionsSSE[i] = positionsSSE[lastIndex];
velocitiesSSE[i] = velocitiesSSE[lastIndex];
colorsSSE[i] = colorsSSE[lastIndex];
ldsSSE[i] = ldsSSE[lastIndex];
// Decrement i so we don't skip processing of the one we moved back.
--i;
// Decrement alive particles.
--aliveParticles;
}
#else // Not SSE_PARTICLES
// If duration has elapsed life-time..
if (lifeDurations[i] > lifeTimes[i])
{
int lastIndex = aliveParticles - 1;
// Kill it, by moving in the last used data to replace it.
positions[i] = positions[lastIndex];
velocities[i] = velocities[lastIndex];
lifeDurations[i] = lifeDurations[lastIndex];
colors[i] = colors[lastIndex];
lifeTimes[i] = lifeTimes[lastIndex];
scales[i] = scales[lastIndex];
// Decrement i so we don't skip processing of the one we moved back.
--i;
// Decrement alive particles.
--aliveParticles;
}
#endif
}
timer.Stop();
FrameStats.particleProcessingRedead += timer.GetMs();
}
示例2: ProcessPhysics
//.........这里部分代码省略.........
entity->physics->UpdateProperties(entity);
// Re-calculate transform matrix, as it was probably affected..?
entity->RecalculateMatrix(Entity::ALL_PARTS);
if (estimator->finished)
{
estimators.RemoveIndex(j, ListOption::RETAIN_ORDER);
--j;
delete estimator;
}
}
}
/// Awesome.
Integrate(newStepSize);
/// Apply external constraints
// ApplyContraints();
/// Apply pathfinding for all relevant entities - should be done in separate property-files. Or in more dedicated classes for specific games.
// ApplyPathfinding();
Timer collisionTimer;
collisionTimer.Start();
Timer timer;
timer.Start();
/// Detect collisions.
List<Collision> collisions;
Timer sweepTimer;
sweepTimer.Start();
// Generate pair of possible collissions via some optimized way (AABB-sorting or Octree).
List<EntityPair> pairs = this->aabbSweeper->Sweep();
sweepTimer.Stop();
int sweepDur = sweepTimer.GetMs();
FrameStats.physicsCollisionDetectionAABBSweep += sweepDur;
// std::cout<<"\nAABB sweep pairs: "<<pairs.Size()<<" with "<<physicalEntities.Size()<<" entities";
Timer detectorTimer;
detectorTimer.Start();
if (collisionDetector)
{
collisionDetector->DetectCollisions(pairs, collisions);
}
// Old approach which combined collision-detection and resolution in a big mess...
else
DetectCollisions();
detectorTimer.Stop();
int detectorMs = detectorTimer.GetMs();
FrameStats.physicsCollisionDetectionChosenDetector += detectorMs;
timer.Stop();
int thisFrame = timer.GetMs();
FrameStats.physicsCollisionDetection += thisFrame;
timer.Start();
/// And resolve them.
if (collisionResolver)
collisionResolver->ResolveCollisions(collisions);
timer.Stop();
FrameStats.physicsCollisionResolution += timer.GetMs();
timer.Start();
messages.Clear();
for (int i = 0; i < collisions.Size(); ++i)
{
Collision & c = collisions[i];