diff --git a/interface/src/AvatarBookmarks.cpp b/interface/src/AvatarBookmarks.cpp index c0734b2e12..256ce2f6fc 100644 --- a/interface/src/AvatarBookmarks.cpp +++ b/interface/src/AvatarBookmarks.cpp @@ -52,6 +52,7 @@ void addAvatarEntities(const QVariantList& avatarEntities) { EntitySimulationPointer entitySimulation = entityTree->getSimulation(); PhysicalEntitySimulationPointer physicalEntitySimulation = std::static_pointer_cast(entitySimulation); EntityEditPacketSender* entityPacketSender = physicalEntitySimulation->getPacketSender(); + // V8TODO: Creating new script engine each time is very inefficient ScriptEnginePointer scriptEngine = newScriptEngine(); for (int index = 0; index < avatarEntities.count(); index++) { const QVariantMap& avatarEntityProperties = avatarEntities.at(index).toMap(); @@ -304,6 +305,7 @@ QVariantMap AvatarBookmarks::getAvatarDataToBookmark() { EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr; if (entityTree) { + // V8TODO: Creating new script engine each time is very inefficient ScriptEnginePointer scriptEngine = newScriptEngine(); auto avatarEntities = myAvatar->getAvatarEntityDataNonDefault(); for (auto entityID : avatarEntities.keys()) { diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index a82d8dc530..42cec567dc 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -51,7 +51,8 @@ STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){ RayToOverlayIntersectionResultFromScriptValue>(scriptEngine); })); -Overlays::Overlays() : _scriptEngine(newScriptEngine()) { +// V8TODO: _scriptEngine can be safely removed as soon as 3D overlays are not used anymore by default scripts +Overlays::Overlays() /*: _scriptEngine(newScriptEngine())*/ { ADD_TYPE_MAP(Box, cube); ADD_TYPE_MAP(Sphere, sphere); _overlayToEntityTypes["rectangle3d"] = "Shape"; @@ -195,13 +196,13 @@ QString Overlays::entityToOverlayType(const QString& type) { return "unknown"; } -QString Overlays::overlayToEntityType(const QString& type) { +/*QString Overlays::overlayToEntityType(const QString& type) { auto iter = _overlayToEntityTypes.find(type); if (iter != _overlayToEntityTypes.end()) { return iter->second; } return "Unknown"; -} +}*/ #define SET_OVERLAY_PROP_DEFAULT(o, d) \ { \ @@ -309,12 +310,14 @@ QString Overlays::overlayToEntityType(const QString& type) { static QHash> savedRotations = QHash>(); -EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id) { +// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts +/*EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id) { std::pair rotation; return convertOverlayToEntityProperties(overlayProps, rotation, type, add, id); -} +}*/ -EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair& rotationToSave, const QString& type, bool add, const QUuid& id) { +// V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts +/*EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair& rotationToSave, const QString& type, bool add, const QUuid& id) { overlayProps["type"] = type; SET_OVERLAY_PROP_DEFAULT(alpha, 0.7); @@ -647,9 +650,10 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove EntityItemProperties toReturn; EntityItemPropertiesFromScriptValueHonorReadOnly(props, toReturn); return toReturn; -} +}*/ -QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemProperties& properties) { +// V8TODO: This can be safely removed once scripts don't use 3D overlays +/*QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemProperties& properties) { ScriptEnginePointer scriptEngine = newScriptEngine(); QVariantMap overlayProps = EntityItemPropertiesToScriptValue(scriptEngine.get(), properties).toVariant().toMap(); @@ -778,7 +782,7 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie RENAME_PROP(localRotation, localOrientation); return overlayProps; -} +}*/ QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) { if (_shuttingDown) { @@ -810,7 +814,9 @@ QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) { return QUuid(); } - QString entityType = overlayToEntityType(type); + return UNKNOWN_ENTITY_ID; + // V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts + /*QString entityType = overlayToEntityType(type); if (entityType == "Unknown") { return UNKNOWN_ENTITY_ID; } @@ -824,7 +830,7 @@ QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) { if (entityType == "Text" || entityType == "Image" || entityType == "Grid" || entityType == "Web") { savedRotations[id] = rotationToSave; } - return id; + return id;*/ } QUuid Overlays::add2DOverlay(const Overlay::Pointer& overlay) { @@ -882,10 +888,14 @@ bool Overlays::editOverlay(const QUuid& id, const QVariant& properties) { return true; } + return false; + + // V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts + /* auto entityScriptingInterface = DependencyManager::get(); auto propertyMap = properties.toMap(); EntityItemProperties entityProperties = convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id); - return !entityScriptingInterface->editEntity(id, entityProperties).isNull(); + return !entityScriptingInterface->editEntity(id, entityProperties).isNull();*/ } bool Overlays::editOverlays(const QVariant& propertiesById) { @@ -897,7 +907,7 @@ bool Overlays::editOverlays(const QVariant& propertiesById) { QVariantMap deferred; const QVariantMap map = propertiesById.toMap(); - auto entityScriptingInterface = DependencyManager::get(); + //auto entityScriptingInterface = DependencyManager::get(); for (const auto& key : map.keys()) { QUuid id = QUuid(key); const QVariant& properties = map[key]; @@ -910,8 +920,10 @@ bool Overlays::editOverlays(const QVariant& propertiesById) { } overlay->setProperties(properties.toMap()); } else { - auto propertyMap = properties.toMap(); - entityScriptingInterface->editEntity(id, convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id)); + qDebug() << "Overlays::editOverlays doesn't support editing entities anymore"; + // V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts + /*auto propertyMap = properties.toMap(); + entityScriptingInterface->editEntity(id, convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id));*/ } } diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index 0f93893bd4..95b06247f7 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -123,7 +123,8 @@ public: void cleanupAllOverlays(); - mutable ScriptEnginePointer _scriptEngine; + // V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts + //mutable ScriptEnginePointer _scriptEngine; public slots: /*@jsdoc @@ -762,13 +763,15 @@ private: QMouseEvent* event, PointerEvent::EventType eventType); static QString entityToOverlayType(const QString& type); - static QString overlayToEntityType(const QString& type); + // V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts + //static QString overlayToEntityType(const QString& type); static std::unordered_map _entityToOverlayTypes; static std::unordered_map _overlayToEntityTypes; - QVariantMap convertEntityToOverlayProperties(const EntityItemProperties& entityProps); + // V8TODO: This can be safely removed as soon as 3D overlays are not used anymore by default scripts + /*QVariantMap convertEntityToOverlayProperties(const EntityItemProperties& entityProps); EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, const QString& type, bool add, const QUuid& id); - EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair& rotationToSave, const QString& type, bool add, const QUuid& id = QUuid()); + EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair& rotationToSave, const QString& type, bool add, const QUuid& id = QUuid());*/ private slots: void mousePressOnPointerEvent(const QUuid& id, const PointerEvent& event); diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 683247e934..b4767910cf 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -2944,6 +2944,7 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer } entityDescription["DataVersion"] = _persistDataVersion; entityDescription["Id"] = _persistID; + // V8TODO: Creating new script engine each time is very inefficient ScriptEnginePointer engine = newScriptEngine(); RecurseOctreeToMapOperator theOperator(entityDescription, element, engine.get(), skipDefaultValues, skipThoseWithBadParents, _myAvatar); @@ -3094,6 +3095,7 @@ bool EntityTree::readFromMap(QVariantMap& map, const bool isImport) { // to a ScriptValue, and then to EntityItemProperties. These properties are used // to add the new entity to the EntityTree. QVariantList entitiesQList = map["Entities"].toList(); + // V8TODO: Creating new script engine each time is very inefficient ScriptEnginePointer scriptEngine = newScriptEngine(); if (entitiesQList.length() == 0) { @@ -3269,6 +3271,7 @@ bool EntityTree::readFromMap(QVariantMap& map, const bool isImport) { } bool EntityTree::writeToJSON(QString& jsonString, const OctreeElementPointer& element) { + // V8TODO: Creating new script engine each time is very inefficient ScriptEnginePointer engine = newScriptEngine(); RecurseOctreeToJSONOperator theOperator(element, engine.get(), jsonString); withReadLock([&] {