History

workaround for bad physics polling on login

Andrew Meadows committed 9 years ago

Commit 0f4e7fb1 parent 895f79f1 file · +14 −7Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+14−7
@@ -5639,10 +5639,10 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 5638 unmodified lines
56395639 return false;
56405640 }
56415641
5642+ AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(0.5f * PHYSICS_READY_RANGE), glm::vec3(PHYSICS_READY_RANGE));
56425643 QVector<EntityItemPointer> entities;
56435644 entityTree->withReadLock([&] {
5644− AABox box(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
5645− entityTree->findEntities(box, entities);
5645+ entityTree->findEntities(avatarBox, entities);
56465646 });
56475647
56485648 // For reasons I haven't found, we don't necessarily have the full scene when we receive a stats packet. Apply
@@ -5662,11 +5662,18 @@ bool Application::nearbyEntitiesAreReadyForPhysics() { · 13 unmodified lines
56625662 bool result = true;
56635663 foreach (EntityItemPointer entity, entities) {
56645664 if (entity->shouldBePhysical() && !entity->isReadyToComputeShape()) {
5665− static QString repeatedMessage =
5666− LogHandler::getInstance().addRepeatedMessageRegex("Physics disabled until entity loads: .*");
5667− qCDebug(interfaceapp) << "Physics disabled until entity loads: " << entity->getID() << entity->getName();
5668− // don't break here because we want all the relevant entities to start their downloads
5669− result = false;
5665+ // BUG: the findEntities() query above is sometimes returning objects that don't actually overlap
5666+ // TODO: investigate and fix findQueries() but in the meantime...
5667+ // WORKAROUND: test the overlap of each entity to verify it matters
5668+ bool success = false;
5669+ AACube entityCube = entity->getQueryAACube(success);
5670+ if (success && avatarBox.touches(entityCube)) {
5671+ static QString repeatedMessage =
5672+ LogHandler::getInstance().addRepeatedMessageRegex("Physics disabled until entity loads: .*");
5673+ qCDebug(interfaceapp) << "Physics disabled until entity loads: " << entity->getID() << entity->getName();
5674+ // don't break here because we want all the relevant entities to start their downloads
5675+ result = false;
5676+ }
56705677 }
56715678 }
56725679 return result;