mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:17:45 +02:00
move stuff out of writelock when possible
This commit is contained in:
parent
0bcecdbe66
commit
bbde1bcd63
1 changed files with 13 additions and 14 deletions
|
@ -5643,9 +5643,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() {
|
||||||
// whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
|
// whose bounding boxes cannot be computed (it is too loose for our purposes here). Instead we manufacture
|
||||||
// custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
|
// custom filters and use the general-purpose EntityTree::findEntities(filter, ...)
|
||||||
QVector<EntityItemPointer> entities;
|
QVector<EntityItemPointer> entities;
|
||||||
entityTree->withReadLock([&] {
|
|
||||||
AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
|
AABox avatarBox(getMyAvatar()->getPosition() - glm::vec3(PHYSICS_READY_RANGE), glm::vec3(2 * PHYSICS_READY_RANGE));
|
||||||
|
|
||||||
// create two functions that use avatarBox (entityScan and elementScan), the second calls the first
|
// create two functions that use avatarBox (entityScan and elementScan), the second calls the first
|
||||||
std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
|
std::function<bool (EntityItemPointer&)> entityScan = [=](EntityItemPointer& entity) {
|
||||||
if (entity->shouldBePhysical()) {
|
if (entity->shouldBePhysical()) {
|
||||||
|
@ -5665,6 +5663,7 @@ bool Application::nearbyEntitiesAreReadyForPhysics() {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
entityTree->withReadLock([&] {
|
||||||
// Pass the second function to the general-purpose EntityTree::findEntities()
|
// Pass the second function to the general-purpose EntityTree::findEntities()
|
||||||
// which will traverse the tree, apply the two filter functions (to element, then to entities)
|
// which will traverse the tree, apply the two filter functions (to element, then to entities)
|
||||||
// as it traverses. The end result will be a list of entities that match.
|
// as it traverses. The end result will be a list of entities that match.
|
||||||
|
|
Loading…
Reference in a new issue