From 6e6f2c50b8e64086059aacd788d82580b7265124 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 17 Jan 2017 14:28:59 -0800 Subject: [PATCH] leverage OctreeQuery enhancements in EntityScriptServer/OHV --- assignment-client/src/scripts/EntityScriptServer.cpp | 8 ++++++++ libraries/octree/src/OctreeHeadlessViewer.h | 4 ++++ libraries/octree/src/OctreeQuery.cpp | 2 ++ libraries/octree/src/OctreeQuery.h | 2 ++ 4 files changed, 16 insertions(+) diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index a1635ff77c..f17785d2ed 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -88,6 +88,14 @@ void EntityScriptServer::run() { _entityViewer.setJurisdictionListener(entityScriptingInterface->getJurisdictionListener()); _entityViewer.init(); + + // setup the JSON filter that asks for entities with a non-default serverScripts property + QJsonObject queryJSONParameters; + queryJSONParameters["serverScripts"] = OctreeQuery::NON_DEFAULT_FILTER; + + // setup the JSON parameters so that OctreeQuery does not use a frustum and uses our JSON filter + _entityViewer.setQueryUsesFrustum(false); + _entityViewer.setQueryJSONParameters(queryJSONParameters); entityScriptingInterface->setEntityTree(_entityViewer.getTree()); diff --git a/libraries/octree/src/OctreeHeadlessViewer.h b/libraries/octree/src/OctreeHeadlessViewer.h index b43dceeba6..9e5b458048 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.h +++ b/libraries/octree/src/OctreeHeadlessViewer.h @@ -64,6 +64,10 @@ public slots: int getMaxPacketsPerSecond() const { return _maxPacketsPerSecond; } unsigned getOctreeElementsCount() const { return _tree->getOctreeElementsCount(); } + + // octree query adjustments + void setQueryUsesFrustum(bool queryUsesFrustum) { _octreeQuery.setUsesFrustum(queryUsesFrustum); } + void setQueryJSONParameters(QJsonObject queryJSONParameters) { _octreeQuery.setJSONParameters(queryJSONParameters); } private: JurisdictionListener* _jurisdictionListener = nullptr; diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 658bc67ba9..72b0838223 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -17,6 +17,8 @@ #include "OctreeConstants.h" #include "OctreeQuery.h" +const QString OctreeQuery::NON_DEFAULT_FILTER = "+"; + OctreeQuery::OctreeQuery() { _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS; diff --git a/libraries/octree/src/OctreeQuery.h b/libraries/octree/src/OctreeQuery.h index 79285697a5..cfd2edcf8a 100644 --- a/libraries/octree/src/OctreeQuery.h +++ b/libraries/octree/src/OctreeQuery.h @@ -42,6 +42,8 @@ class OctreeQuery : public NodeData { public: OctreeQuery(); virtual ~OctreeQuery() {} + + static const QString NON_DEFAULT_FILTER; int getBroadcastData(unsigned char* destinationBuffer); int parseData(ReceivedMessage& message) override;