Revert "Update scriptengine update rate to match displayPlugin target framerate"

This reverts commit d5effc89776b0b2480db364f21384a245bdcd4f0.
This commit is contained in:
Ryan Huffman 2017-02-02 13:40:05 -08:00
parent 69abdf7dd2
commit 537f639d16
3 changed files with 6 additions and 19 deletions

View file

@ -5419,15 +5419,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
return !entityServerNode || isPhysicsEnabled();
});
scriptEngine->setGetTargetUpdateRateFunction([this]() {
auto displayPlugin = _displayPlugin;
if (displayPlugin) {
auto targetUpdateRate = displayPlugin->getTargetFrameRate();
return targetUpdateRate;
}
return 60.0f;
});
// setup the packet senders and jurisdiction listeners of the script engine's scripting interfaces so
// we can use the same ones from the application.
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();

View file

@ -898,15 +898,14 @@ void ScriptEngine::run() {
while (!_isFinished) {
auto beforeSleep = clock::now();
// Throttle to _targetUpdateRate
// We'd like to try to keep the script at a solid _targetUpdateRate update rate. And so we will
// Throttle to SCRIPT_FPS
// We'd like to try to keep the script at a solid SCRIPT_FPS update rate. And so we will
// calculate a sleepUntil to be the time from our start time until the original target
// sleepUntil for this frame. This approach will allow us to "catch up" in the event
// that some of our script udpates/frames take a little bit longer than the target average
// to execute.
// NOTE: if we go to variable SCRIPT_FPS, then we will need to reconsider this approach
//const std::chrono::microseconds TARGET_SCRIPT_FRAME_DURATION(static_cast<int64_t>(USECS_PER_SECOND / _getTargetUpdateRate()) + 1);
const std::chrono::microseconds TARGET_SCRIPT_FRAME_DURATION(static_cast<int64_t>(USECS_PER_SECOND / 75.0f) + 1);
const std::chrono::microseconds TARGET_SCRIPT_FRAME_DURATION(USECS_PER_SECOND / SCRIPT_FPS + 1);
clock::time_point targetSleepUntil(startTime + (thisFrame++ * TARGET_SCRIPT_FRAME_DURATION));
// However, if our sleepUntil is not at least our average update and timer execution time

View file

@ -41,9 +41,11 @@
#include "ScriptUUID.h"
#include "Vec3.h"
class QScriptEngineDebugger;
static const QString NO_SCRIPT("");
class QScriptEngineDebugger;
static const int SCRIPT_FPS = 60;
class CallbackData {
public:
@ -54,7 +56,6 @@ public:
typedef QList<CallbackData> CallbackList;
typedef QHash<QString, CallbackList> RegisteredEventHandlers;
using GetTargetUpdateRateFunction = std::function<float()>;
class EntityScriptDetails {
public:
@ -200,8 +201,6 @@ public:
bool getEntityScriptDetails(const EntityItemID& entityID, EntityScriptDetails &details) const;
void setGetTargetUpdateRateFunction(GetTargetUpdateRateFunction function) { _getTargetUpdateRate = function; }
public slots:
void callAnimationStateHandler(QScriptValue callback, AnimVariantMap parameters, QStringList names, bool useNames, AnimVariantResultHandler resultHandler);
void updateMemoryCost(const qint64&);
@ -271,8 +270,6 @@ protected:
std::atomic<bool> _isUserLoaded { false };
bool _isReloading { false };
GetTargetUpdateRateFunction _getTargetUpdateRate { []() { return 60.0f; } };
ArrayBufferClass* _arrayBufferClass;
AssetScriptingInterface _assetScriptingInterface{ this };