From c0119867940847e0fbe2d2dbee1106c8ad291c83 Mon Sep 17 00:00:00 2001 From: Victor Lindquist Date: Wed, 15 Jun 2022 19:14:49 -0600 Subject: [PATCH] Added 'hasLoaded' bool in the syncable storage so that enabling properties in the renderable occurs at the correct time --- .../pointdatamessagehandler.cpp | 2 +- .../rendering/renderablepointscloud.cpp | 7 ++++++- .../softwareintegrationmodule.cpp | 11 ++++++++-- .../softwareintegrationmodule.h | 6 +++++- .../syncablefloatdatastorage.cpp | 20 ++++++++++++++----- .../syncablefloatdatastorage.h | 4 +++- 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/modules/softwareintegration/pointdatamessagehandler.cpp b/modules/softwareintegration/pointdatamessagehandler.cpp index 630ee18ad6..8c25f64857 100644 --- a/modules/softwareintegration/pointdatamessagehandler.cpp +++ b/modules/softwareintegration/pointdatamessagehandler.cpp @@ -855,7 +855,7 @@ void PointDataMessageHandler::postSync() { try { for (auto& waitFor : waitForData) { - if (softwareIntegrationModule->isSyncDataDirty(identifier, waitFor)) { + if (!softwareIntegrationModule->dataLoaded(identifier, waitFor)) { throw std::exception{}; } } diff --git a/modules/softwareintegration/rendering/renderablepointscloud.cpp b/modules/softwareintegration/rendering/renderablepointscloud.cpp index abc39e9135..42dc687a55 100644 --- a/modules/softwareintegration/rendering/renderablepointscloud.cpp +++ b/modules/softwareintegration/rendering/renderablepointscloud.cpp @@ -651,6 +651,7 @@ void RenderablePointsCloud::loadData(SoftwareIntegrationModule* softwareIntegrat addPosition(transformedPos); } + softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::DataPoints); } void RenderablePointsCloud::loadColormap(SoftwareIntegrationModule* softwareIntegrationModule) { @@ -678,6 +679,7 @@ void RenderablePointsCloud::loadColormap(SoftwareIntegrationModule* softwareInte _colormapTexture->uploadTexture(); _hasLoadedColormap = true; + softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::Colormap); } void RenderablePointsCloud::loadColormapAttributeData(SoftwareIntegrationModule* softwareIntegrationModule) { @@ -709,6 +711,7 @@ void RenderablePointsCloud::loadColormapAttributeData(SoftwareIntegrationModule* _hasLoadedColormapAttributeData = true; LDEBUG("Rerendering with colormap attribute data"); + softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::ColormapAttrData); } void RenderablePointsCloud::loadLinearSizeAttributeData(SoftwareIntegrationModule* softwareIntegrationModule) { @@ -739,7 +742,8 @@ void RenderablePointsCloud::loadLinearSizeAttributeData(SoftwareIntegrationModul } _hasLoadedLinearSizeAttributeData = true; - LDEBUG("Rerendering with linear size attribute data"); + LDEBUG("Rerendering with linear size attribute data"); + softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::LinearSizeAttrData); } void RenderablePointsCloud::loadVelocityData(SoftwareIntegrationModule* softwareIntegrationModule) { @@ -835,6 +839,7 @@ void RenderablePointsCloud::loadVelocityData(SoftwareIntegrationModule* software // ========================================= _hasLoadedVelocityData = true; + softwareIntegrationModule->setDataLoaded(_identifier.value(), storage::Key::VelocityData); LDEBUG("Rerendering with motion based on velocity data"); } diff --git a/modules/softwareintegration/softwareintegrationmodule.cpp b/modules/softwareintegration/softwareintegrationmodule.cpp index 898d96f5ba..f1baab073d 100644 --- a/modules/softwareintegration/softwareintegrationmodule.cpp +++ b/modules/softwareintegration/softwareintegrationmodule.cpp @@ -75,11 +75,18 @@ bool SoftwareIntegrationModule::isDataDirty( return _syncableFloatDataStorage.isDirty(identifier, key); } -bool SoftwareIntegrationModule::isSyncDataDirty( +void SoftwareIntegrationModule::setDataLoaded( + const SyncableFloatDataStorage::Identifier& identifier, + const storage::Key key +) { + _syncableFloatDataStorage.setLoaded(identifier, key); +} + +bool SoftwareIntegrationModule::dataLoaded( const SyncableFloatDataStorage::Identifier& identifier, const storage::Key key ) { - return _syncableFloatDataStorage.isSyncDirty(identifier, key); + return _syncableFloatDataStorage.hasLoaded(identifier, key); } void SoftwareIntegrationModule::internalInitialize(const ghoul::Dictionary&) { diff --git a/modules/softwareintegration/softwareintegrationmodule.h b/modules/softwareintegration/softwareintegrationmodule.h index 4af99bec07..3faae838fd 100644 --- a/modules/softwareintegration/softwareintegrationmodule.h +++ b/modules/softwareintegration/softwareintegrationmodule.h @@ -53,7 +53,11 @@ public: const SyncableFloatDataStorage::Identifier& identifier, const storage::Key key ); - bool isSyncDataDirty( + void setDataLoaded( + const SyncableFloatDataStorage::Identifier& identifier, + const storage::Key key + ); + bool dataLoaded( const SyncableFloatDataStorage::Identifier& identifier, const storage::Key key ); diff --git a/modules/softwareintegration/syncablefloatdatastorage.cpp b/modules/softwareintegration/syncablefloatdatastorage.cpp index 4b157eae27..de4504f054 100644 --- a/modules/softwareintegration/syncablefloatdatastorage.cpp +++ b/modules/softwareintegration/syncablefloatdatastorage.cpp @@ -173,14 +173,24 @@ bool SyncableFloatDataStorage::isDirty( return _storage.find(identifier)->second.find(key)->second.dirty; } -bool SyncableFloatDataStorage::isSyncDirty( - const Identifier& identifier, const storage::Key key -) { +void SyncableFloatDataStorage::setLoaded(const Identifier& identifier, const storage::Key key) { if (!count(identifier, key)) { - return true; + LERROR(fmt::format( + "SceneGraphNode {} has no data with key '{}' in the centralized data storage", + identifier, + storage::getStorageKeyString(key) + )); + return; + } + _storage.find(identifier)->second.find(key)->second.hasLoaded = true; +} + +bool SyncableFloatDataStorage::hasLoaded(const Identifier& identifier, const storage::Key key) { + if (!count(identifier, key)) { + return false; } - return _storage.find(identifier)->second.find(key)->second.syncDirty; + return _storage.find(identifier)->second.find(key)->second.hasLoaded; } void SyncableFloatDataStorage::store( diff --git a/modules/softwareintegration/syncablefloatdatastorage.h b/modules/softwareintegration/syncablefloatdatastorage.h index 4a9e69fa3e..b5f3dfa2d3 100644 --- a/modules/softwareintegration/syncablefloatdatastorage.h +++ b/modules/softwareintegration/syncablefloatdatastorage.h @@ -43,6 +43,7 @@ public: std::vector data; bool hasEncoded = false; bool syncDirty = true; + bool hasLoaded = false; bool dirty = true; }; using ValueData = decltype(Value::data); @@ -61,7 +62,8 @@ public: const ValueData& fetch(const Identifier& identifier, const storage::Key key); bool isDirty(const Identifier& identifier, const storage::Key key); - bool isSyncDirty(const Identifier& identifier, const storage::Key key); + void setLoaded(const Identifier& identifier, const storage::Key key); + bool hasLoaded(const Identifier& identifier, const storage::Key key); void store(const Identifier& identifier, const storage::Key key, const ValueData& data); std::string getStringOfAllKeysInStorage();