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();
}
}
if (properties.parentRelatedPropertyChanged()) {
if (properties.parentRelatedPropertyChanged() && entity->setPuffedQueryAACube()) {
properties.setQueryAACube(entity->getQueryAACube());
}
entity->setLastBroadcast(usecTimestampNow());

View file

@ -374,6 +374,10 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationStep, const QUuid& s
return true;
}
if (_entity->queryAABoxNeedsUpdate()) {
return true;
}
if (_entity->getSimulatorID() != sessionID) {
// we don't own the simulation, but maybe we should...
if (_outgoingPriority != NO_PRORITY) {
@ -466,7 +470,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q
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.
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) {
_queryAACube = queryAACube;
if (queryAACube.getScale() > 0.0f) {
@ -543,11 +547,7 @@ void SpatiallyNestable::setQueryAACube(const AACube& queryAACube) {
}
}
AACube SpatiallyNestable::getMaximumAACube(bool& success) const {
return AACube(getPosition(success) - glm::vec3(0.5f), 1.0f); // XXX
}
bool SpatiallyNestable::setPuffedQueryAACube() {
bool SpatiallyNestable::queryAABoxNeedsUpdate() const {
bool success;
AACube currentAACube = getMaximumAACube(success);
if (!success) {
@ -558,6 +558,15 @@ bool SpatiallyNestable::setPuffedQueryAACube() {
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
_queryAACube = AACube(currentAACube.getCorner() - glm::vec3(currentAACube.getScale()), currentAACube.getScale() * 2.0f);
_queryAACubeSet = true;

View file

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