mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 14:52:46 +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()) {
|
if (!entity->getParentID().isNull()) {
|
||||||
QWriteLocker locker(&_missingParentLock);
|
addToNeedsParentFixupList(entity);
|
||||||
_missingParent.append(entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_isDirty = true;
|
_isDirty = true;
|
||||||
emit addingEntity(entity->getEntityItemID());
|
emit addingEntity(entity->getEntityItemID());
|
||||||
|
|
||||||
// find and hook up any entities with this entity as a (previously) missing parent
|
// 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) {
|
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;
|
bool success;
|
||||||
AACube queryCube = childEntity->getQueryAACube(success);
|
AACube queryCube = childEntity->getQueryAACube(success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
QWriteLocker locker(&_missingParentLock);
|
addToNeedsParentFixupList(childEntity);
|
||||||
_missingParent.append(childEntity);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!childEntity->getParentID().isNull()) {
|
if (!childEntity->getParentID().isNull()) {
|
||||||
QWriteLocker locker(&_missingParentLock);
|
addToNeedsParentFixupList(childEntity);
|
||||||
_missingParent.append(childEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateEntityOperator theChildOperator(getThisPointer(), containingElement, childEntity, queryCube);
|
UpdateEntityOperator theChildOperator(getThisPointer(), containingElement, childEntity, queryCube);
|
||||||
|
@ -384,8 +381,7 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
||||||
AddEntityOperator theOperator(getThisPointer(), result);
|
AddEntityOperator theOperator(getThisPointer(), result);
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
if (!result->getParentID().isNull()) {
|
if (!result->getParentID().isNull()) {
|
||||||
QWriteLocker locker(&_missingParentLock);
|
addToNeedsParentFixupList(result);
|
||||||
_missingParent.append(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postAddEntity(result);
|
postAddEntity(result);
|
||||||
|
@ -1207,11 +1203,13 @@ void EntityTree::entityChanged(EntityItemPointer entity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::fixupMissingParents() {
|
|
||||||
|
void EntityTree::fixupNeedsParentFixups() {
|
||||||
MovingEntitiesOperator moveOperator(getThisPointer());
|
MovingEntitiesOperator moveOperator(getThisPointer());
|
||||||
|
|
||||||
QWriteLocker locker(&_missingParentLock);
|
QWriteLocker locker(&_needsParentFixupLock);
|
||||||
QMutableVectorIterator<EntityItemWeakPointer> iter(_missingParent);
|
|
||||||
|
QMutableVectorIterator<EntityItemWeakPointer> iter(_needsParentFixup);
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
EntityItemWeakPointer entityWP = iter.next();
|
EntityItemWeakPointer entityWP = iter.next();
|
||||||
EntityItemPointer entity = entityWP.lock();
|
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() {
|
void EntityTree::update() {
|
||||||
fixupMissingParents();
|
fixupNeedsParentFixups();
|
||||||
if (_simulation) {
|
if (_simulation) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_simulation->updateEntities();
|
_simulation->updateEntities();
|
||||||
|
@ -1609,8 +1612,7 @@ QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSen
|
||||||
EntityItemPointer entity = localTree->findEntityByEntityItemID(newID);
|
EntityItemPointer entity = localTree->findEntityByEntityItemID(newID);
|
||||||
if (entity) {
|
if (entity) {
|
||||||
if (!entity->getParentID().isNull()) {
|
if (!entity->getParentID().isNull()) {
|
||||||
QWriteLocker locker(&_missingParentLock);
|
addToNeedsParentFixupList(entity);
|
||||||
_missingParent.append(entity);
|
|
||||||
}
|
}
|
||||||
entity->forceQueryAACubeUpdate();
|
entity->forceQueryAACubeUpdate();
|
||||||
moveOperator.addEntityToMoveList(entity, entity->getQueryAACube());
|
moveOperator.addEntityToMoveList(entity, entity->getQueryAACube());
|
||||||
|
|
|
@ -271,6 +271,8 @@ public:
|
||||||
void forgetAvatarID(QUuid avatarID) { _avatarIDs -= avatarID; }
|
void forgetAvatarID(QUuid avatarID) { _avatarIDs -= avatarID; }
|
||||||
void deleteDescendantsOfAvatar(QUuid avatarID);
|
void deleteDescendantsOfAvatar(QUuid avatarID);
|
||||||
|
|
||||||
|
void addToNeedsParentFixupList(EntityItemPointer entity);
|
||||||
|
|
||||||
void notifyNewCollisionSoundURL(const QString& newCollisionSoundURL, const EntityItemID& entityID);
|
void notifyNewCollisionSoundURL(const QString& newCollisionSoundURL, const EntityItemID& entityID);
|
||||||
|
|
||||||
static const float DEFAULT_MAX_TMP_ENTITY_LIFETIME;
|
static const float DEFAULT_MAX_TMP_ENTITY_LIFETIME;
|
||||||
|
@ -351,9 +353,9 @@ protected:
|
||||||
quint64 _maxEditDelta = 0;
|
quint64 _maxEditDelta = 0;
|
||||||
quint64 _treeResetTime = 0;
|
quint64 _treeResetTime = 0;
|
||||||
|
|
||||||
void fixupMissingParents(); // try to hook members of _missingParent to parent instances
|
void fixupNeedsParentFixups(); // try to hook members of _needsParentFixup to parent instances
|
||||||
QVector<EntityItemWeakPointer> _missingParent; // entites with a parentID but no (yet) known parent instance
|
QVector<EntityItemWeakPointer> _needsParentFixup; // entites with a parentID but no (yet) known parent instance
|
||||||
mutable QReadWriteLock _missingParentLock;
|
mutable QReadWriteLock _needsParentFixupLock;
|
||||||
|
|
||||||
// we maintain a list of avatarIDs to notice when an entity is a child of one.
|
// 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
|
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???
|
// why would this ever fail???
|
||||||
// If we've encoding this element before... but we're coming back a second time in an attempt to
|
// 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())) {
|
if (extraEncodeData->contains(childElement.get())) {
|
||||||
EntityTreeElementExtraEncodeDataPointer childExtraEncodeData
|
EntityTreeElementExtraEncodeDataPointer childExtraEncodeData
|
||||||
= std::static_pointer_cast<EntityTreeElementExtraEncodeData>((*extraEncodeData)[childElement.get()]);
|
= 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
|
// 3) remember the old cube for the entity so we can mark it as dirty
|
||||||
if (entityItem) {
|
if (entityItem) {
|
||||||
QString entityScriptBefore = entityItem->getScript();
|
QString entityScriptBefore = entityItem->getScript();
|
||||||
|
QUuid parentIDBefore = entityItem->getParentID();
|
||||||
QString entityServerScriptsBefore = entityItem->getServerScripts();
|
QString entityServerScriptsBefore = entityItem->getServerScripts();
|
||||||
quint64 entityScriptTimestampBefore = entityItem->getScriptTimestamp();
|
quint64 entityScriptTimestampBefore = entityItem->getScriptTimestamp();
|
||||||
bool bestFitBefore = bestFitEntityBounds(entityItem);
|
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
|
_myTree->emitEntityServerScriptChanging(entityItemID, reload); // the entity server script has changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUuid parentIDAfter = entityItem->getParentID();
|
||||||
|
if (parentIDBefore != parentIDAfter) {
|
||||||
|
_myTree->addToNeedsParentFixupList(entityItem);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
||||||
if (entityItem) {
|
if (entityItem) {
|
||||||
|
|
Loading…
Reference in a new issue