From e18f106084ed4dc5a7cab39b5d48e73e0e5aa9ec Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Mon, 8 Feb 2021 09:31:24 +0100 Subject: [PATCH] Fix for handling nan values in data --- .../rendering/renderablepointscloud.cpp | 5 +++-- .../softwareintegration/softwareintegrationmodule.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/softwareintegration/rendering/renderablepointscloud.cpp b/modules/softwareintegration/rendering/renderablepointscloud.cpp index 3aa4d51db2..62b09d62ff 100644 --- a/modules/softwareintegration/rendering/renderablepointscloud.cpp +++ b/modules/softwareintegration/rendering/renderablepointscloud.cpp @@ -123,7 +123,8 @@ RenderablePointsCloud::RenderablePointsCloud(const ghoul::Dictionary& dictionary ghoul::Dictionary d = dictionary.value(DataInfo.identifier); for (int i = 0; i < static_cast(d.size()); ++i) { - _pointData.push_back(d.value(std::to_string(i + 1))); + const std::string key = std::to_string(i + 1); + _pointData.push_back(d.value(key)); } addProperty(_opacity); @@ -287,7 +288,7 @@ void RenderablePointsCloud::createDataSlice() { void RenderablePointsCloud::loadData() { if (_pointData.empty()) { - LERROR("No point data found"); + LWARNING("No point data found"); return; } diff --git a/modules/softwareintegration/softwareintegrationmodule.cpp b/modules/softwareintegration/softwareintegrationmodule.cpp index 089db490c0..b97432f41f 100644 --- a/modules/softwareintegration/softwareintegrationmodule.cpp +++ b/modules/softwareintegration/softwareintegrationmodule.cpp @@ -252,9 +252,17 @@ void SoftwareIntegrationModule::handlePeerMessage(PeerMessage peerMessage) { float x = xCoordinates[i]; float y = yCoordinates[i]; float z = zCoordinates[i]; + glm::dvec3 point{ x, y, z }; const std::string key = fmt::format("[{}]", i + 1); - pointDataDictonary.setValue(key, { x, y, z }); + + // Avoid passing nan values through dictionary + if (glm::any(glm::isnan(point))) { + point = glm::dvec3(0.0); + // @TODO Keep track of invalid indices? + } + + pointDataDictonary.setValue(key, point); } // Create a renderable