3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 20:55:24 +02:00

Merging with the actual worloadspace managed from the EntityTreeRenderer

This commit is contained in:
samcake 2018-02-21 10:34:58 -08:00
parent 34db56c50c
commit 33b47f9ae2
6 changed files with 18 additions and 8 deletions
interface/src
libraries
entities-renderer/src
workload/src/workload

View file

@ -2400,7 +2400,7 @@ void Application::initializeGL() {
DependencyManager::get<GeometryCache>()->initializeShapePipelines();
});
_gameWorkload.startup(_workloadSpace, _main3DScene);
_gameWorkload.startup(getEntities()->getWorkloadSpace(), _main3DScene);
_offscreenContext = new OffscreenGLCanvas();
_offscreenContext->setObjectName("MainThreadContext");

View file

@ -616,7 +616,6 @@ private:
gpu::ContextPointer _gpuContext; // initialized during window creation
GameWorkload _gameWorkload;
workload::SpacePointer _workloadSpace{ new workload::Space() };
mutable QMutex _renderArgsMutex{ QMutex::Recursive };
struct AppRenderArgs {

View file

@ -30,17 +30,23 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
auto renderItem = std::make_shared<GameWorkloadRenderItem>();
renderItem->editBound().expandedContains(glm::vec3(0.0), 32000.0);
transaction.resetItem(_spaceRenderItemID, std::make_shared<GameWorkloadRenderItem::Payload>(std::make_shared<GameWorkloadRenderItem>()));
scene->enqueueTransaction(transaction);
}
scene->enqueueTransaction(transaction);
auto space = gameWorkloadContext->_space;
if (!space) {
return;
}
space->getNumObjects();
std::vector<workload::Space::Proxy> proxies(space->getNumAllocatedProxies());
space->copyProxyValues(proxies.data(), proxies.size());
transaction.updateItem<GameWorkloadRenderItem>(_spaceRenderItemID, [proxies](GameWorkloadRenderItem& item) {
item.setAllProxies(proxies);
});
scene->enqueueTransaction(transaction);
}
namespace render {

View file

@ -281,7 +281,7 @@ void EntityTreeRenderer::addPendingEntities(const render::ScenePointer& scene, r
if (entity->getSpaceIndex() == -1) {
std::unique_lock<std::mutex> lock(_spaceLock);
workload::Space::Sphere sphere(entity->getWorldPosition(), entity->getBoundingRadius());
int32_t spaceIndex = _space.createProxy(sphere);
int32_t spaceIndex = _space->createProxy(sphere);
entity->setSpaceIndex(spaceIndex);
connect(entity.get(), &EntityItem::spaceUpdate, this, &EntityTreeRenderer::handleSpaceUpdate, Qt::QueuedConnection);
}
@ -428,7 +428,7 @@ void EntityTreeRenderer::update(bool simulate) {
}
{ // update proxies in the workload::Space
std::unique_lock<std::mutex> lock(_spaceLock);
_space.updateProxies(_spaceUpdates);
_space->updateProxies(_spaceUpdates);
_spaceUpdates.clear();
}
{ // flush final EntityTree references to removed entities
@ -442,7 +442,7 @@ void EntityTreeRenderer::update(bool simulate) {
disconnect(entity.get(), &EntityItem::spaceUpdate, this, &EntityTreeRenderer::handleSpaceUpdate);
deadProxies.push_back(spaceIndex);
}
_space.deleteProxies(deadProxies);
_space->deleteProxies(deadProxies);
}
}

View file

@ -120,6 +120,9 @@ public:
static void setRenderDebugHullsOperator(std::function<bool()> renderDebugHullsOperator) { _renderDebugHullsOperator = renderDebugHullsOperator; }
static bool shouldRenderDebugHulls() { return _renderDebugHullsOperator(); }
// Access the workload Space
const workload::SpacePointer getWorkloadSpace() const { return _space; }
signals:
void enterEntity(const EntityItemID& entityItemID);
void leaveEntity(const EntityItemID& entityItemID);
@ -266,7 +269,7 @@ private:
static std::function<bool()> _renderDebugHullsOperator;
mutable std::mutex _spaceLock;
workload::Space _space;
workload::SpacePointer _space{ new workload::Space() };
std::vector<workload::Space::ProxyUpdate> _spaceUpdates;
};

View file

@ -35,6 +35,7 @@ public:
class Proxy {
public:
Proxy() : sphere(0.0f) {}
Proxy(const Sphere& s) : sphere(s) {}
Sphere sphere;
uint8_t region { REGION_UNKNOWN };
@ -68,6 +69,7 @@ public:
void setViews(const std::vector<View>& views);
uint32_t getNumObjects() const { return (uint32_t)(_proxies.size() - _freeIndices.size()); }
uint32_t getNumAllocatedProxies() const { return (uint32_t)(_proxies.size()); }
void categorizeAndGetChanges(std::vector<Change>& changes);