snapshot after using tree from entity item.

This commit is contained in:
howard-stearns 2016-03-28 16:58:20 -07:00
parent db13b15337
commit b09b9a4a0a
8 changed files with 17 additions and 11 deletions

View file

@ -1010,6 +1010,10 @@ EntityTreePointer EntityItem::getTree() const {
return tree; return tree;
} }
SpatialParentTree* EntityItem::getParentTree() const {
return getTree().get();
}
bool EntityItem::wantTerseEditLogging() const { bool EntityItem::wantTerseEditLogging() const {
EntityTreePointer tree = getTree(); EntityTreePointer tree = getTree();
return tree ? tree->wantTerseEditLogging() : false; return tree ? tree->wantTerseEditLogging() : false;

View file

@ -359,6 +359,7 @@ public:
void setPhysicsInfo(void* data) { _physicsInfo = data; } void setPhysicsInfo(void* data) { _physicsInfo = data; }
EntityTreeElementPointer getElement() const { return _element; } EntityTreeElementPointer getElement() const { return _element; }
EntityTreePointer getTree() const; EntityTreePointer getTree() const;
virtual SpatialParentTree* getParentTree() const;
bool wantTerseEditLogging() const; bool wantTerseEditLogging() const;
glm::mat4 getEntityToWorldMatrix() const; glm::mat4 getEntityToWorldMatrix() const;

View file

@ -90,7 +90,7 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
_simulation->addEntity(entity); _simulation->addEntity(entity);
} }
if (!entity->isParentIDValid(this)) { if (!entity->isParentIDValid()) {
_missingParent.append(entity); _missingParent.append(entity);
} }
@ -260,7 +260,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
_missingParent.append(childEntity); _missingParent.append(childEntity);
continue; continue;
} }
if (!childEntity->isParentIDValid(this)) { if (!childEntity->isParentIDValid()) {
_missingParent.append(childEntity); _missingParent.append(childEntity);
} }
@ -1027,7 +1027,7 @@ void EntityTree::fixupMissingParents() {
} }
bool doMove = false; bool doMove = false;
if (entity->isParentIDValid(this)) { if (entity->isParentIDValid()) {
qCDebug(entities) << "HRS fixme valid parent" << entity->getEntityItemID() << queryAACubeSuccess; qCDebug(entities) << "HRS fixme valid parent" << entity->getEntityItemID() << queryAACubeSuccess;
// this entity's parent was previously not known, and now is. Update its location in the EntityTree... // this entity's parent was previously not known, and now is. Update its location in the EntityTree...
doMove = true; doMove = true;
@ -1040,7 +1040,7 @@ void EntityTree::fixupMissingParents() {
_childrenOfAvatars[entity->getParentID()] += entity->getEntityItemID(); _childrenOfAvatars[entity->getParentID()] += entity->getEntityItemID();
doMove = true; doMove = true;
} }
else qCDebug(entities) << "HRS fixme failed parent" << entity->getEntityItemID() << queryAACubeSuccess; else qCDebug(entities) << "HRS fixme failed parent" << entity->getEntityItemID() << queryAACubeSuccess << "parent:" << entity->getParentID() << !!findEntityByID(entity->getParentID());
if (queryAACubeSuccess && doMove) { if (queryAACubeSuccess && doMove) {
moveOperator.addEntityToMoveList(entity, newCube); moveOperator.addEntityToMoveList(entity, newCube);

View file

@ -126,7 +126,7 @@ public:
EntityItemPointer findClosestEntity(glm::vec3 position, float targetRadius); EntityItemPointer findClosestEntity(glm::vec3 position, float targetRadius);
EntityItemPointer findEntityByID(const QUuid& id); EntityItemPointer findEntityByID(const QUuid& id);
EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID); EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID);
SpatiallyNestablePointer EntityTree::findByID(const QUuid& id) { return findEntityByID(id); } virtual SpatiallyNestablePointer findByID(const QUuid& id) { 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

View file

@ -51,7 +51,7 @@ bool RecurseOctreeToMapOperator::postRecursion(OctreeElementPointer element) {
QVariantList entitiesQList = qvariant_cast<QVariantList>(_map["Entities"]); QVariantList entitiesQList = qvariant_cast<QVariantList>(_map["Entities"]);
entityTreeElement->forEachEntity([&](EntityItemPointer entityItem) { entityTreeElement->forEachEntity([&](EntityItemPointer entityItem) {
if (_skipThoseWithBadParents && !entityItem->isParentIDValid(_entityTree)) { if (_skipThoseWithBadParents && !entityItem->isParentIDValid()) {
return; // we weren't able to resolve a parent from _parentID, so don't save this entity. return; // we weren't able to resolve a parent from _parentID, so don't save this entity.
} }

View file

@ -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:
SpatiallyNestablePointer findByID(const QUuid& id) { return nullptr; } virtual SpatiallyNestablePointer findByID(const QUuid& id) { return nullptr; }
}; };
class SpatialParentFinder : public Dependency { class SpatialParentFinder : public Dependency {

View file

@ -70,7 +70,7 @@ Transform SpatiallyNestable::getParentTransform(bool& success, int depth) const
return result; return result;
} }
SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success, SpatialParentTree* entityTree) const { SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success) const {
SpatiallyNestablePointer parent = _parent.lock(); SpatiallyNestablePointer parent = _parent.lock();
QUuid parentID = getParentID(); // used for its locking QUuid parentID = getParentID(); // used for its locking
@ -105,7 +105,7 @@ SpatiallyNestablePointer SpatiallyNestable::getParentPointer(bool& success, Spat
success = false; success = false;
return nullptr; return nullptr;
} }
_parent = parentFinder->find(parentID, success, entityTree); _parent = parentFinder->find(parentID, success, getParentTree());
if (!success) { if (!success) {
return nullptr; return nullptr;
} }

View file

@ -139,14 +139,15 @@ public:
void die() { _isDead = true; } void die() { _isDead = true; }
bool isDead() const { return _isDead; } bool isDead() const { return _isDead; }
bool isParentIDValid(SpatialParentTree* entityTree = nullptr) const { bool success = false; getParentPointer(success, entityTree); return success; } bool isParentIDValid() const { bool success = false; getParentPointer(success); return success; }
virtual SpatialParentTree* getParentTree() const { return nullptr; }
protected: protected:
const NestableType _nestableType; // EntityItem or an AvatarData const NestableType _nestableType; // EntityItem or an AvatarData
QUuid _id; QUuid _id;
QUuid _parentID; // what is this thing's transform relative to? QUuid _parentID; // what is this thing's transform relative to?
quint16 _parentJointIndex { 0 }; // which joint of the parent is this relative to? quint16 _parentJointIndex { 0 }; // which joint of the parent is this relative to?
SpatiallyNestablePointer getParentPointer(bool& success, SpatialParentTree* entityTree = nullptr) const; SpatiallyNestablePointer getParentPointer(bool& success) const;
mutable SpatiallyNestableWeakPointer _parent; mutable SpatiallyNestableWeakPointer _parent;