mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
children collision hulls appear to be in the right place, now
This commit is contained in:
parent
67f222cb3f
commit
5c94147f40
3 changed files with 29 additions and 19 deletions
|
@ -123,15 +123,14 @@ void EntityTree::postAddEntity(EntityItemPointer entity) {
|
|||
}
|
||||
|
||||
if (!entity->getParentID().isNull()) {
|
||||
QWriteLocker locker(&_missingParentLock);
|
||||
_missingParent.append(entity);
|
||||
addToNeedsParentFixupList(entity);
|
||||
}
|
||||
|
||||
_isDirty = true;
|
||||
emit addingEntity(entity->getEntityItemID());
|
||||
|
||||
// find and hook up any entities with this entity as a (previously) missing parent
|
||||
fixupMissingParents();
|
||||
fixupNeedsParentFixups();
|
||||
}
|
||||
|
||||
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
|
||||
|
@ -291,13 +290,11 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
|||
bool success;
|
||||
AACube queryCube = childEntity->getQueryAACube(success);
|
||||
if (!success) {
|
||||
QWriteLocker locker(&_missingParentLock);
|
||||
_missingParent.append(childEntity);
|
||||
addToNeedsParentFixupList(childEntity);
|
||||
continue;
|
||||
}
|
||||
if (!childEntity->getParentID().isNull()) {
|
||||
QWriteLocker locker(&_missingParentLock);
|
||||
_missingParent.append(childEntity);
|
||||
addToNeedsParentFixupList(childEntity);
|
||||
}
|
||||
|
||||
UpdateEntityOperator theChildOperator(getThisPointer(), containingElement, childEntity, queryCube);
|
||||
|
@ -384,8 +381,7 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
|||
AddEntityOperator theOperator(getThisPointer(), result);
|
||||
recurseTreeWithOperator(&theOperator);
|
||||
if (!result->getParentID().isNull()) {
|
||||
QWriteLocker locker(&_missingParentLock);
|
||||
_missingParent.append(result);
|
||||
addToNeedsParentFixupList(result);
|
||||
}
|
||||
|
||||
postAddEntity(result);
|
||||
|
@ -1207,11 +1203,13 @@ void EntityTree::entityChanged(EntityItemPointer entity) {
|
|||
}
|
||||
}
|
||||
|
||||
void EntityTree::fixupMissingParents() {
|
||||
|
||||
void EntityTree::fixupNeedsParentFixups() {
|
||||
MovingEntitiesOperator moveOperator(getThisPointer());
|
||||
|
||||
QWriteLocker locker(&_missingParentLock);
|
||||
QMutableVectorIterator<EntityItemWeakPointer> iter(_missingParent);
|
||||
QWriteLocker locker(&_needsParentFixupLock);
|
||||
|
||||
QMutableVectorIterator<EntityItemWeakPointer> iter(_needsParentFixup);
|
||||
while (iter.hasNext()) {
|
||||
EntityItemWeakPointer entityWP = iter.next();
|
||||
EntityItemPointer entity = entityWP.lock();
|
||||
|
@ -1283,8 +1281,13 @@ void EntityTree::deleteDescendantsOfAvatar(QUuid avatarID) {
|
|||
}
|
||||
}
|
||||
|
||||
void EntityTree::addToNeedsParentFixupList(EntityItemPointer entity) {
|
||||
QWriteLocker locker(&_needsParentFixupLock);
|
||||
_needsParentFixup.append(entity);
|
||||
}
|
||||
|
||||
void EntityTree::update() {
|
||||
fixupMissingParents();
|
||||
fixupNeedsParentFixups();
|
||||
if (_simulation) {
|
||||
withWriteLock([&] {
|
||||
_simulation->updateEntities();
|
||||
|
@ -1609,8 +1612,7 @@ QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSen
|
|||
EntityItemPointer entity = localTree->findEntityByEntityItemID(newID);
|
||||
if (entity) {
|
||||
if (!entity->getParentID().isNull()) {
|
||||
QWriteLocker locker(&_missingParentLock);
|
||||
_missingParent.append(entity);
|
||||
addToNeedsParentFixupList(entity);
|
||||
}
|
||||
entity->forceQueryAACubeUpdate();
|
||||
moveOperator.addEntityToMoveList(entity, entity->getQueryAACube());
|
||||
|
|
|
@ -271,6 +271,8 @@ public:
|
|||
void forgetAvatarID(QUuid avatarID) { _avatarIDs -= avatarID; }
|
||||
void deleteDescendantsOfAvatar(QUuid avatarID);
|
||||
|
||||
void addToNeedsParentFixupList(EntityItemPointer entity);
|
||||
|
||||
void notifyNewCollisionSoundURL(const QString& newCollisionSoundURL, const EntityItemID& entityID);
|
||||
|
||||
static const float DEFAULT_MAX_TMP_ENTITY_LIFETIME;
|
||||
|
@ -351,9 +353,9 @@ protected:
|
|||
quint64 _maxEditDelta = 0;
|
||||
quint64 _treeResetTime = 0;
|
||||
|
||||
void fixupMissingParents(); // try to hook members of _missingParent to parent instances
|
||||
QVector<EntityItemWeakPointer> _missingParent; // entites with a parentID but no (yet) known parent instance
|
||||
mutable QReadWriteLock _missingParentLock;
|
||||
void fixupNeedsParentFixups(); // try to hook members of _needsParentFixup to parent instances
|
||||
QVector<EntityItemWeakPointer> _needsParentFixup; // entites with a parentID but no (yet) known parent instance
|
||||
mutable QReadWriteLock _needsParentFixupLock;
|
||||
|
||||
// we maintain a list of avatarIDs to notice when an entity is a child of one.
|
||||
QSet<QUuid> _avatarIDs; // IDs of avatars connected to entity server
|
||||
|
|
|
@ -208,7 +208,7 @@ void EntityTreeElement::elementEncodeComplete(EncodeBitstreamParams& params) con
|
|||
|
||||
// why would this ever fail???
|
||||
// If we've encoding this element before... but we're coming back a second time in an attempt to
|
||||
// encoud our parent... this might happen.
|
||||
// encode our parent... this might happen.
|
||||
if (extraEncodeData->contains(childElement.get())) {
|
||||
EntityTreeElementExtraEncodeDataPointer childExtraEncodeData
|
||||
= std::static_pointer_cast<EntityTreeElementExtraEncodeData>((*extraEncodeData)[childElement.get()]);
|
||||
|
@ -981,6 +981,7 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
|||
// 3) remember the old cube for the entity so we can mark it as dirty
|
||||
if (entityItem) {
|
||||
QString entityScriptBefore = entityItem->getScript();
|
||||
QUuid parentIDBefore = entityItem->getParentID();
|
||||
QString entityServerScriptsBefore = entityItem->getServerScripts();
|
||||
quint64 entityScriptTimestampBefore = entityItem->getScriptTimestamp();
|
||||
bool bestFitBefore = bestFitEntityBounds(entityItem);
|
||||
|
@ -1018,6 +1019,11 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
|||
_myTree->emitEntityServerScriptChanging(entityItemID, reload); // the entity server script has changed
|
||||
}
|
||||
|
||||
QUuid parentIDAfter = entityItem->getParentID();
|
||||
if (parentIDBefore != parentIDAfter) {
|
||||
_myTree->addToNeedsParentFixupList(entityItem);
|
||||
}
|
||||
|
||||
} else {
|
||||
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
||||
if (entityItem) {
|
||||
|
|
Loading…
Reference in a new issue