mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge pull request #13 from birarda/entity-script-server
fix bug with JSON in query, avoid frustum check in EntityTreeElement
This commit is contained in:
commit
2117b1fed3
7 changed files with 19 additions and 8 deletions
|
@ -434,6 +434,7 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode*
|
|||
nodeData->getLastTimeBagEmpty(),
|
||||
isFullScene, &nodeData->stats, _myServer->getJurisdiction(),
|
||||
&nodeData->extraEncodeData,
|
||||
nodeData->getUsesFrustum(),
|
||||
nodeData);
|
||||
nodeData->copyCurrentViewFrustum(params.viewFrustum);
|
||||
if (viewFrustumChanged) {
|
||||
|
|
|
@ -246,6 +246,7 @@ void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const
|
|||
if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
|
||||
QString scriptUrl = entity->getServerScripts();
|
||||
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
||||
qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID;
|
||||
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
|
||||
entity->serverScriptHasPreloaded();
|
||||
}
|
||||
|
|
|
@ -2246,7 +2246,7 @@ bool EntityItem::matchesJSONFilters(const QJsonObject& jsonFilters) const {
|
|||
|
||||
static const QString SERVER_SCRIPTS_PROPERTY = "serverScripts";
|
||||
|
||||
for (auto& property : jsonFilters.keys()) {
|
||||
foreach(const auto& property, jsonFilters.keys()) {
|
||||
if (property == SERVER_SCRIPTS_PROPERTY && jsonFilters[property] == EntityQueryFilterSymbol::NonDefault) {
|
||||
// check if this entity has a non-default value for serverScripts
|
||||
if (_serverScripts != ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS) {
|
||||
|
|
|
@ -279,7 +279,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
int numberOfEntitiesOffset = 0;
|
||||
withReadLock([&] {
|
||||
QVector<uint16_t> indexesOfEntitiesToInclude;
|
||||
|
||||
|
||||
// It's possible that our element has been previous completed. In this case we'll simply not include any of our
|
||||
// entities for encoding. This is needed because we encode the element data at the "parent" level, and so we
|
||||
// need to handle the case where our sibling elements need encoding but we don't.
|
||||
|
@ -300,6 +300,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
auto jsonFilters = entityNodeData->getJSONParameters();
|
||||
|
||||
if (!jsonFilters.isEmpty()) {
|
||||
|
||||
// if params include JSON filters, check if this entity matches
|
||||
bool entityMatchesFilters = entity->matchesJSONFilters(jsonFilters);
|
||||
|
||||
|
@ -322,14 +323,13 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hadElementExtraData) {
|
||||
includeThisEntity = includeThisEntity &&
|
||||
entityTreeElementExtraEncodeData->entities.contains(entity->getEntityItemID());
|
||||
}
|
||||
|
||||
if (includeThisEntity || params.recurseEverything) {
|
||||
if (params.usesFrustum && (includeThisEntity || params.recurseEverything)) {
|
||||
|
||||
// we want to use the maximum possible box for this, so that we don't have to worry about the nuance of
|
||||
// simulation changing what's visible. consider the case where the entity contains an angular velocity
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
OctreeSceneStats* stats;
|
||||
JurisdictionMap* jurisdictionMap;
|
||||
OctreeElementExtraEncodeData* extraEncodeData;
|
||||
bool usesFrustum;
|
||||
NodeData* nodeData;
|
||||
|
||||
// output hints from the encode process
|
||||
|
@ -111,6 +112,7 @@ public:
|
|||
OctreeSceneStats* stats = IGNORE_SCENE_STATS,
|
||||
JurisdictionMap* jurisdictionMap = IGNORE_JURISDICTION_MAP,
|
||||
OctreeElementExtraEncodeData* extraEncodeData = nullptr,
|
||||
bool usesFrustum = true,
|
||||
NodeData* nodeData = nullptr) :
|
||||
lastQuerySent(lastQuerySent),
|
||||
maxEncodeLevel(maxEncodeLevel),
|
||||
|
@ -124,6 +126,7 @@ public:
|
|||
stats(stats),
|
||||
jurisdictionMap(jurisdictionMap),
|
||||
extraEncodeData(extraEncodeData),
|
||||
usesFrustum(usesFrustum),
|
||||
nodeData(nodeData),
|
||||
stopReason(UNKNOWN)
|
||||
{
|
||||
|
|
|
@ -90,7 +90,7 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
|||
|
||||
// check if this query uses a view frustum
|
||||
memcpy(&_usesFrustum, sourceBuffer, sizeof(_usesFrustum));
|
||||
sourceBuffer += _usesFrustum;
|
||||
sourceBuffer += sizeof(_usesFrustum);
|
||||
|
||||
if (_usesFrustum) {
|
||||
// unpack camera details
|
||||
|
@ -132,7 +132,10 @@ int OctreeQuery::parseData(ReceivedMessage& message) {
|
|||
sourceBuffer += binaryParametersBytes;
|
||||
|
||||
// grab the parameter object from the packed binary representation of JSON
|
||||
_jsonParameters = QJsonDocument::fromBinaryData(binaryJSONParameters).object();
|
||||
auto newJsonDocument = QJsonDocument::fromBinaryData(binaryJSONParameters);
|
||||
|
||||
QWriteLocker jsonParameterLocker { &_jsonParametersLock };
|
||||
_jsonParameters = newJsonDocument.object();
|
||||
}
|
||||
|
||||
return sourceBuffer - startPosition;
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef unsigned long long quint64;
|
|||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QReadWriteLock>
|
||||
|
||||
#include <NodeData.h>
|
||||
|
||||
|
@ -69,8 +70,9 @@ public:
|
|||
void setCameraCenterRadius(float radius) { _cameraCenterRadius = radius; }
|
||||
|
||||
// getters/setters for JSON filter
|
||||
QJsonObject getJSONParameters() { return _jsonParameters; }
|
||||
void setJSONParameters(const QJsonObject& jsonParameters) { _jsonParameters = jsonParameters; }
|
||||
QJsonObject getJSONParameters() { QReadLocker locker { &_jsonParametersLock }; return _jsonParameters; }
|
||||
void setJSONParameters(const QJsonObject& jsonParameters)
|
||||
{ QWriteLocker locker { &_jsonParametersLock }; _jsonParameters = jsonParameters; }
|
||||
|
||||
// related to Octree Sending strategies
|
||||
int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; }
|
||||
|
@ -104,6 +106,7 @@ protected:
|
|||
uint8_t _usesFrustum = true;
|
||||
|
||||
QJsonObject _jsonParameters;
|
||||
QReadWriteLock _jsonParametersLock;
|
||||
|
||||
private:
|
||||
// privatize the copy constructor and assignment operator so they cannot be called
|
||||
|
|
Loading…
Reference in a new issue