Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 65 files). Show all
Unified · Split
| @@ -28,22 +28,19 @@ · 27 unmodified lines | |||
| 28 | #include <NodeList.h> | 28 | #include <NodeList.h> |
| 29 | #include <PacketHeaders.h> | 29 | #include <PacketHeaders.h> |
| 30 | #include <UUID.h> | 30 | #include <UUID.h> |
| 31 | #include <VoxelConstants.h> | 31 | //#include <VoxelConstants.h> |
| 32 | #include <VoxelDetail.h> | ||
| 33 | 32 | ||
| 34 | #include "AnimationObject.h" | 33 | #include "AnimationObject.h" |
| 35 | #include "ArrayBufferViewClass.h" | 34 | #include "ArrayBufferViewClass.h" |
| 36 | #include "DataViewClass.h" | 35 | #include "DataViewClass.h" |
| 37 | #include "EventTypes.h" | 36 | #include "EventTypes.h" |
| 38 | #include "MenuItemProperties.h" | 37 | #include "MenuItemProperties.h" |
| 39 | #include "LocalVoxels.h" | ||
| 40 | #include "ScriptEngine.h" | 38 | #include "ScriptEngine.h" |
| 41 | #include "TypedArrays.h" | 39 | #include "TypedArrays.h" |
| 42 | #include "XMLHttpRequestClass.h" | 40 | #include "XMLHttpRequestClass.h" |
| 43 | 41 | ||
| 44 | #include "MIDIEvent.h" | 42 | #include "MIDIEvent.h" |
| 45 | 43 | ||
| 46 | VoxelsScriptingInterface ScriptEngine::_voxelsScriptingInterface; | ||
| 47 | EntityScriptingInterface ScriptEngine::_entityScriptingInterface; | 44 | EntityScriptingInterface ScriptEngine::_entityScriptingInterface; |
| 48 | 45 | ||
| 49 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ | 46 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ |
| @@ -200,8 +197,6 @@ void ScriptEngine::handleScriptDownload() { · 150 unmodified lines | |||
| 200 | } | 197 | } |
| 201 | } | 198 | } |
| 202 | 199 | ||
| 203 | Q_SCRIPT_DECLARE_QMETAOBJECT(LocalVoxels, QString) | ||
| 204 | |||
| 205 | void ScriptEngine::init() { | 200 | void ScriptEngine::init() { |
| 206 | if (_isInitialized) { | 201 | if (_isInitialized) { |
| 207 | return; // only initialize once | 202 | return; // only initialize once |
| @@ -209,12 +204,9 @@ void ScriptEngine::init() { · 1 unmodified line | |||
| 209 | 204 | ||
| 210 | _isInitialized = true; | 205 | _isInitialized = true; |
| 211 | 206 | ||
| 212 | _voxelsScriptingInterface.init(); | ||
| 213 | |||
| 214 | // register various meta-types | 207 | // register various meta-types |
| 215 | registerMetaTypes(this); | 208 | registerMetaTypes(this); |
| 216 | registerMIDIMetaTypes(this); | 209 | registerMIDIMetaTypes(this); |
| 217 | registerVoxelMetaTypes(this); | ||
| 218 | registerEventTypes(this); | 210 | registerEventTypes(this); |
| 219 | registerMenuItemProperties(this); | 211 | registerMenuItemProperties(this); |
| 220 | registerAnimationTypes(this); | 212 | registerAnimationTypes(this); |
| @@ -237,9 +229,6 @@ void ScriptEngine::init() { · 16 unmodified lines | |||
| 237 | QScriptValue printConstructorValue = newFunction(debugPrint); | 229 | QScriptValue printConstructorValue = newFunction(debugPrint); |
| 238 | globalObject().setProperty("print", printConstructorValue); | 230 | globalObject().setProperty("print", printConstructorValue); |
| 239 | 231 | ||
| 240 | QScriptValue localVoxelsValue = scriptValueFromQMetaObject<LocalVoxels>(); | ||
| 241 | globalObject().setProperty("LocalVoxels", localVoxelsValue); | ||
| 242 | |||
| 243 | QScriptValue audioEffectOptionsConstructorValue = newFunction(AudioEffectOptions::constructor); | 232 | QScriptValue audioEffectOptionsConstructorValue = newFunction(AudioEffectOptions::constructor); |
| 244 | globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue); | 233 | globalObject().setProperty("AudioEffectOptions", audioEffectOptionsConstructorValue); |
| 245 | 234 | ||
| @@ -257,19 +246,14 @@ void ScriptEngine::init() { · 11 unmodified lines | |||
| 257 | registerGlobalObject("Uuid", &_uuidLibrary); | 246 | registerGlobalObject("Uuid", &_uuidLibrary); |
| 258 | registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); | 247 | registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); |
| 259 | 248 | ||
| 260 | registerGlobalObject("Voxels", &_voxelsScriptingInterface); | ||
| 261 | |||
| 262 | // constants | 249 | // constants |
| 263 | globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE))); | 250 | globalObject().setProperty("TREE_SCALE", newVariant(QVariant(TREE_SCALE))); |
| 264 | globalObject().setProperty("COLLISION_GROUP_ENVIRONMENT", newVariant(QVariant(COLLISION_GROUP_ENVIRONMENT))); | 251 | globalObject().setProperty("COLLISION_GROUP_ENVIRONMENT", newVariant(QVariant(COLLISION_GROUP_ENVIRONMENT))); |
| 265 | globalObject().setProperty("COLLISION_GROUP_AVATARS", newVariant(QVariant(COLLISION_GROUP_AVATARS))); | 252 | globalObject().setProperty("COLLISION_GROUP_AVATARS", newVariant(QVariant(COLLISION_GROUP_AVATARS))); |
| 266 | globalObject().setProperty("COLLISION_GROUP_VOXELS", newVariant(QVariant(COLLISION_GROUP_VOXELS))); | ||
| 267 | 253 | ||
| 268 | globalObject().setProperty("AVATAR_MOTION_OBEY_LOCAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_LOCAL_GRAVITY))); | 254 | globalObject().setProperty("AVATAR_MOTION_OBEY_LOCAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_LOCAL_GRAVITY))); |
| 269 | globalObject().setProperty("AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY))); | 255 | globalObject().setProperty("AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY", newVariant(QVariant(AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY))); |
| 270 | 256 | ||
| 271 | // let the VoxelPacketSender know how frequently we plan to call it | ||
| 272 | _voxelsScriptingInterface.getVoxelPacketSender()->setProcessCallIntervalHint(SCRIPT_DATA_CALLBACK_USECS); | ||
| 273 | } | 257 | } |
| 274 | 258 | ||
| 275 | QScriptValue ScriptEngine::registerGlobalObject(const QString& name, QObject* object) { | 259 | QScriptValue ScriptEngine::registerGlobalObject(const QString& name, QObject* object) { |
| @@ -379,18 +363,8 @@ void ScriptEngine::run() { · 103 unmodified lines | |||
| 379 | break; | 363 | break; |
| 380 | } | 364 | } |
| 381 | 365 | ||
| 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 | if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { | 366 | if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { |
| 393 | // release the queue of edit voxel messages. | 367 | // release the queue of edit entity messages. |
| 394 | _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); | 368 | _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); |
| 395 | 369 | ||
| 396 | // since we're in non-threaded mode, call process so that the packets are sent | 370 | // since we're in non-threaded mode, call process so that the packets are sent |
| @@ -516,16 +490,6 @@ void ScriptEngine::run() { · 119 unmodified lines | |||
| 516 | // kill the avatar identity timer | 490 | // kill the avatar identity timer |
| 517 | delete _avatarIdentityTimer; | 491 | delete _avatarIdentityTimer; |
| 518 | 492 | ||
| 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 | if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { | 493 | if (_entityScriptingInterface.getEntityPacketSender()->serversExist()) { |
| 530 | // release the queue of edit entity messages. | 494 | // release the queue of edit entity messages. |
| 531 | _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); | 495 | _entityScriptingInterface.getEntityPacketSender()->releaseQueuedMessages(); |