Removed 3D overlays functionality entirely

This commit is contained in:
ksuprynowicz 2023-03-18 17:25:05 +01:00
parent 91d7abc883
commit 420e861a36
4 changed files with 39 additions and 19 deletions

View file

@ -52,6 +52,7 @@ void addAvatarEntities(const QVariantList& avatarEntities) {
EntitySimulationPointer entitySimulation = entityTree->getSimulation(); EntitySimulationPointer entitySimulation = entityTree->getSimulation();
PhysicalEntitySimulationPointer physicalEntitySimulation = std::static_pointer_cast<PhysicalEntitySimulation>(entitySimulation); PhysicalEntitySimulationPointer physicalEntitySimulation = std::static_pointer_cast<PhysicalEntitySimulation>(entitySimulation);
EntityEditPacketSender* entityPacketSender = physicalEntitySimulation->getPacketSender(); EntityEditPacketSender* entityPacketSender = physicalEntitySimulation->getPacketSender();
// V8TODO: Creating new script engine each time is very inefficient
ScriptEnginePointer scriptEngine = newScriptEngine(); ScriptEnginePointer scriptEngine = newScriptEngine();
for (int index = 0; index < avatarEntities.count(); index++) { for (int index = 0; index < avatarEntities.count(); index++) {
const QVariantMap& avatarEntityProperties = avatarEntities.at(index).toMap(); const QVariantMap& avatarEntityProperties = avatarEntities.at(index).toMap();
@ -304,6 +305,7 @@ QVariantMap AvatarBookmarks::getAvatarDataToBookmark() {
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr; EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
if (entityTree) { if (entityTree) {
// V8TODO: Creating new script engine each time is very inefficient
ScriptEnginePointer scriptEngine = newScriptEngine(); ScriptEnginePointer scriptEngine = newScriptEngine();
auto avatarEntities = myAvatar->getAvatarEntityDataNonDefault(); auto avatarEntities = myAvatar->getAvatarEntityDataNonDefault();
for (auto entityID : avatarEntities.keys()) { for (auto entityID : avatarEntities.keys()) {

View file

@ -51,7 +51,8 @@ STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
RayToOverlayIntersectionResultFromScriptValue>(scriptEngine); 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(Box, cube);
ADD_TYPE_MAP(Sphere, sphere); ADD_TYPE_MAP(Sphere, sphere);
_overlayToEntityTypes["rectangle3d"] = "Shape"; _overlayToEntityTypes["rectangle3d"] = "Shape";
@ -195,13 +196,13 @@ QString Overlays::entityToOverlayType(const QString& type) {
return "unknown"; return "unknown";
} }
QString Overlays::overlayToEntityType(const QString& type) { /*QString Overlays::overlayToEntityType(const QString& type) {
auto iter = _overlayToEntityTypes.find(type); auto iter = _overlayToEntityTypes.find(type);
if (iter != _overlayToEntityTypes.end()) { if (iter != _overlayToEntityTypes.end()) {
return iter->second; return iter->second;
} }
return "Unknown"; return "Unknown";
} }*/
#define SET_OVERLAY_PROP_DEFAULT(o, d) \ #define SET_OVERLAY_PROP_DEFAULT(o, d) \
{ \ { \
@ -309,12 +310,14 @@ QString Overlays::overlayToEntityType(const QString& type) {
static QHash<QUuid, std::pair<glm::quat, bool>> savedRotations = QHash<QUuid, std::pair<glm::quat, bool>>(); static QHash<QUuid, std::pair<glm::quat, bool>> savedRotations = QHash<QUuid, std::pair<glm::quat, bool>>();
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<glm::quat, bool> rotation; std::pair<glm::quat, bool> rotation;
return convertOverlayToEntityProperties(overlayProps, rotation, type, add, id); return convertOverlayToEntityProperties(overlayProps, rotation, type, add, id);
} }*/
EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair<glm::quat, bool>& 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<glm::quat, bool>& rotationToSave, const QString& type, bool add, const QUuid& id) {
overlayProps["type"] = type; overlayProps["type"] = type;
SET_OVERLAY_PROP_DEFAULT(alpha, 0.7); SET_OVERLAY_PROP_DEFAULT(alpha, 0.7);
@ -647,9 +650,10 @@ EntityItemProperties Overlays::convertOverlayToEntityProperties(QVariantMap& ove
EntityItemProperties toReturn; EntityItemProperties toReturn;
EntityItemPropertiesFromScriptValueHonorReadOnly(props, toReturn); EntityItemPropertiesFromScriptValueHonorReadOnly(props, toReturn);
return 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(); ScriptEnginePointer scriptEngine = newScriptEngine();
QVariantMap overlayProps = EntityItemPropertiesToScriptValue(scriptEngine.get(), properties).toVariant().toMap(); QVariantMap overlayProps = EntityItemPropertiesToScriptValue(scriptEngine.get(), properties).toVariant().toMap();
@ -778,7 +782,7 @@ QVariantMap Overlays::convertEntityToOverlayProperties(const EntityItemPropertie
RENAME_PROP(localRotation, localOrientation); RENAME_PROP(localRotation, localOrientation);
return overlayProps; return overlayProps;
} }*/
QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) { QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) {
if (_shuttingDown) { if (_shuttingDown) {
@ -810,7 +814,9 @@ QUuid Overlays::addOverlay(const QString& type, const QVariant& properties) {
return QUuid(); 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") { if (entityType == "Unknown") {
return UNKNOWN_ENTITY_ID; 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") { if (entityType == "Text" || entityType == "Image" || entityType == "Grid" || entityType == "Web") {
savedRotations[id] = rotationToSave; savedRotations[id] = rotationToSave;
} }
return id; return id;*/
} }
QUuid Overlays::add2DOverlay(const Overlay::Pointer& overlay) { QUuid Overlays::add2DOverlay(const Overlay::Pointer& overlay) {
@ -882,10 +888,14 @@ bool Overlays::editOverlay(const QUuid& id, const QVariant& properties) {
return true; 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<EntityScriptingInterface>(); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
auto propertyMap = properties.toMap(); auto propertyMap = properties.toMap();
EntityItemProperties entityProperties = convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id); 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) { bool Overlays::editOverlays(const QVariant& propertiesById) {
@ -897,7 +907,7 @@ bool Overlays::editOverlays(const QVariant& propertiesById) {
QVariantMap deferred; QVariantMap deferred;
const QVariantMap map = propertiesById.toMap(); const QVariantMap map = propertiesById.toMap();
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); //auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
for (const auto& key : map.keys()) { for (const auto& key : map.keys()) {
QUuid id = QUuid(key); QUuid id = QUuid(key);
const QVariant& properties = map[key]; const QVariant& properties = map[key];
@ -910,8 +920,10 @@ bool Overlays::editOverlays(const QVariant& propertiesById) {
} }
overlay->setProperties(properties.toMap()); overlay->setProperties(properties.toMap());
} else { } else {
auto propertyMap = properties.toMap(); qDebug() << "Overlays::editOverlays doesn't support editing entities anymore";
entityScriptingInterface->editEntity(id, convertOverlayToEntityProperties(propertyMap, entityScriptingInterface->getEntityType(id), false, id)); // 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));*/
} }
} }

View file

@ -123,7 +123,8 @@ public:
void cleanupAllOverlays(); 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: public slots:
/*@jsdoc /*@jsdoc
@ -762,13 +763,15 @@ private:
QMouseEvent* event, PointerEvent::EventType eventType); QMouseEvent* event, PointerEvent::EventType eventType);
static QString entityToOverlayType(const QString& type); 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<QString, QString> _entityToOverlayTypes; static std::unordered_map<QString, QString> _entityToOverlayTypes;
static std::unordered_map<QString, QString> _overlayToEntityTypes; static std::unordered_map<QString, QString> _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, const QString& type, bool add, const QUuid& id);
EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair<glm::quat, bool>& rotationToSave, const QString& type, bool add, const QUuid& id = QUuid()); EntityItemProperties convertOverlayToEntityProperties(QVariantMap& overlayProps, std::pair<glm::quat, bool>& rotationToSave, const QString& type, bool add, const QUuid& id = QUuid());*/
private slots: private slots:
void mousePressOnPointerEvent(const QUuid& id, const PointerEvent& event); void mousePressOnPointerEvent(const QUuid& id, const PointerEvent& event);

View file

@ -2944,6 +2944,7 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer
} }
entityDescription["DataVersion"] = _persistDataVersion; entityDescription["DataVersion"] = _persistDataVersion;
entityDescription["Id"] = _persistID; entityDescription["Id"] = _persistID;
// V8TODO: Creating new script engine each time is very inefficient
ScriptEnginePointer engine = newScriptEngine(); ScriptEnginePointer engine = newScriptEngine();
RecurseOctreeToMapOperator theOperator(entityDescription, element, engine.get(), skipDefaultValues, RecurseOctreeToMapOperator theOperator(entityDescription, element, engine.get(), skipDefaultValues,
skipThoseWithBadParents, _myAvatar); 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 a ScriptValue, and then to EntityItemProperties. These properties are used
// to add the new entity to the EntityTree. // to add the new entity to the EntityTree.
QVariantList entitiesQList = map["Entities"].toList(); QVariantList entitiesQList = map["Entities"].toList();
// V8TODO: Creating new script engine each time is very inefficient
ScriptEnginePointer scriptEngine = newScriptEngine(); ScriptEnginePointer scriptEngine = newScriptEngine();
if (entitiesQList.length() == 0) { if (entitiesQList.length() == 0) {
@ -3269,6 +3271,7 @@ bool EntityTree::readFromMap(QVariantMap& map, const bool isImport) {
} }
bool EntityTree::writeToJSON(QString& jsonString, const OctreeElementPointer& element) { bool EntityTree::writeToJSON(QString& jsonString, const OctreeElementPointer& element) {
// V8TODO: Creating new script engine each time is very inefficient
ScriptEnginePointer engine = newScriptEngine(); ScriptEnginePointer engine = newScriptEngine();
RecurseOctreeToJSONOperator theOperator(element, engine.get(), jsonString); RecurseOctreeToJSONOperator theOperator(element, engine.get(), jsonString);
withReadLock([&] { withReadLock([&] {