History

Merge branch 'master' of https://github.com/highfidelity/hifi into applications_diet_cpp11

Atlante45 committed 11 years ago

Commit 2a82ff92 parents 327daac 1b1fd2b497 files · +12546 −22844Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+7−40
@@ -17,9 +17,9 @@ · 16 unmodified lines
1717 #include <QtNetwork/QNetworkReply>
1818 #include <QScriptEngine>
1919
20+#include <AudioConstants.h>
2021 #include <AudioEffectOptions.h>
2122 #include <AudioInjector.h>
22−#include <AudioRingBuffer.h>
2323 #include <AvatarData.h>
2424 #include <Bitstream.h>
2525 #include <CollisionInfo.h>
@@ -28,22 +28,18 @@ · 2 unmodified lines
2828 #include <NodeList.h>
2929 #include <PacketHeaders.h>
3030 #include <UUID.h>
31−#include <VoxelConstants.h>
32−#include <VoxelDetail.h>
3331
3432 #include "AnimationObject.h"
3533 #include "ArrayBufferViewClass.h"
3634 #include "DataViewClass.h"
3735 #include "EventTypes.h"
3836 #include "MenuItemProperties.h"
39−#include "LocalVoxels.h"
4037 #include "ScriptEngine.h"
4138 #include "TypedArrays.h"
4239 #include "XMLHttpRequestClass.h"
4340
4441 #include "MIDIEvent.h"
4542
46−VoxelsScriptingInterface ScriptEngine::_voxelsScriptingInterface;
4743 EntityScriptingInterface ScriptEngine::_entityScriptingInterface;
4844
4945 static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
@@ -198,10 +194,10 @@ void ScriptEngine::handleScriptDownload() { · 148 unmodified lines
198194 qDebug() << "ERROR Loading file:" << reply->url().toString();
199195 emit errorLoadingScript(_fileNameString);
200196 }
197+
198+ reply->deleteLater();
201199 }
202200
203−Q_SCRIPT_DECLARE_QMETAOBJECT(LocalVoxels, QString)
204−
205201 void ScriptEngine::init() {
206202 if (_isInitialized) {
207203 return; // only initialize once
@@ -209,12 +205,9 @@ void ScriptEngine::init() { · 1 unmodified line
209205
210206 _isInitialized = true;
211207
212− _voxelsScriptingInterface.init();
213−
214208 // register various meta-types
215209 registerMetaTypes(this);
216210 registerMIDIMetaTypes(this);
217− registerVoxelMetaTypes(this);
218211 registerEventTypes(this);
219212 registerMenuItemProperties(this);
220213 registerAnimationTypes(this);
@@ -237,9 +230,6 @@ void ScriptEngine::init() { · 16 unmodified lines
237230 QScriptValue printConstructorValue = newFunction(debugPrint);
238231 globalObject().setProperty("print", printConstructorValue);
239232
240− QScriptValue localVoxelsValue = scriptValueFromQMetaObject<LocalVoxels>();
241− globalObject().setProperty("LocalVoxels", localVoxelsValue);
242−
243233 QScriptValue audioEffectOptionsConstructorValue = newFunction(AudioEffectOptions::constructor);
244234 globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue);
245235
@@ -257,19 +247,14 @@ void ScriptEngine::init() { · 11 unmodified lines
257247 registerGlobalObject("Uuid", &_uuidLibrary);
258248 registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
259249
260− registerGlobalObject("Voxels", &_voxelsScriptingInterface);
261−
262250 // constants
263251 globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE)));
264252 globalObject().setProperty("COLLISION_GROUP_ENVIRONMENT", newVariant(QVariant(COLLISION_GROUP_ENVIRONMENT)));
265253 globalObject().setProperty("COLLISION_GROUP_AVATARS", newVariant(QVariant(COLLISION_GROUP_AVATARS)));
266− globalObject().setProperty("COLLISION_GROUP_VOXELS", newVariant(QVariant(COLLISION_GROUP_VOXELS)));
267254
268255 globalObject().setProperty("AVATAR_MOTION_OBEY_LOCAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_LOCAL_GRAVITY)));
269256 globalObject().setProperty("AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY)));
270257
271− // let the VoxelPacketSender know how frequently we plan to call it
272− _voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS);
273258 }
274259
275260 QScriptValue ScriptEngine::registerGlobalObject(const QString& name, QObject* object) {
@@ -379,18 +364,8 @@ void ScriptEngine::run() { · 103 unmodified lines
379364 break;
380365 }
381366
382− if (_voxelsScriptingInterface.getVoxelPacketSender()->serversExist()) {
383− // release the queue of edit voxel messages.
384− _voxelsScriptingInterface.getVoxelPacketSender()->releaseQueuedMessages();
385−
386− // since we're in non-threaded mode, call process so that the packets are sent
387− if (!_voxelsScriptingInterface.getVoxelPacketSender()->isThreaded()) {
388− _voxelsScriptingInterface.getVoxelPacketSender()->process();
389− }
390− }
391−
392367 if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) {
393− // release the queue of edit voxel messages.
368+ // release the queue of edit entity messages.
394369 _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages();
395370
396371 // since we're in non-threaded mode, call process so that the packets are sent
@@ -401,7 +376,8 @@ void ScriptEngine::run() { · 4 unmodified lines
401376
402377 if (_isAvatar && _avatarData) {
403378
404− const int SCRIPT_AUDIO_BUFFER_SAMPLES = floor(((SCRIPT_DATA_CALLBACK_USECS * SAMPLE_RATE) / (1000 * 1000)) + 0.5);
379+ const int SCRIPT_AUDIO_BUFFER_SAMPLES = floor(((SCRIPT_DATA_CALLBACK_USECS * AudioConstants::SAMPLE_RATE)
380+ / (1000 * 1000)) + 0.5);
405381 const int SCRIPT_AUDIO_BUFFER_BYTES = SCRIPT_AUDIO_BUFFER_SAMPLES * sizeof(int16_t);
406382
407383 QByteArray avatarPacket = byteArrayWithPopulatedHeader(PacketTypeAvatarData);
@@ -516,16 +492,6 @@ void ScriptEngine::run() { · 108 unmodified lines
516492 // kill the avatar identity timer
517493 delete _avatarIdentityTimer;
518494
519− if (_voxelsScriptingInterface.getVoxelPacketSender()->serversExist()) {
520− // release the queue of edit voxel messages.
521− _voxelsScriptingInterface.getVoxelPacketSender()->releaseQueuedMessages();
522−
523− // since we're in non-threaded mode, call process so that the packets are sent
524− if (!_voxelsScriptingInterface.getVoxelPacketSender()->isThreaded()) {
525− _voxelsScriptingInterface.getVoxelPacketSender()->process();
526− }
527− }
528−
529495 if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) {
530496 // release the queue of edit entity messages.
531497 _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages();
@@ -641,6 +607,7 @@ void ScriptEngine::include(const QString& includeFile) { · 109 unmodified lines
641607 QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
642608 loop.exec();
643609 includeContents = reply->readAll();
610+ reply->deleteLater();
644611 } else {
645612 #ifdef _WIN32
646613 QString fileName = url.toString();