mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 16:43:33 +02:00
Merge branch 'workload' of https://github.com/highfidelity/hifi into workload
This commit is contained in:
commit
6e7ef1e609
6 changed files with 21 additions and 23 deletions
|
@ -35,10 +35,6 @@ void EntityTreeHeadlessViewer::update() {
|
|||
EntityTreePointer tree = std::static_pointer_cast<EntityTree>(_tree);
|
||||
tree->withTryWriteLock([&] {
|
||||
tree->update();
|
||||
|
||||
// flush final EntityTree references to deleted entities
|
||||
std::vector<EntityItemPointer> deletedEntities;
|
||||
tree->swapRemovedEntities(deletedEntities);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,6 +194,7 @@ void EntityTreeRenderer::clear() {
|
|||
}
|
||||
|
||||
// remove all entities from the scene
|
||||
_space->clear();
|
||||
auto scene = _viewState->getMain3DScene();
|
||||
if (scene) {
|
||||
render::Transaction transaction;
|
||||
|
@ -431,18 +432,12 @@ void EntityTreeRenderer::update(bool simulate) {
|
|||
_space->updateProxies(_spaceUpdates);
|
||||
_spaceUpdates.clear();
|
||||
}
|
||||
{ // flush final EntityTree references to removed entities
|
||||
std::vector<EntityItemPointer> deletedEntities;
|
||||
tree->swapRemovedEntities(deletedEntities);
|
||||
{ // delete proxies from workload::Space
|
||||
std::vector<int32_t> deadProxies;
|
||||
{
|
||||
std::vector<int32_t> staleProxies;
|
||||
tree->swapStaleProxies(staleProxies);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(_spaceLock);
|
||||
for (auto entity : deletedEntities) {
|
||||
int32_t spaceIndex = entity->getSpaceIndex();
|
||||
disconnect(entity.get(), &EntityItem::spaceUpdate, this, &EntityTreeRenderer::handleSpaceUpdate);
|
||||
deadProxies.push_back(spaceIndex);
|
||||
}
|
||||
_space->deleteProxies(deadProxies);
|
||||
_space->deleteProxies(staleProxies);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ void EntityTree::eraseAllOctreeElements(bool createNewRoot) {
|
|||
if (_simulation) {
|
||||
_simulation->clearEntities();
|
||||
}
|
||||
_staleProxies.clear();
|
||||
QHash<EntityItemID, EntityItemPointer> localMap;
|
||||
localMap.swap(_entityMap);
|
||||
this->withWriteLock([&] {
|
||||
|
@ -697,10 +698,11 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator)
|
|||
_simulation->prepareEntityForDelete(theEntity);
|
||||
}
|
||||
|
||||
// We save a pointer to theEntity for external contexts that need it
|
||||
// but this means: external contexts that remove entities from the tree
|
||||
// must occasionally swapRemovedEntities() to flush these references.
|
||||
_removedEntities.push_back(theEntity);
|
||||
// keep a record of valid stale spaceIndices so they can be removed from the Space
|
||||
int32_t spaceIndex = theEntity->getSpaceIndex();
|
||||
if (spaceIndex != -1) {
|
||||
_staleProxies.push_back(spaceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2476,4 +2478,4 @@ bool EntityTree::removeMaterialFromOverlay(const QUuid& overlayID, graphics::Mat
|
|||
return _removeMaterialFromOverlayOperator(overlayID, material, parentMaterialName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ public:
|
|||
|
||||
void setMyAvatar(std::shared_ptr<AvatarData> myAvatar) { _myAvatar = myAvatar; }
|
||||
|
||||
void swapRemovedEntities(std::vector<EntityItemPointer>& entities) { entities.swap(_removedEntities); }
|
||||
void swapStaleProxies(std::vector<int>& proxies) { proxies.swap(_staleProxies); }
|
||||
|
||||
static void setAddMaterialToEntityOperator(std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> addMaterialToEntityOperator) { _addMaterialToEntityOperator = addMaterialToEntityOperator; }
|
||||
static void setRemoveMaterialFromEntityOperator(std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> removeMaterialFromEntityOperator) { _removeMaterialFromEntityOperator = removeMaterialFromEntityOperator; }
|
||||
|
@ -415,7 +415,7 @@ private:
|
|||
static std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> _addMaterialToOverlayOperator;
|
||||
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromOverlayOperator;
|
||||
|
||||
std::vector<EntityItemPointer> _removedEntities;
|
||||
std::vector<int32_t> _staleProxies;
|
||||
};
|
||||
|
||||
#endif // hifi_EntityTree_h
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
using namespace workload;
|
||||
|
||||
void Space::clear() {
|
||||
_proxies.clear();
|
||||
_freeIndices.clear();
|
||||
}
|
||||
|
||||
int32_t Space::createProxy(const Space::Sphere& newSphere) {
|
||||
if (_freeIndices.empty()) {
|
||||
_proxies.emplace_back(Space::Proxy(newSphere));
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
|
||||
Space() {}
|
||||
|
||||
void clear();
|
||||
int32_t createProxy(const Sphere& sphere);
|
||||
void deleteProxies(const std::vector<int32_t>& deadIndices);
|
||||
void updateProxies(const std::vector<ProxyUpdate>& changedProxies);
|
||||
|
@ -79,7 +80,6 @@ public:
|
|||
uint32_t getNumAllocatedProxies() const { return (uint32_t)(_proxies.size()); }
|
||||
|
||||
void categorizeAndGetChanges(std::vector<Change>& changes);
|
||||
|
||||
uint32_t copyProxyValues(Proxy* proxies, uint32_t numDestProxies);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue