Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 6 files). Show all
Unified · Split
| @@ -44,8 +44,6 @@ · 43 unmodified lines | ||
| 44 | 44 | #include "MIDIEvent.h" |
| 45 | 45 | |
| 46 | 46 | |
| 47 | −EntityScriptingInterface* ScriptEngine::_entityScriptingInterface; | |
| 48 | − | |
| 49 | 47 | static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){ |
| 50 | 48 | qDebug() << "script:print()<<" << context->argument(0).toString(); |
| 51 | 49 | QString message = context->argument(0).toString() |
| @@ -73,13 +71,6 @@ void inputControllerFromScriptValue(const QScriptValue &object, AbstractInputCon · 21 unmodified lines | ||
| 73 | 71 | out = qobject_cast<AbstractInputController*>(object.toQObject()); |
| 74 | 72 | } |
| 75 | 73 | |
| 76 | −EntityScriptingInterface* ScriptEngine::getEntityScriptingInterface() { | |
| 77 | − if (!_entityScriptingInterface) { | |
| 78 | − _entityScriptingInterface = new EntityScriptingInterface(); | |
| 79 | − } | |
| 80 | − return _entityScriptingInterface; | |
| 81 | −} | |
| 82 | − | |
| 83 | 74 | ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString, |
| 84 | 75 | AbstractControllerScriptingInterface* controllerScriptingInterface) : |
| 85 | 76 | |
| @@ -104,7 +95,6 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 18 unmodified lines | ||
| 104 | 95 | _isUserLoaded(false), |
| 105 | 96 | _arrayBufferClass(new ArrayBufferClass(this)) |
| 106 | 97 | { |
| 107 | − getEntityScriptingInterface(); | |
| 108 | 98 | _allScriptsMutex.lock(); |
| 109 | 99 | _allKnownScriptEngines.insert(this); |
| 110 | 100 | _allScriptsMutex.unlock(); |
| @@ -322,7 +312,8 @@ void ScriptEngine::init() { · 211 unmodified lines | ||
| 322 | 312 | |
| 323 | 313 | auto sceneScriptingInterface = DependencyManager::set<SceneScriptingInterface>(); |
| 324 | 314 | |
| 325 | − _entityScriptingInterface->init(); | |
| 315 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 316 | + entityScriptingInterface->init(); | |
| 326 | 317 | |
| 327 | 318 | // register various meta-types |
| 328 | 319 | registerMetaTypes(this); |
| @@ -360,7 +351,7 @@ void ScriptEngine::init() { · 31 unmodified lines | ||
| 360 | 351 | registerGlobalObject("Script", this); |
| 361 | 352 | registerGlobalObject("Audio", &AudioScriptingInterface::getInstance()); |
| 362 | 353 | registerGlobalObject("Controller", _controllerScriptingInterface); |
| 363 | − registerGlobalObject("Entities", _entityScriptingInterface); | |
| 354 | + registerGlobalObject("Entities", entityScriptingInterface.data()); | |
| 364 | 355 | registerGlobalObject("Quat", &_quatLibrary); |
| 365 | 356 | registerGlobalObject("Vec3", &_vec3Library); |
| 366 | 357 | registerGlobalObject("Uuid", &_uuidLibrary); |
| @@ -478,6 +469,7 @@ void ScriptEngine::run() { · 111 unmodified lines | ||
| 478 | 469 | int thisFrame = 0; |
| 479 | 470 | |
| 480 | 471 | auto nodeList = DependencyManager::get<NodeList>(); |
| 472 | + auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); | |
| 481 | 473 | |
| 482 | 474 | qint64 lastUpdate = usecTimestampNow(); |
| 483 | 475 | |
| @@ -497,13 +489,13 @@ void ScriptEngine::run() { · 13 unmodified lines | ||
| 497 | 489 | break; |
| 498 | 490 | } |
| 499 | 491 | |
| 500 | − if (!_isFinished && _entityScriptingInterface->getEntityPacketSender()->serversExist()) { | |
| 492 | + if (!_isFinished && entityScriptingInterface->getEntityPacketSender()->serversExist()) { | |
| 501 | 493 | // release the queue of edit entity messages. |
| 502 | − _entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); | |
| 494 | + entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); | |
| 503 | 495 | |
| 504 | 496 | // since we're in non-threaded mode, call process so that the packets are sent |
| 505 | − if (!_entityScriptingInterface->getEntityPacketSender()->isThreaded()) { | |
| 506 | − _entityScriptingInterface->getEntityPacketSender()->process(); | |
| 497 | + if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { | |
| 498 | + entityScriptingInterface->getEntityPacketSender()->process(); | |
| 507 | 499 | } |
| 508 | 500 | } |
| 509 | 501 | |
| @@ -630,13 +622,13 @@ void ScriptEngine::run() { · 120 unmodified lines | ||
| 630 | 622 | // kill the avatar identity timer |
| 631 | 623 | delete _avatarIdentityTimer; |
| 632 | 624 | |
| 633 | − if (_entityScriptingInterface->getEntityPacketSender()->serversExist()) { | |
| 625 | + if (entityScriptingInterface->getEntityPacketSender()->serversExist()) { | |
| 634 | 626 | // release the queue of edit entity messages. |
| 635 | − _entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); | |
| 627 | + entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); | |
| 636 | 628 | |
| 637 | 629 | // since we're in non-threaded mode, call process so that the packets are sent |
| 638 | − if (!_entityScriptingInterface->getEntityPacketSender()->isThreaded()) { | |
| 639 | − _entityScriptingInterface->getEntityPacketSender()->process(); | |
| 630 | + if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { | |
| 631 | + entityScriptingInterface->getEntityPacketSender()->process(); | |
| 640 | 632 | } |
| 641 | 633 | } |
| 642 | 634 | |