mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:31:13 +02:00
use weak ptrs, add comment about SelectSortItems performance
This commit is contained in:
parent
da092cc5f0
commit
04198c6bfc
4 changed files with 13 additions and 10 deletions
|
@ -1191,7 +1191,8 @@ bool EntityTreeRenderer::LayeredZones::clearDomainAndNonOwnedZones(const QUuid&
|
||||||
|
|
||||||
auto it = c.begin();
|
auto it = c.begin();
|
||||||
while (it != c.end()) {
|
while (it != c.end()) {
|
||||||
if (!(it->zone->isLocalEntity() || (it->zone->isAvatarEntity() && it->zone->getOwningAvatarID() == sessionUUID))) {
|
auto zone = it->zone.lock();
|
||||||
|
if (!zone || !(zone->isLocalEntity() || (zone->isAvatarEntity() && zone->getOwningAvatarID() == sessionUUID))) {
|
||||||
zonesChanged = true;
|
zonesChanged = true;
|
||||||
it = c.erase(it);
|
it = c.erase(it);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1208,8 +1209,9 @@ bool EntityTreeRenderer::LayeredZones::clearDomainAndNonOwnedZones(const QUuid&
|
||||||
std::pair<bool, bool> EntityTreeRenderer::LayeredZones::getZoneInteractionProperties() const {
|
std::pair<bool, bool> EntityTreeRenderer::LayeredZones::getZoneInteractionProperties() const {
|
||||||
auto it = c.cbegin();
|
auto it = c.cbegin();
|
||||||
while (it != c.cend()) {
|
while (it != c.cend()) {
|
||||||
if (it->zone && it->zone->isDomainEntity()) {
|
auto zone = it->zone.lock();
|
||||||
return { it->zone->getFlyingAllowed(), it->zone->getGhostingAllowed() };
|
if (zone && zone->isDomainEntity()) {
|
||||||
|
return { zone->getFlyingAllowed(), zone->getGhostingAllowed() };
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
@ -1219,7 +1221,7 @@ std::pair<bool, bool> EntityTreeRenderer::LayeredZones::getZoneInteractionProper
|
||||||
void EntityTreeRenderer::LayeredZones::remove(const std::shared_ptr<ZoneEntityItem>& zone) {
|
void EntityTreeRenderer::LayeredZones::remove(const std::shared_ptr<ZoneEntityItem>& zone) {
|
||||||
auto it = c.begin();
|
auto it = c.begin();
|
||||||
while (it != c.end()) {
|
while (it != c.end()) {
|
||||||
if (it->zone == zone) {
|
if (it->zone.lock() == zone) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
|
@ -1262,7 +1264,7 @@ bool EntityTreeRenderer::LayeredZones::equals(const LayeredZones& other) const {
|
||||||
void EntityTreeRenderer::LayeredZones::appendRenderIDs(render::ItemIDs& list, EntityTreeRenderer* entityTreeRenderer) const {
|
void EntityTreeRenderer::LayeredZones::appendRenderIDs(render::ItemIDs& list, EntityTreeRenderer* entityTreeRenderer) const {
|
||||||
auto it = c.cbegin();
|
auto it = c.cbegin();
|
||||||
while (it != c.cend()) {
|
while (it != c.cend()) {
|
||||||
if (it->zone) {
|
if (it->zone.lock()) {
|
||||||
auto id = entityTreeRenderer->renderableIdForEntityId(it->id);
|
auto id = entityTreeRenderer->renderableIdForEntityId(it->id);
|
||||||
if (id != render::Item::INVALID_ITEM_ID) {
|
if (id != render::Item::INVALID_ITEM_ID) {
|
||||||
list.push_back(id);
|
list.push_back(id);
|
||||||
|
|
|
@ -213,11 +213,11 @@ private:
|
||||||
LayeredZone(std::shared_ptr<ZoneEntityItem> zone) : zone(zone), id(zone->getID()), volume(zone->getVolumeEstimate()) {}
|
LayeredZone(std::shared_ptr<ZoneEntityItem> zone) : zone(zone), id(zone->getID()), volume(zone->getVolumeEstimate()) {}
|
||||||
|
|
||||||
bool operator>(const LayeredZone& r) const { return volume > r.volume; }
|
bool operator>(const LayeredZone& r) const { return volume > r.volume; }
|
||||||
bool operator==(const LayeredZone& r) const { return zone.get() == r.zone.get(); }
|
bool operator==(const LayeredZone& r) const { return zone.lock() == r.zone.lock(); }
|
||||||
bool operator!=(const LayeredZone& r) const { return !(*this == r); }
|
bool operator!=(const LayeredZone& r) const { return !(*this == r); }
|
||||||
bool operator>=(const LayeredZone& r) const { return (*this > r) || (*this == r); }
|
bool operator>=(const LayeredZone& r) const { return (*this > r) || (*this == r); }
|
||||||
|
|
||||||
std::shared_ptr<ZoneEntityItem> zone;
|
std::weak_ptr<ZoneEntityItem> zone;
|
||||||
QUuid id;
|
QUuid id;
|
||||||
float volume;
|
float volume;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,6 +43,8 @@ const Selection::Name ZoneRendererTask::ZONES_SELECTION { "RankedZones" };
|
||||||
|
|
||||||
void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& output) {
|
void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& output) {
|
||||||
// Filter out the sorted list of zones
|
// Filter out the sorted list of zones
|
||||||
|
// FIXME: the zones in the selection are already sorted, but we're doing another sort here to pick the selected items
|
||||||
|
// out of `input`, which means we're also looping over the inItems an extra time.
|
||||||
const auto zoneItems = task.addJob<render::SelectSortItems>("FilterZones", input, ZONES_SELECTION);
|
const auto zoneItems = task.addJob<render::SelectSortItems>("FilterZones", input, ZONES_SELECTION);
|
||||||
|
|
||||||
// just setup the current zone env
|
// just setup the current zone env
|
||||||
|
|
|
@ -277,9 +277,6 @@ void Scene::processTransactionFrame(const Transaction& transaction) {
|
||||||
// removes
|
// removes
|
||||||
removeItems(transaction._removedItems);
|
removeItems(transaction._removedItems);
|
||||||
|
|
||||||
// handle selections
|
|
||||||
resetSelections(transaction._resetSelections);
|
|
||||||
|
|
||||||
// add transitions
|
// add transitions
|
||||||
transitionItems(transaction._addedTransitions);
|
transitionItems(transaction._addedTransitions);
|
||||||
reApplyTransitions(transaction._reAppliedTransitions);
|
reApplyTransitions(transaction._reAppliedTransitions);
|
||||||
|
@ -290,6 +287,8 @@ void Scene::processTransactionFrame(const Transaction& transaction) {
|
||||||
_numAllocatedItems.exchange(maxID);
|
_numAllocatedItems.exchange(maxID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetSelections(transaction._resetSelections);
|
||||||
|
|
||||||
resetHighlights(transaction._highlightResets);
|
resetHighlights(transaction._highlightResets);
|
||||||
removeHighlights(transaction._highlightRemoves);
|
removeHighlights(transaction._highlightRemoves);
|
||||||
queryHighlights(transaction._highlightQueries);
|
queryHighlights(transaction._highlightQueries);
|
||||||
|
|
Loading…
Reference in a new issue