mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 00:36:30 +02:00
revert deadlock, remove Space stubbery in EntityTree
This commit is contained in:
parent
91f0134632
commit
6d347cf44f
13 changed files with 52 additions and 96 deletions
|
@ -13,7 +13,7 @@ setup_memory_debugger()
|
||||||
link_hifi_libraries(
|
link_hifi_libraries(
|
||||||
audio avatars octree gpu graphics fbx entities
|
audio avatars octree gpu graphics fbx entities
|
||||||
networking animation recording shared script-engine embedded-webserver
|
networking animation recording shared script-engine embedded-webserver
|
||||||
controllers physics plugins midi image workload
|
controllers physics plugins midi image
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(${TARGET_NAME} oven)
|
add_dependencies(${TARGET_NAME} oven)
|
||||||
|
|
|
@ -4477,6 +4477,8 @@ void Application::init() {
|
||||||
_physicsEngine->init();
|
_physicsEngine->init();
|
||||||
|
|
||||||
EntityTreePointer tree = getEntities()->getTree();
|
EntityTreePointer tree = getEntities()->getTree();
|
||||||
|
connect(tree.get(), &EntityTree::deletingEntity, this, &Application::deletingEntity, Qt::QueuedConnection);
|
||||||
|
connect(tree.get(), &EntityTree::addingEntity, this, &Application::addingEntity, Qt::QueuedConnection);
|
||||||
_entitySimulation->init(tree, _physicsEngine, &_entityEditSender);
|
_entitySimulation->init(tree, _physicsEngine, &_entityEditSender);
|
||||||
tree->setSimulation(_entitySimulation);
|
tree->setSimulation(_entitySimulation);
|
||||||
|
|
||||||
|
@ -7606,4 +7608,12 @@ void Application::saveNextPhysicsStats(QString filename) {
|
||||||
_physicsEngine->saveNextPhysicsStats(filename);
|
_physicsEngine->saveNextPhysicsStats(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::addingEntity(const EntityItemID& entityID) {
|
||||||
|
// TODO: Andrew to implement this
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::deletingEntity(const EntityItemID& entityID) {
|
||||||
|
// TODO: Andrew to implement this
|
||||||
|
}
|
||||||
|
|
||||||
#include "Application.moc"
|
#include "Application.moc"
|
||||||
|
|
|
@ -391,6 +391,9 @@ public slots:
|
||||||
const QString getPreferredCursor() const { return _preferredCursor.get(); }
|
const QString getPreferredCursor() const { return _preferredCursor.get(); }
|
||||||
void setPreferredCursor(const QString& cursor);
|
void setPreferredCursor(const QString& cursor);
|
||||||
|
|
||||||
|
void addingEntity(const EntityItemID& entityID);
|
||||||
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDesktopRootItemCreated(QQuickItem* qmlContext);
|
void onDesktopRootItemCreated(QQuickItem* qmlContext);
|
||||||
void onDesktopRootContextCreated(QQmlContext* qmlContext);
|
void onDesktopRootContextCreated(QQmlContext* qmlContext);
|
||||||
|
|
|
@ -14,6 +14,5 @@ include_hifi_library_headers(audio)
|
||||||
include_hifi_library_headers(entities)
|
include_hifi_library_headers(entities)
|
||||||
include_hifi_library_headers(octree)
|
include_hifi_library_headers(octree)
|
||||||
include_hifi_library_headers(task)
|
include_hifi_library_headers(task)
|
||||||
include_hifi_library_headers(workload)
|
|
||||||
|
|
||||||
target_bullet()
|
target_bullet()
|
||||||
|
|
|
@ -14,7 +14,6 @@ include_hifi_library_headers(entities)
|
||||||
include_hifi_library_headers(avatars)
|
include_hifi_library_headers(avatars)
|
||||||
include_hifi_library_headers(controllers)
|
include_hifi_library_headers(controllers)
|
||||||
include_hifi_library_headers(task)
|
include_hifi_library_headers(task)
|
||||||
include_hifi_library_headers(workload)
|
|
||||||
|
|
||||||
target_bullet()
|
target_bullet()
|
||||||
target_polyvox()
|
target_polyvox()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(TARGET_NAME entities)
|
set(TARGET_NAME entities)
|
||||||
setup_hifi_library(Network Script)
|
setup_hifi_library(Network Script)
|
||||||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||||
link_hifi_libraries(shared workload networking octree avatars graphics)
|
link_hifi_libraries(shared networking octree avatars graphics)
|
||||||
|
|
|
@ -2365,15 +2365,14 @@ QList<EntityDynamicPointer> EntityItem::getActionsOfType(EntityDynamicType typeT
|
||||||
|
|
||||||
void EntityItem::locationChanged(bool tellPhysics) {
|
void EntityItem::locationChanged(bool tellPhysics) {
|
||||||
requiresRecalcBoxes();
|
requiresRecalcBoxes();
|
||||||
EntityTreePointer tree = getTree();
|
if (tellPhysics) {
|
||||||
if (tree) {
|
_flags |= Simulation::DIRTY_TRANSFORM;
|
||||||
if (tellPhysics) {
|
EntityTreePointer tree = getTree();
|
||||||
_flags |= Simulation::DIRTY_TRANSFORM;
|
if (tree) {
|
||||||
tree->entityChanged(getThisPointer());
|
tree->entityChanged(getThisPointer());
|
||||||
}
|
}
|
||||||
glm::vec4 sphere(getWorldPosition(), 0.5f * glm::length(getScaledDimensions()));
|
|
||||||
tree->queueUpdateSpaceProxy(_spaceIndex, sphere);
|
|
||||||
}
|
}
|
||||||
|
// TODO: Andrew to connect this to the Space instance in Application
|
||||||
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
||||||
somethingChangedNotification();
|
somethingChangedNotification();
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,49 +560,37 @@ void EntityTree::setSimulation(EntitySimulationPointer simulation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ignoreWarnings) {
|
void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ignoreWarnings) {
|
||||||
EntityItemPointer entity;
|
EntityTreeElementPointer containingElement = getContainingElement(entityID);
|
||||||
{
|
if (!containingElement) {
|
||||||
QReadLocker locker(&_entityMapLock);
|
|
||||||
entity = _entityMap.value(entityID);
|
|
||||||
}
|
|
||||||
if (!entity) {
|
|
||||||
if (!ignoreWarnings) {
|
if (!ignoreWarnings) {
|
||||||
qCWarning(entities) << "EntityTree::deleteEntity() on unknown entityID=" << entityID;
|
qCWarning(entities) << "EntityTree::deleteEntity() on non-existent entityID=" << entityID;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity->getLocked() && !force) {
|
|
||||||
|
EntityItemPointer existingEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||||
|
if (!existingEntity) {
|
||||||
|
if (!ignoreWarnings) {
|
||||||
|
qCWarning(entities) << "EntityTree::deleteEntity() on non-existant entity item with entityID=" << entityID;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingEntity->getLocked() && !force) {
|
||||||
if (!ignoreWarnings) {
|
if (!ignoreWarnings) {
|
||||||
qCDebug(entities) << "ERROR! EntityTree::deleteEntity() trying to delete locked entity. entityID=" << entityID;
|
qCDebug(entities) << "ERROR! EntityTree::deleteEntity() trying to delete locked entity. entityID=" << entityID;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreWarnings) {
|
|
||||||
if (!entity->getElement()) {
|
|
||||||
qCWarning(entities) << "EntityTree::deleteEntity() found entity with entityID=" << entityID
|
|
||||||
<< " in map but it doesn't know its containing element";
|
|
||||||
} else {
|
|
||||||
// check for element mismatch
|
|
||||||
EntityItemPointer otherEntity = entity->getElement()->getEntityWithEntityItemID(entityID);
|
|
||||||
if (!otherEntity) {
|
|
||||||
qCWarning(entities) << "EntityTree::deleteEntity() on entity with entityID=" << entityID
|
|
||||||
<< " but the containing element of record cannot find it";
|
|
||||||
} else if (otherEntity != entity) {
|
|
||||||
qCWarning(entities) << "EntityTree::deleteEntity() on entity with entityID=" << entityID
|
|
||||||
<< " but the containing element of record found a different entity";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unhookChildAvatar(entityID);
|
unhookChildAvatar(entityID);
|
||||||
emit deletingEntity(entityID);
|
emit deletingEntity(entityID);
|
||||||
emit deletingEntityPointer(entity.get());
|
emit deletingEntityPointer(existingEntity.get());
|
||||||
|
|
||||||
// NOTE: callers must lock the tree before using this method
|
// NOTE: callers must lock the tree before using this method
|
||||||
DeleteEntityOperator theOperator(getThisPointer(), entityID);
|
DeleteEntityOperator theOperator(getThisPointer(), entityID);
|
||||||
|
|
||||||
entity->forEachDescendant([&](SpatiallyNestablePointer descendant) {
|
existingEntity->forEachDescendant([&](SpatiallyNestablePointer descendant) {
|
||||||
auto descendantID = descendant->getID();
|
auto descendantID = descendant->getID();
|
||||||
theOperator.addEntityIDToDeleteList(descendantID);
|
theOperator.addEntityIDToDeleteList(descendantID);
|
||||||
emit deletingEntity(descendantID);
|
emit deletingEntity(descendantID);
|
||||||
|
@ -632,46 +620,34 @@ void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs, bool force, bool i
|
||||||
// NOTE: callers must lock the tree before using this method
|
// NOTE: callers must lock the tree before using this method
|
||||||
DeleteEntityOperator theOperator(getThisPointer());
|
DeleteEntityOperator theOperator(getThisPointer());
|
||||||
foreach(const EntityItemID& entityID, entityIDs) {
|
foreach(const EntityItemID& entityID, entityIDs) {
|
||||||
EntityItemPointer entity;
|
EntityTreeElementPointer containingElement = getContainingElement(entityID);
|
||||||
{
|
if (!containingElement) {
|
||||||
QReadLocker locker(&_entityMapLock);
|
|
||||||
entity = _entityMap.value(entityID);
|
|
||||||
}
|
|
||||||
if (!entity) {
|
|
||||||
if (!ignoreWarnings) {
|
if (!ignoreWarnings) {
|
||||||
qCWarning(entities) << "EntityTree::deleteEntities() on unknown entityID=" << entityID;
|
qCWarning(entities) << "EntityTree::deleteEntities() on non-existent entityID=" << entityID;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (entity->getLocked() && !force) {
|
|
||||||
|
EntityItemPointer existingEntity = containingElement->getEntityWithEntityItemID(entityID);
|
||||||
|
if (!existingEntity) {
|
||||||
|
if (!ignoreWarnings) {
|
||||||
|
qCWarning(entities) << "EntityTree::deleteEntities() on non-existent entity item with entityID=" << entityID;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingEntity->getLocked() && !force) {
|
||||||
if (!ignoreWarnings) {
|
if (!ignoreWarnings) {
|
||||||
qCDebug(entities) << "ERROR! EntityTree::deleteEntities() trying to delete locked entity. entityID=" << entityID;
|
qCDebug(entities) << "ERROR! EntityTree::deleteEntities() trying to delete locked entity. entityID=" << entityID;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreWarnings) {
|
|
||||||
if (!entity->getElement()) {
|
|
||||||
qCWarning(entities) << "EntityTree::deleteEntities() found entity with entityID=" << entityID
|
|
||||||
<< " in map but it doesn't know its containing element";
|
|
||||||
} else {
|
|
||||||
// check for element mismatch
|
|
||||||
EntityItemPointer otherEntity = entity->getElement()->getEntityWithEntityItemID(entityID);
|
|
||||||
if (!otherEntity) {
|
|
||||||
qCWarning(entities) << "EntityTree::deleteEntities() on entity with entityID=" << entityID
|
|
||||||
<< " but the containing element of record cannot find it";
|
|
||||||
} else if (otherEntity != entity) {
|
|
||||||
qCWarning(entities) << "EntityTree::deleteEntities() on entity with entityID=" << entityID
|
|
||||||
<< " but the containing element of record found a different entity";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// tell our delete operator about this entityID
|
// tell our delete operator about this entityID
|
||||||
unhookChildAvatar(entityID);
|
unhookChildAvatar(entityID);
|
||||||
theOperator.addEntityIDToDeleteList(entityID);
|
theOperator.addEntityIDToDeleteList(entityID);
|
||||||
emit deletingEntity(entityID);
|
emit deletingEntity(entityID);
|
||||||
emit deletingEntityPointer(entity.get());
|
emit deletingEntityPointer(existingEntity.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theOperator.getEntities().size() > 0) {
|
if (theOperator.getEntities().size() > 0) {
|
||||||
|
@ -1233,10 +1209,6 @@ bool EntityTree::verifyNonce(const QString& certID, const QString& nonce, Entity
|
||||||
return verificationSuccess;
|
return verificationSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::queueUpdateSpaceProxy(int32_t index, const glm::vec4& sphere) {
|
|
||||||
_spaceUpdates.push_back(std::pair<int32_t, glm::vec4>(index, sphere));
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityTree::processChallengeOwnershipRequestPacket(ReceivedMessage& message, const SharedNodePointer& sourceNode) {
|
void EntityTree::processChallengeOwnershipRequestPacket(ReceivedMessage& message, const SharedNodePointer& sourceNode) {
|
||||||
int certIDByteArraySize;
|
int certIDByteArraySize;
|
||||||
int textByteArraySize;
|
int textByteArraySize;
|
||||||
|
@ -1838,12 +1810,6 @@ void EntityTree::update(bool simulate) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// process Space queues
|
|
||||||
_space.deleteProxies(_spaceDeletes);
|
|
||||||
_spaceDeletes.clear();
|
|
||||||
_space.updateProxies(_spaceUpdates);
|
|
||||||
_spaceUpdates.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 EntityTree::getAdjustedConsiderSince(quint64 sinceTime) {
|
quint64 EntityTree::getAdjustedConsiderSince(quint64 sinceTime) {
|
||||||
|
@ -2013,25 +1979,11 @@ void EntityTree::addEntityMapEntry(EntityItemPointer entity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_entityMap.insert(id, entity);
|
_entityMap.insert(id, entity);
|
||||||
|
|
||||||
// create a proxy for the entity in the workload/Space container
|
|
||||||
glm::vec4 sphere(entity->getWorldPosition(), 0.5f * glm::length(entity->getScaledDimensions()));
|
|
||||||
int32_t spaceIndex = _space.createProxy(sphere);
|
|
||||||
entity->setSpaceIndex(spaceIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::clearEntityMapEntry(const EntityItemID& id) {
|
void EntityTree::clearEntityMapEntry(const EntityItemID& id) {
|
||||||
// this method only called by DeleteEntityOperator
|
|
||||||
QWriteLocker locker(&_entityMapLock);
|
QWriteLocker locker(&_entityMapLock);
|
||||||
QHash<EntityItemID, EntityItemPointer>::iterator itr = _entityMap.find(id);
|
_entityMap.remove(id);
|
||||||
if (itr != _entityMap.end()) {
|
|
||||||
// queue delete from _space BEFORE removing from map
|
|
||||||
int32_t spaceIndex = itr.value()->getSpaceIndex();
|
|
||||||
assert(spaceIndex != -1);
|
|
||||||
_spaceDeletes.push_back(spaceIndex);
|
|
||||||
|
|
||||||
_entityMap.erase(itr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::debugDumpMap() {
|
void EntityTree::debugDumpMap() {
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include <Octree.h>
|
#include <Octree.h>
|
||||||
#include <SpatialParentFinder.h>
|
#include <SpatialParentFinder.h>
|
||||||
#include <workload/Space.h>
|
|
||||||
|
|
||||||
class EntityTree;
|
class EntityTree;
|
||||||
using EntityTreePointer = std::shared_ptr<EntityTree>;
|
using EntityTreePointer = std::shared_ptr<EntityTree>;
|
||||||
|
@ -390,9 +389,6 @@ private:
|
||||||
void validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation);
|
void validatePop(const QString& certID, const EntityItemID& entityItemID, const SharedNodePointer& senderNode, bool isRetryingValidation);
|
||||||
|
|
||||||
std::shared_ptr<AvatarData> _myAvatar{ nullptr };
|
std::shared_ptr<AvatarData> _myAvatar{ nullptr };
|
||||||
workload::Space _space;
|
|
||||||
std::vector< std::pair<int32_t, glm::vec4> > _spaceUpdates;
|
|
||||||
std::vector< int32_t > _spaceDeletes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_EntityTree_h
|
#endif // hifi_EntityTree_h
|
||||||
|
|
|
@ -7,6 +7,5 @@ include_hifi_library_headers(avatars)
|
||||||
include_hifi_library_headers(audio)
|
include_hifi_library_headers(audio)
|
||||||
include_hifi_library_headers(octree)
|
include_hifi_library_headers(octree)
|
||||||
include_hifi_library_headers(animation)
|
include_hifi_library_headers(animation)
|
||||||
include_hifi_library_headers(workload)
|
|
||||||
|
|
||||||
target_bullet()
|
target_bullet()
|
||||||
|
|
|
@ -20,4 +20,3 @@ endif ()
|
||||||
link_hifi_libraries(shared networking octree gpu procedural graphics model-networking ktx recording avatars fbx entities controllers animation audio physics image midi)
|
link_hifi_libraries(shared networking octree gpu procedural graphics model-networking ktx recording avatars fbx entities controllers animation audio physics image midi)
|
||||||
# ui includes gl, but link_hifi_libraries does not use transitive includes, so gl must be explicit
|
# ui includes gl, but link_hifi_libraries does not use transitive includes, so gl must be explicit
|
||||||
include_hifi_library_headers(gl)
|
include_hifi_library_headers(gl)
|
||||||
include_hifi_library_headers(workload)
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ setup_memory_debugger()
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||||
|
|
||||||
# link in the shared libraries
|
# link in the shared libraries
|
||||||
link_hifi_libraries(entities avatars shared workload octree gpu graphics fbx networking animation audio gl)
|
link_hifi_libraries(entities avatars shared octree gpu graphics fbx networking animation audio gl)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_dependency_external_projects(wasapi)
|
add_dependency_external_projects(wasapi)
|
||||||
|
|
|
@ -18,7 +18,7 @@ link_hifi_libraries(
|
||||||
render render-utils
|
render render-utils
|
||||||
graphics fbx model-networking
|
graphics fbx model-networking
|
||||||
entities entities-renderer audio avatars script-engine
|
entities entities-renderer audio avatars script-engine
|
||||||
physics procedural midi qml ui workload
|
physics procedural midi qml ui
|
||||||
${PLATFORM_GL_BACKEND}
|
${PLATFORM_GL_BACKEND}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue