mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
faster and const EntityTree::findByID()
This commit is contained in:
parent
040710807d
commit
38bc312004
3 changed files with 18 additions and 11 deletions
|
@ -913,18 +913,25 @@ void EntityTree::findEntities(RecurseOctreeOperation& elementFilter,
|
|||
recurseTreeWithOperation(elementFilter, nullptr);
|
||||
}
|
||||
|
||||
EntityItemPointer EntityTree::findEntityByID(const QUuid& id) {
|
||||
EntityItemPointer EntityTree::findEntityByID(const QUuid& id) const {
|
||||
EntityItemID entityID(id);
|
||||
return findEntityByEntityItemID(entityID);
|
||||
}
|
||||
|
||||
EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ {
|
||||
EntityItemPointer foundEntity = NULL;
|
||||
EntityTreeElementPointer containingElement = getContainingElement(entityID);
|
||||
if (containingElement) {
|
||||
foundEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||
EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) const {
|
||||
EntityItemPointer foundEntity = nullptr;
|
||||
{
|
||||
QReadLocker locker(&_entityMapLock);
|
||||
foundEntity = _entityMap.value(entityID);
|
||||
}
|
||||
if (foundEntity && !foundEntity->getElement()) {
|
||||
// special case to maintain legacy behavior:
|
||||
// if the entity is in the map but not in the tree
|
||||
// then pretend the entity doesn't exist
|
||||
return EntityItemPointer(nullptr);
|
||||
} else {
|
||||
return foundEntity;
|
||||
}
|
||||
return foundEntity;
|
||||
}
|
||||
|
||||
void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<QString>& changedProperties) {
|
||||
|
|
|
@ -132,9 +132,9 @@ public:
|
|||
/// \param position point of query in world-frame (meters)
|
||||
/// \param targetRadius radius of query (meters)
|
||||
EntityItemPointer findClosestEntity(const glm::vec3& position, float targetRadius);
|
||||
EntityItemPointer findEntityByID(const QUuid& id);
|
||||
EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID);
|
||||
virtual SpatiallyNestablePointer findByID(const QUuid& id) override { return findEntityByID(id); }
|
||||
EntityItemPointer findEntityByID(const QUuid& id) const;
|
||||
EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID) const;
|
||||
virtual SpatiallyNestablePointer findByID(const QUuid& id) const override { return findEntityByID(id); }
|
||||
|
||||
EntityItemID assignEntityID(const EntityItemID& entityItemID); /// Assigns a known ID for a creator token ID
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ using SpatiallyNestableWeakPointer = std::weak_ptr<SpatiallyNestable>;
|
|||
using SpatiallyNestablePointer = std::shared_ptr<SpatiallyNestable>;
|
||||
class SpatialParentTree {
|
||||
public:
|
||||
virtual SpatiallyNestablePointer findByID(const QUuid& id) { return nullptr; }
|
||||
virtual SpatiallyNestablePointer findByID(const QUuid& id) const { return nullptr; }
|
||||
};
|
||||
class SpatialParentFinder : public Dependency {
|
||||
|
||||
|
|
Loading…
Reference in a new issue