Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 497 files). Show all
Unified · Split
| @@ -17,9 +17,9 @@ · 16 unmodified lines | ||
| 17 | 17 | #include <QtNetwork/QNetworkReply> |
| 18 | 18 | #include <QScriptEngine> |
| 19 | 19 | |
| 20 | +#include <AudioConstants.h> | |
| 20 | 21 | #include <AudioEffectOptions.h> |
| 21 | 22 | #include <AudioInjector.h> |
| 22 | −#include <AudioRingBuffer.h> | |
| 23 | 23 | #include <AvatarData.h> |
| 24 | 24 | #include <Bitstream.h> |
| 25 | 25 | #include <CollisionInfo.h> |
| @@ -28,22 +28,18 @@ · 2 unmodified lines | ||
| 28 | 28 | #include <NodeList.h> |
| 29 | 29 | #include <PacketHeaders.h> |
| 30 | 30 | #include <UUID.h> |
| 31 | −#include <VoxelConstants.h> | |
| 32 | −#include <VoxelDetail.h> | |
| 33 | 31 | |
| 34 | 32 | #include "AnimationObject.h" |
| 35 | 33 | #include "ArrayBufferViewClass.h" |
| 36 | 34 | #include "DataViewClass.h" |
| 37 | 35 | #include "EventTypes.h" |
| 38 | 36 | #include "MenuItemProperties.h" |
| 39 | −#include "LocalVoxels.h" | |
| 40 | 37 | #include "ScriptEngine.h" |
| 41 | 38 | #include "TypedArrays.h" |
| 42 | 39 | #include "XMLHttpRequestClass.h" |
| 43 | 40 | |
| 44 | 41 | #include "MIDIEvent.h" |
| 45 | 42 | |
| 46 | −VoxelsScriptingInterface ScriptEngine::_voxelsScriptingInterface; | |
| 47 | 43 | EntityScriptingInterface ScriptEngine::_entityScriptingInterface; |
| 48 | 44 | |
| 49 | 45 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ |
| @@ -198,10 +194,10 @@ void ScriptEngine::handleScriptDownload() { · 148 unmodified lines | ||
| 198 | 194 | qDebug() << "ERROR Loading file:" << reply->url().toString(); |
| 199 | 195 | emit errorLoadingScript(_fileNameString); |
| 200 | 196 | } |
| 197 | + | |
| 198 | + reply->deleteLater(); | |
| 201 | 199 | } |
| 202 | 200 | |
| 203 | −Q_SCRIPT_DECLARE_QMETAOBJECT(LocalVoxels, QString) | |
| 204 | − | |
| 205 | 201 | void ScriptEngine::init() { |
| 206 | 202 | if (_isInitialized) { |
| 207 | 203 | return; // only initialize once |
| @@ -209,12 +205,9 @@ void ScriptEngine::init() { · 1 unmodified line | ||
| 209 | 205 | |
| 210 | 206 | _isInitialized = true; |
| 211 | 207 | |
| 212 | − _voxelsScriptingInterface.init(); | |
| 213 | − | |
| 214 | 208 | // register various meta-types |
| 215 | 209 | registerMetaTypes(this); |
| 216 | 210 | registerMIDIMetaTypes(this); |
| 217 | − registerVoxelMetaTypes(this); | |
| 218 | 211 | registerEventTypes(this); |
| 219 | 212 | registerMenuItemProperties(this); |
| 220 | 213 | registerAnimationTypes(this); |
| @@ -237,9 +230,6 @@ void ScriptEngine::init() { · 16 unmodified lines | ||
| 237 | 230 | QScriptValue printConstructorValue = newFunction(debugPrint); |
| 238 | 231 | globalObject().setProperty("print", printConstructorValue); |
| 239 | 232 | |
| 240 | − QScriptValue localVoxelsValue = scriptValueFromQMetaObject<LocalVoxels>(); | |
| 241 | − globalObject().setProperty("LocalVoxels", localVoxelsValue); | |
| 242 | − | |
| 243 | 233 | QScriptValue audioEffectOptionsConstructorValue = newFunction(AudioEffectOptions::constructor); |
| 244 | 234 | globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue); |
| 245 | 235 | |
| @@ -257,19 +247,14 @@ void ScriptEngine::init() { · 11 unmodified lines | ||
| 257 | 247 | registerGlobalObject("Uuid", &_uuidLibrary); |
| 258 | 248 | registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); |
| 259 | 249 | |
| 260 | − registerGlobalObject("Voxels", &_voxelsScriptingInterface); | |
| 261 | − | |
| 262 | 250 | // constants |
| 263 | 251 | globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE))); |
| 264 | 252 | globalObject().setProperty("COLLISION_GROUP_ENVIRONMENT", newVariant(QVariant(COLLISION_GROUP_ENVIRONMENT))); |
| 265 | 253 | globalObject().setProperty("COLLISION_GROUP_AVATARS", newVariant(QVariant(COLLISION_GROUP_AVATARS))); |
| 266 | − globalObject().setProperty("COLLISION_GROUP_VOXELS", newVariant(QVariant(COLLISION_GROUP_VOXELS))); | |
| 267 | 254 | |
| 268 | 255 | globalObject().setProperty("AVATAR_MOTION_OBEY_LOCAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_LOCAL_GRAVITY))); |
| 269 | 256 | globalObject().setProperty("AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY))); |
| 270 | 257 | |
| 271 | − // let the VoxelPacketSender know how frequently we plan to call it | |
| 272 | − _voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS); | |
| 273 | 258 | } |
| 274 | 259 | |
| 275 | 260 | QScriptValue ScriptEngine::registerGlobalObject(const QString& name, QObject* object) { |
| @@ -379,18 +364,8 @@ void ScriptEngine::run() { · 103 unmodified lines | ||
| 379 | 364 | break; |
| 380 | 365 | } |
| 381 | 366 | |
| 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 | − | |
| 392 | 367 | if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { |
| 393 | − // release the queue of edit voxel messages. | |
| 368 | + // release the queue of edit entity messages. | |
| 394 | 369 | _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); |
| 395 | 370 | |
| 396 | 371 | // 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 | ||
| 401 | 376 | |
| 402 | 377 | if (_isAvatar && _avatarData) { |
| 403 | 378 | |
| 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); | |
| 405 | 381 | const int SCRIPT_AUDIO_BUFFER_BYTES = SCRIPT_AUDIO_BUFFER_SAMPLES * sizeof(int16_t); |
| 406 | 382 | |
| 407 | 383 | QByteArray avatarPacket = byteArrayWithPopulatedHeader(PacketTypeAvatarData); |
| @@ -516,16 +492,6 @@ void ScriptEngine::run() { · 108 unmodified lines | ||
| 516 | 492 | // kill the avatar identity timer |
| 517 | 493 | delete _avatarIdentityTimer; |
| 518 | 494 | |
| 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 | − | |
| 529 | 495 | if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { |
| 530 | 496 | // release the queue of edit entity messages. |
| 531 | 497 | _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); |
| @@ -641,6 +607,7 @@ void ScriptEngine::include(const QString& includeFile) { · 109 unmodified lines | ||
| 641 | 607 | QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); |
| 642 | 608 | loop.exec(); |
| 643 | 609 | includeContents = reply->readAll(); |
| 610 | + reply->deleteLater(); | |
| 644 | 611 | } else { |
| 645 | 612 | #ifdef _WIN32 |
| 646 | 613 | QString fileName = url.toString(); |