Avoid redundant zone updates

This commit is contained in:
Zach Pomerantz 2016-03-01 17:46:53 -08:00
parent 1547fc15aa
commit d615e2e83b

View file

@ -158,6 +158,8 @@ void EntityTreeRenderer::update() {
} }
bool EntityTreeRenderer::checkEnterLeaveEntities() { bool EntityTreeRenderer::checkEnterLeaveEntities() {
bool didUpdate = false;
if (_tree && !_shuttingDown) { if (_tree && !_shuttingDown) {
glm::vec3 avatarPosition = _viewState->getAvatarPosition(); glm::vec3 avatarPosition = _viewState->getAvatarPosition();
@ -172,6 +174,7 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities); std::static_pointer_cast<EntityTree>(_tree)->findEntities(avatarPosition, radius, foundEntities);
// Whenever you're in an intersection between zones, we will always choose the smallest zone. // Whenever you're in an intersection between zones, we will always choose the smallest zone.
auto oldBestZone = _bestZone;
_bestZone = nullptr; // NOTE: Is this what we want? _bestZone = nullptr; // NOTE: Is this what we want?
_bestZoneVolume = std::numeric_limits<float>::max(); _bestZoneVolume = std::numeric_limits<float>::max();
@ -204,7 +207,10 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
} }
} }
applyZonePropertiesToScene(_bestZone); if (_bestZone != oldBestZone) {
applyZonePropertiesToScene(_bestZone);
didUpdate = true;
}
}); });
// Note: at this point we don't need to worry about the tree being locked, because we only deal with // Note: at this point we don't need to worry about the tree being locked, because we only deal with
@ -228,11 +234,9 @@ bool EntityTreeRenderer::checkEnterLeaveEntities() {
} }
_currentEntitiesInside = entitiesContainingAvatar; _currentEntitiesInside = entitiesContainingAvatar;
_lastAvatarPosition = avatarPosition; _lastAvatarPosition = avatarPosition;
return true;
} }
} }
return false; return didUpdate;
} }
void EntityTreeRenderer::leaveAllEntities() { void EntityTreeRenderer::leaveAllEntities() {