History

first cut at flocking birds, change willEmitVisualCallback to update

ZappoMan committed 12 years ago

Commit 374af9e1 parent 129964539 files · +106 −86Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 39 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+6−1
@@ -215,6 +215,8 @@ void ScriptEngine::run() { · 214 unmodified lines
215215 int thisFrame = 0;
216216
217217 NodeList* nodeList = NodeList::getInstance();
218+
219+ qint64 lastUpdate = usecTimestampNow();
218220
219221 while (!_isFinished) {
220222 int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * VISUAL_DATA_CALLBACK_USECS) - usecTimestampNow();
@@ -259,7 +261,10 @@ void ScriptEngine::run() { · 38 unmodified lines
259261 nodeList->broadcastToNodes(avatarPacket, NodeSet() << NodeType::AvatarMixer);
260262 }
261263
262− emit willSendVisualDataCallback();
264+ qint64 now = usecTimestampNow();
265+ float deltaTime = (float)(now - lastUpdate)/(float)USECS_PER_SECOND;
266+ emit update(deltaTime);
267+ lastUpdate = now;
263268
264269 if (_engine.hasUncaughtException()) {
265270 int line = _engine.uncaughtExceptionLineNumber();