From 7ec27cab13f5b51fae640210c543e7a4db16a55e Mon Sep 17 00:00:00 2001 From: David Kelly Date: Fri, 10 Feb 2017 12:47:48 -0700 Subject: [PATCH] Use EntityItem.contains Cuz it works - seemed like it was broken but nope. Also, trim off the filters for zones that no longer are in the tree. --- libraries/entities/src/EntityEditFilters.cpp | 17 ++++++++++++++--- libraries/entities/src/ZoneEntityItem.cpp | 8 -------- libraries/entities/src/ZoneEntityItem.h | 1 - 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libraries/entities/src/EntityEditFilters.cpp b/libraries/entities/src/EntityEditFilters.cpp index 385fb91c81..e914248118 100644 --- a/libraries/entities/src/EntityEditFilters.cpp +++ b/libraries/entities/src/EntityEditFilters.cpp @@ -17,6 +17,7 @@ QList EntityEditFilters::getZonesByPosition(glm::vec3& position) { QList zones; + QList missingZones; _lock.lockForRead(); qCDebug(entities) << "looking at " << _filterFunctionMap.size() << "possible zones, at " << position; for (auto it = _filterFunctionMap.begin(); it != _filterFunctionMap.end(); it++) { @@ -25,14 +26,23 @@ QList EntityEditFilters::getZonesByPosition(glm::vec3& position) { // for now, look it up in the tree (soon we need to cache or similar?) EntityItemPointer itemPtr = _tree->findEntityByEntityItemID(id); auto zone = std::dynamic_pointer_cast(itemPtr); - if (zone && zone->containsPoint(position)) { + if (!zone) { + missingZones.append(id); + } else if (zone->contains(position)) { zones.append(id); } } else { + // the null id is the global filter we put in the domain server's + // advanced entity server settings zones.append(id); } } _lock.unlock(); + // TODO: maybe do this later (not block filter) + // now remove filters for missing zones + for (auto id : missingZones) { + removeFilter(id); + } return zones; } @@ -89,14 +99,15 @@ bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& proper // make propertiesIn reflect the changes, for next filter... propertiesIn.copyFromScriptValue(result, false); - // and update propertiesOut too. #TODO: this could be more efficient... + // and update propertiesOut too. TODO: this could be more efficient... propertiesOut.copyFromScriptValue(result, false); // Javascript objects are == only if they are the same object. To compare arbitrary values, we need to use JSON. auto out = QJsonValue::fromVariant(result.toVariant()); wasChanged |= (in != out); } else { // an edit was rejected, so we stop here and return false - qCDebug(entities) << "Edit rejected by " << *it; + qCDebug(entities) << "Edit rejected by filter " << *it ; + return false; } } } diff --git a/libraries/entities/src/ZoneEntityItem.cpp b/libraries/entities/src/ZoneEntityItem.cpp index 9273298d3e..7158bc2588 100644 --- a/libraries/entities/src/ZoneEntityItem.cpp +++ b/libraries/entities/src/ZoneEntityItem.cpp @@ -233,11 +233,3 @@ void ZoneEntityItem::setFilterURL(QString url) { } } -bool ZoneEntityItem::containsPoint(glm::vec3& position) { - // use _shapeType shortly - // for now bounding box just so I can get end-to-end working - bool success; - bool result = getAABox(success).contains(position); - return result && success; -} - diff --git a/libraries/entities/src/ZoneEntityItem.h b/libraries/entities/src/ZoneEntityItem.h index f804ac8dbb..2bef95e452 100644 --- a/libraries/entities/src/ZoneEntityItem.h +++ b/libraries/entities/src/ZoneEntityItem.h @@ -76,7 +76,6 @@ public: void setGhostingAllowed(bool value) { _ghostingAllowed = value; } QString getFilterURL() const { return _filterURL; } void setFilterURL(const QString url); - bool containsPoint(glm::vec3& position); virtual bool supportsDetailedRayIntersection() const override { return true; } virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,