mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01: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();
|
||||
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;
|
||||
it = c.erase(it);
|
||||
} else {
|
||||
|
@ -1208,8 +1209,9 @@ bool EntityTreeRenderer::LayeredZones::clearDomainAndNonOwnedZones(const QUuid&
|
|||
std::pair<bool, bool> EntityTreeRenderer::LayeredZones::getZoneInteractionProperties() const {
|
||||
auto it = c.cbegin();
|
||||
while (it != c.cend()) {
|
||||
if (it->zone && it->zone->isDomainEntity()) {
|
||||
return { it->zone->getFlyingAllowed(), it->zone->getGhostingAllowed() };
|
||||
auto zone = it->zone.lock();
|
||||
if (zone && zone->isDomainEntity()) {
|
||||
return { zone->getFlyingAllowed(), zone->getGhostingAllowed() };
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
@ -1219,7 +1221,7 @@ std::pair<bool, bool> EntityTreeRenderer::LayeredZones::getZoneInteractionProper
|
|||
void EntityTreeRenderer::LayeredZones::remove(const std::shared_ptr<ZoneEntityItem>& zone) {
|
||||
auto it = c.begin();
|
||||
while (it != c.end()) {
|
||||
if (it->zone == zone) {
|
||||
if (it->zone.lock() == zone) {
|
||||
break;
|
||||
}
|
||||
it++;
|
||||
|
@ -1262,7 +1264,7 @@ bool EntityTreeRenderer::LayeredZones::equals(const LayeredZones& other) const {
|
|||
void EntityTreeRenderer::LayeredZones::appendRenderIDs(render::ItemIDs& list, EntityTreeRenderer* entityTreeRenderer) const {
|
||||
auto it = c.cbegin();
|
||||
while (it != c.cend()) {
|
||||
if (it->zone) {
|
||||
if (it->zone.lock()) {
|
||||
auto id = entityTreeRenderer->renderableIdForEntityId(it->id);
|
||||
if (id != render::Item::INVALID_ITEM_ID) {
|
||||
list.push_back(id);
|
||||
|
|
|
@ -213,11 +213,11 @@ private:
|
|||
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 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) || (*this == r); }
|
||||
|
||||
std::shared_ptr<ZoneEntityItem> zone;
|
||||
std::weak_ptr<ZoneEntityItem> zone;
|
||||
QUuid id;
|
||||
float volume;
|
||||
};
|
||||
|
|
|
@ -43,6 +43,8 @@ const Selection::Name ZoneRendererTask::ZONES_SELECTION { "RankedZones" };
|
|||
|
||||
void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& output) {
|
||||
// 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);
|
||||
|
||||
// just setup the current zone env
|
||||
|
|
|
@ -277,9 +277,6 @@ void Scene::processTransactionFrame(const Transaction& transaction) {
|
|||
// removes
|
||||
removeItems(transaction._removedItems);
|
||||
|
||||
// handle selections
|
||||
resetSelections(transaction._resetSelections);
|
||||
|
||||
// add transitions
|
||||
transitionItems(transaction._addedTransitions);
|
||||
reApplyTransitions(transaction._reAppliedTransitions);
|
||||
|
@ -290,6 +287,8 @@ void Scene::processTransactionFrame(const Transaction& transaction) {
|
|||
_numAllocatedItems.exchange(maxID);
|
||||
}
|
||||
|
||||
resetSelections(transaction._resetSelections);
|
||||
|
||||
resetHighlights(transaction._highlightResets);
|
||||
removeHighlights(transaction._highlightRemoves);
|
||||
queryHighlights(transaction._highlightQueries);
|
||||
|
|
Loading…
Reference in a new issue