mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:48:38 +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);
|
recurseTreeWithOperation(elementFilter, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemPointer EntityTree::findEntityByID(const QUuid& id) {
|
EntityItemPointer EntityTree::findEntityByID(const QUuid& id) const {
|
||||||
EntityItemID entityID(id);
|
EntityItemID entityID(id);
|
||||||
return findEntityByEntityItemID(entityID);
|
return findEntityByEntityItemID(entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ {
|
EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) const {
|
||||||
EntityItemPointer foundEntity = NULL;
|
EntityItemPointer foundEntity = nullptr;
|
||||||
EntityTreeElementPointer containingElement = getContainingElement(entityID);
|
{
|
||||||
if (containingElement) {
|
QReadLocker locker(&_entityMapLock);
|
||||||
foundEntity = containingElement->getEntityWithEntityItemID(entityID);
|
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) {
|
void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<QString>& changedProperties) {
|
||||||
|
|
|
@ -132,9 +132,9 @@ public:
|
||||||
/// \param position point of query in world-frame (meters)
|
/// \param position point of query in world-frame (meters)
|
||||||
/// \param targetRadius radius of query (meters)
|
/// \param targetRadius radius of query (meters)
|
||||||
EntityItemPointer findClosestEntity(const glm::vec3& position, float targetRadius);
|
EntityItemPointer findClosestEntity(const glm::vec3& position, float targetRadius);
|
||||||
EntityItemPointer findEntityByID(const QUuid& id);
|
EntityItemPointer findEntityByID(const QUuid& id) const;
|
||||||
EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID);
|
EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID) const;
|
||||||
virtual SpatiallyNestablePointer findByID(const QUuid& id) override { return findEntityByID(id); }
|
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
|
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>;
|
using SpatiallyNestablePointer = std::shared_ptr<SpatiallyNestable>;
|
||||||
class SpatialParentTree {
|
class SpatialParentTree {
|
||||||
public:
|
public:
|
||||||
virtual SpatiallyNestablePointer findByID(const QUuid& id) { return nullptr; }
|
virtual SpatiallyNestablePointer findByID(const QUuid& id) const { return nullptr; }
|
||||||
};
|
};
|
||||||
class SpatialParentFinder : public Dependency {
|
class SpatialParentFinder : public Dependency {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue