more queryAABox experimenting

This commit is contained in:
Seth Alves 2015-12-17 16:18:41 -08:00
parent 2dd2a49141
commit 688448fe41
4 changed files with 21 additions and 7 deletions

View file

@ -274,7 +274,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
entity->flagForOwnership(); entity->flagForOwnership();
} }
} }
if (properties.parentRelatedPropertyChanged()) { if (properties.parentRelatedPropertyChanged() && entity->setPuffedQueryAACube()) {
properties.setQueryAACube(entity->getQueryAACube()); properties.setQueryAACube(entity->getQueryAACube());
} }
entity->setLastBroadcast(usecTimestampNow()); entity->setLastBroadcast(usecTimestampNow());

View file

@ -374,6 +374,10 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationStep, const QUuid& s
return true; return true;
} }
if (_entity->queryAABoxNeedsUpdate()) {
return true;
}
if (_entity->getSimulatorID() != sessionID) { if (_entity->getSimulatorID() != sessionID) {
// we don't own the simulation, but maybe we should... // we don't own the simulation, but maybe we should...
if (_outgoingPriority != NO_PRORITY) { if (_outgoingPriority != NO_PRORITY) {
@ -466,7 +470,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q
properties.setActionData(_serverActionData); properties.setActionData(_serverActionData);
} }
if (properties.parentRelatedPropertyChanged()) { if (properties.parentRelatedPropertyChanged() && _entity->setPuffedQueryAACube()) {
// due to parenting, the server may not know where something is in world-space, so include the bounding cube. // due to parenting, the server may not know where something is in world-space, so include the bounding cube.
properties.setQueryAACube(_entity->getQueryAACube()); properties.setQueryAACube(_entity->getQueryAACube());
} }

View file

@ -536,6 +536,10 @@ void SpatiallyNestable::locationChanged() {
}); });
} }
AACube SpatiallyNestable::getMaximumAACube(bool& success) const {
return AACube(getPosition(success) - glm::vec3(0.5f), 1.0f); // XXX
}
void SpatiallyNestable::setQueryAACube(const AACube& queryAACube) { void SpatiallyNestable::setQueryAACube(const AACube& queryAACube) {
_queryAACube = queryAACube; _queryAACube = queryAACube;
if (queryAACube.getScale() > 0.0f) { if (queryAACube.getScale() > 0.0f) {
@ -543,11 +547,7 @@ void SpatiallyNestable::setQueryAACube(const AACube& queryAACube) {
} }
} }
AACube SpatiallyNestable::getMaximumAACube(bool& success) const { bool SpatiallyNestable::queryAABoxNeedsUpdate() const {
return AACube(getPosition(success) - glm::vec3(0.5f), 1.0f); // XXX
}
bool SpatiallyNestable::setPuffedQueryAACube() {
bool success; bool success;
AACube currentAACube = getMaximumAACube(success); AACube currentAACube = getMaximumAACube(success);
if (!success) { if (!success) {
@ -558,6 +558,15 @@ bool SpatiallyNestable::setPuffedQueryAACube() {
return false; return false;
} }
return true;
}
bool SpatiallyNestable::setPuffedQueryAACube() {
if (!queryAABoxNeedsUpdate()) {
return false;
}
bool success;
AACube currentAACube = getMaximumAACube(success);
// make an AACube with edges twice as long and centered on the object // make an AACube with edges twice as long and centered on the object
_queryAACube = AACube(currentAACube.getCorner() - glm::vec3(currentAACube.getScale()), currentAACube.getScale() * 2.0f); _queryAACube = AACube(currentAACube.getCorner() - glm::vec3(currentAACube.getScale()), currentAACube.getScale() * 2.0f);
_queryAACubeSet = true; _queryAACubeSet = true;

View file

@ -72,6 +72,7 @@ public:
virtual bool setPuffedQueryAACube(); virtual bool setPuffedQueryAACube();
virtual void setQueryAACube(const AACube& queryAACube); virtual void setQueryAACube(const AACube& queryAACube);
virtual bool queryAABoxNeedsUpdate() const;
virtual AACube getQueryAACube(bool& success) const; virtual AACube getQueryAACube(bool& success) const;
virtual AACube getQueryAACube() const; virtual AACube getQueryAACube() const;