Browse Source

Merge branch 'ticket/8'

closes #8 (Requires corresponding MOULSCRIPT ticket 13)
tickets/08/8/2
rarified 4 years ago
parent
commit
5b95b7e9b7
  1. 31
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 2
      Sources/Plasma/PubUtilLib/plInterp/hsInterp.cpp
  3. 18
      Sources/Plasma/PubUtilLib/plInterp/plAnimTimeConvert.cpp
  4. 16
      Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp
  5. 3
      Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h

31
Sources/Plasma/Apps/plClient/plClient.cpp

@ -1287,7 +1287,20 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress)
return; return;
fInstance->fMessagePumpProc(); fInstance->fMessagePumpProc();
fInstance->IDraw();
// HACK HACK HACK HACK!
// Yes, this is the ORIGINAL, EVIL famerate limit from plClient::IDraw (except I bumped it to 60fps)
// As it so happens, this callback is happening in the main resource loading thread
// Without this NASTY ASS HACK, we draw after loading every KO, which starves the loader.
// At some point, a better solution should be found... Like running the loader in a separate thread.
static float lastDrawTime;
static const float kMaxFrameRate = 1.f/60.f;
float currTime = (float) hsTimer::GetSeconds();
if ((currTime - lastDrawTime) > kMaxFrameRate)
{
fInstance->IDraw();
lastDrawTime = currTime;
}
} }
//============================================================================ //============================================================================
@ -1847,22 +1860,6 @@ hsBool plClient::IDrawProgress() {
hsBool plClient::IDraw() hsBool plClient::IDraw()
{ {
// Limit framerate
static float lastDrawTime;
static const float kMaxFrameRate = 1.f/30.f;
float currTime = (float) hsTimer::GetSeconds();
if (!fPipeline->IsDebugFlagSet(plPipeDbg::kFlagNVPerfHUD))
{
// If we're using NVPerfHUD to step through draw calls,
// We're going to have a frame delta of zero. In that
// case we need to draw no matter what, and we don't
// care as much about starving other threads because
// we're presumably just debugging a graphics glitch.
if ((currTime - lastDrawTime) < kMaxFrameRate)
return true;
}
lastDrawTime = currTime;
// If we're shutting down, don't attempt to draw. Doing so // If we're shutting down, don't attempt to draw. Doing so
// tends to cause a device reload each frame. // tends to cause a device reload each frame.
if (fDone) if (fDone)

2
Sources/Plasma/PubUtilLib/plInterp/hsInterp.cpp

@ -404,7 +404,7 @@ void hsInterp::GetBoundaryKeyFrames(hsScalar time, UInt32 numKeys, void *keys, U
{ {
hsAssert(numKeys>1, "Must have more than 1 keyframe"); hsAssert(numKeys>1, "Must have more than 1 keyframe");
int k1, k2; int k1, k2;
UInt16 frame = (UInt16)(time * MAX_FRAMES_PER_SEC); float frame = (time * MAX_FRAMES_PER_SEC);
// boundary case, past end // boundary case, past end
if (frame > GetKey(numKeys-1, keys, size)->fFrame) if (frame > GetKey(numKeys-1, keys, size)->fFrame)

18
Sources/Plasma/PubUtilLib/plInterp/plAnimTimeConvert.cpp

@ -557,8 +557,13 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
{ {
if (secs > fLoopEnd) if (secs > fLoopEnd)
{ {
secs = fmodf(secs - fLoopBegin, fLoopEnd - fLoopBegin) + fLoopBegin; float result = fmodf(secs - fLoopBegin, fLoopEnd - fLoopBegin) + fLoopBegin;
wrapped = true; // if fLoopBegin == fLoopEnd == 0, result will not be a number
if (!_isnan(result))
{
secs = result;
wrapped = true;
}
} }
} }
} }
@ -576,8 +581,13 @@ hsScalar plAnimTimeConvert::WorldToAnimTime(double wSecs)
{ {
if (secs < fLoopBegin) if (secs < fLoopBegin)
{ {
secs = fLoopEnd - fmodf(fLoopEnd - secs, fLoopEnd - fLoopBegin); float result = fLoopEnd - fmodf(fLoopEnd - secs, fLoopEnd - fLoopBegin);
wrapped = true; // if fLoopBegin == fLoopEnd == 0, result will not be a number
if (!_isnan(result))
{
secs = result;
wrapped = true;
}
} }
} }
} }

16
Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp

@ -626,15 +626,15 @@ void plSimulationMgr::Advance(float delSecs)
{ {
if (fExtraProfile) if (fExtraProfile)
Log("Step clamped from %f to limit of %f", fAccumulator, fMaxDelta); Log("Step clamped from %f to limit of %f", fAccumulator, fMaxDelta);
fAccumulator = fMaxDelta; fAccumulator = kDefaultMaxDelta;
} }
++fStepCount; ++fStepCount;
// Perform as many whole substeps as possible saving the remainder in our accumulator. // Perform as many whole substeps as possible saving the remainder in our accumulator.
int numSubSteps = (int)(fAccumulator / fStepSize + 0.000001f); int numSubSteps = (int)(fAccumulator / fStepSize + 0.000001f);
float delta = numSubSteps * fStepSize; float delta = numSubSteps * fStepSize;
fAccumulator -= delta; fAccumulator -= delta;
plProfile_IncCount(StepLen, (int)(delta*1000)); plProfile_IncCount(StepLen, (int)(delta*1000));
plProfile_BeginTiming(Step); plProfile_BeginTiming(Step);
@ -783,25 +783,21 @@ void plSimulationMgr::ISendUpdates()
// RESOLUTION & TIMEOUT PARAMETERS // RESOLUTION & TIMEOUT PARAMETERS
// //
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
void plSimulationMgr::SetMaxDelta(float maxDelta) void plSimulationMgr::SetMaxDelta(float maxDelta)
{ {
fMaxDelta = maxDelta; fMaxDelta = maxDelta;
} }
float plSimulationMgr::GetMaxDelta() const float plSimulationMgr::GetMaxDelta() const
{ {
return fMaxDelta; return fMaxDelta;
} }
void plSimulationMgr::SetStepsPerSecond(int stepsPerSecond) void plSimulationMgr::SetStepsPerSecond(int stepsPerSecond)
{ {
fStepSize = 1.0f / (float)stepsPerSecond; fStepSize = 1.0f / (float)stepsPerSecond;
} }
int plSimulationMgr::GetStepsPerSecond() int plSimulationMgr::GetStepsPerSecond()
{ {
return (int)((1.0 / fStepSize) + 0.5f); // round to nearest int return (int)((1.0 / fStepSize) + 0.5f); // round to nearest int
} }
int plSimulationMgr::GetMaterialIdx(NxScene* scene, hsScalar friction, hsScalar restitution) int plSimulationMgr::GetMaterialIdx(NxScene* scene, hsScalar friction, hsScalar restitution)

3
Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h

@ -122,7 +122,7 @@ protected:
// physicals and the avatar may move at a faster rate than usual. // physicals and the avatar may move at a faster rate than usual.
void SetMaxDelta(float maxDelta); void SetMaxDelta(float maxDelta);
float GetMaxDelta() const; float GetMaxDelta() const;
// Set the number of steps per second that physics will advance. // Set the number of steps per second that physics will advance.
// The more steps per second, the less fallthough and more accurate // The more steps per second, the less fallthough and more accurate
// simulation response. // simulation response.
@ -159,6 +159,7 @@ protected:
float fMaxDelta; float fMaxDelta;
float fStepSize; float fStepSize;
float fAccumulator; float fAccumulator;
UInt32 fStepCount; UInt32 fStepCount;

Loading…
Cancel
Save