diff --git a/data/scenes/dyn/dyn_geom_swap_scene_by_indices.xml b/data/scenes/dyn/dyn_geom_swap_scene_by_indices.xml
new file mode 100644
index 000000000..25415eadc
--- /dev/null
+++ b/data/scenes/dyn/dyn_geom_swap_scene_by_indices.xml
@@ -0,0 +1,167 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/assetloading/SpectralLibrary.h b/src/assetloading/SpectralLibrary.h
index f91298d5e..e7b7ca838 100644
--- a/src/assetloading/SpectralLibrary.h
+++ b/src/assetloading/SpectralLibrary.h
@@ -79,4 +79,10 @@ class SpectralLibrary {
* @param scene Scene with materials which reflectance must be setted
*/
void setReflectances(Scene* scene);
+
+ /**
+ * @brief Obtain the default reflectance of the spectral library.
+ * @see SpectralLibrary::defaultReflectance
+ */
+ inline double getDefaultReflectance(){return defaultReflectance;}
};
\ No newline at end of file
diff --git a/src/assetloading/XmlSurveyLoader.cpp b/src/assetloading/XmlSurveyLoader.cpp
index b84b48e5e..de87cd9a4 100644
--- a/src/assetloading/XmlSurveyLoader.cpp
+++ b/src/assetloading/XmlSurveyLoader.cpp
@@ -90,6 +90,9 @@ XmlSurveyLoader::createSurveyFromXml(
(float)survey->scanner->getWavelength(), assetsDir + "spectra");
spectralLibrary.readReflectances();
spectralLibrary.setReflectances(survey->scanner->platform->scene.get());
+ survey->scanner->platform->scene->setDefaultReflectance(
+ spectralLibrary.getDefaultReflectance()
+ );
// Update materials for all swap on repeat handlers
for(std::shared_ptr sp : survey->scanner->platform->scene->parts){
diff --git a/src/main/helios_version.cpp b/src/main/helios_version.cpp
index 39f2a20b9..68351d6ab 100644
--- a/src/main/helios_version.cpp
+++ b/src/main/helios_version.cpp
@@ -4,7 +4,7 @@
const char * HELIOS_VERSION = "1.3.0";
-const char * HELIOS_GIT_HASH = "4aa844cd";
+const char * HELIOS_GIT_HASH = "e8bf9ebe";
const char * getHeliosVersion(){
return HELIOS_VERSION;
diff --git a/src/scanner/ScanningDevice.cpp b/src/scanner/ScanningDevice.cpp
index a74efce39..b8708b8eb 100644
--- a/src/scanner/ScanningDevice.cpp
+++ b/src/scanner/ScanningDevice.cpp
@@ -286,10 +286,8 @@ void ScanningDevice::computeSubrays(
){
size_t const numSubrays = cached_subrayRotation.size();
for(size_t i = 0 ; i < numSubrays ; ++i) {
- #if DATA_ANALYTICS >=2
- bool subrayHit;
- #endif
#if DATA_ANALYTICS >=2
+ bool subrayHit;
std::vector subraySimRecord(
14, std::numeric_limits::quiet_NaN()
);
diff --git a/src/scene/Scene.cpp b/src/scene/Scene.cpp
index 7fdb07939..7dccfe194 100644
--- a/src/scene/Scene.cpp
+++ b/src/scene/Scene.cpp
@@ -96,7 +96,7 @@ bool Scene::finalizeLoading(bool const safe) {
// Store original bounding box (CRS coordinates):
this->bbox_crs = AABB::getForPrimitives(primitives);
- glm::dvec3 diff = this->bbox_crs->getMin();
+ glm::dvec3 const diff = this->bbox_crs->getMin();
stringstream ss;
ss << "CRS bounding box (by vertices): " << this->bbox_crs->toString()
<< "\nShift: " << glm::to_string(diff)
diff --git a/src/scene/Scene.h b/src/scene/Scene.h
index 753f0fb2d..b789b97fe 100644
--- a/src/scene/Scene.h
+++ b/src/scene/Scene.h
@@ -124,6 +124,17 @@ class Scene : public Asset {
* @see Scene::getIntersections
*/
std::shared_ptr raycaster;
+ /**
+ * @brief The default reflectance that must be used for primitives with
+ * not reflectance (NaN). It is typically loaded through the spectral
+ * library and then assigned to the scene so it can be known when needed.
+ * @see Scene::setDefaultReflectance
+ * @see Scene::getDefaultReflectance
+ * @see SpectralLibrary
+ * @see SpectralLibrary::defaultReflectance
+ * @see XmlSurveyLoader::createSurveyFromXml
+ */
+ double defaultReflectance = 50.0;
public:
/**
@@ -473,6 +484,31 @@ class Scene : public Asset {
* @see ScenePart::sorh
*/
std::vector> getSwapOnRepeatObjects();
+ /**
+ * @brief Set the default reflectance that must be used for primitives
+ * that have no assigned reflectance.
+ * @param defaultReflectance The new default reflectance.
+ * @see Scene::defaultReflectance
+ * @see Scene::getDefaultReflectance
+ * @see SpectralLibrary
+ * @see SpectralLibrary::defaultReflectance
+ * @see XmlSurveyLoader::createSurveyFromXml
+ */
+ inline void setDefaultReflectance(double const defaultReflectance)
+ {this->defaultReflectance = defaultReflectance;}
+ /**
+ * @brief Get the default reflectance that must be used for primitives that
+ * have not got an assigned reflectance.
+ * @return The default reflectance for primitives that have not got an
+ * assigned reflectance.
+ * @see Scene::setDefaultReflectance
+ * @see SpectralLibrary
+ * @see SpectralLibrary::defaultReflectance
+ * @see XmlSurveyLoader::createSurveyFromXml
+ */
+ inline double getDefaultReflectance() const {return defaultReflectance;}
+
+
// *** READ/WRITE *** //
// ********************* //
diff --git a/src/sim/comps/SimulationPlayer.cpp b/src/sim/comps/SimulationPlayer.cpp
index 3e27f51e2..788ad1903 100644
--- a/src/sim/comps/SimulationPlayer.cpp
+++ b/src/sim/comps/SimulationPlayer.cpp
@@ -70,7 +70,7 @@ void SimulationPlayer::endPlay(){
// Restart scanner
logging::DEBUG("Restarting scanner for next simulation play ...");
restartScanner(*sim.getScanner());
- // Restar scene
+ // Restart scene
logging::DEBUG("Restarting scene for next simulation play ...");
restartScene(*sim.getScanner()->platform->scene);
// Restart simulation
@@ -168,7 +168,7 @@ void SimulationPlayer::restartScene(Scene &scene){
if(sp->sorh != nullptr && sp->sorh->needsDiscardOnReplay()){
for(Primitive * p: sp->sorh->getBaselinePrimitives()) delete p;
for(Primitive * p: sp->mPrimitives) delete p;
- sp->sorh = nullptr;
+ //sp->sorh = nullptr; // TODO Rethink : Remove to enable rebirth?
continue;
}
// Handle scene parts that must be preserved
@@ -181,7 +181,7 @@ void SimulationPlayer::restartScene(Scene &scene){
for(size_t i = 0 ; i < p->getNumVertices() ; ++i){
v[i].pos = v[i].pos + diff;
}
- p->update();
+ //p->update(); // TODO Rethink : Avoid calling twice
}
}
// Handle scene parts who are in the first play after a swap
@@ -199,8 +199,15 @@ void SimulationPlayer::restartScene(Scene &scene){
}
scene.parts = newParts;
scene.primitives = newPrims;
+ // Apply default reflectances when needed
+ for(Primitive * p : scene.primitives){
+ Material &mat = *p->material;
+ if(std::isnan(mat.reflectance)){
+ mat.reflectance = scene.getDefaultReflectance();
+ }
+ }
// Reload scene
- scene.finalizeLoading(false);
+ scene.finalizeLoading(false); // TODO Rethink : p->update is called here
}
void SimulationPlayer::restartSimulation(Simulation &sim){
diff --git a/src/sim/core/Simulation.cpp b/src/sim/core/Simulation.cpp
index 58f7073aa..66b576be4 100644
--- a/src/sim/core/Simulation.cpp
+++ b/src/sim/core/Simulation.cpp
@@ -10,10 +10,10 @@ using namespace std::chrono;
#include
#include
#ifdef DATA_ANALYTICS
-#include
#include
using helios::analytics::HDA_StateJSONReporter;
using helios::analytics::HDA_SimStepRecorder;
+using helios::analytics::HDA_Recorder;
#endif
#include "Simulation.h"
@@ -149,7 +149,11 @@ void Simulation::start() {
ss.str("");
ss << "Starting simulation loop " << simLoopIndex+1 << " ...";
logging::INFO(ss.str());
- doSimLoop();
+ doSimLoop(
+#ifdef DATA_ANALYTICS
+ ssr
+#endif
+ );
// NOTE there is no need for a sync. barrier after the last iteration
// because end of simulation will handle it.
ss.str("");
@@ -191,7 +195,14 @@ void Simulation::start() {
shutdown();
}
-void Simulation::doSimLoop(){
+void Simulation::doSimLoop(
+#ifdef DATA_ANALYTICS
+ HDA_Recorder &_ssr
+#endif
+){
+#ifdef DATA_ANALYTICS
+ HDA_SimStepRecorder &ssr = static_cast(_ssr);
+#endif
size_t iter = 1;
// Execute the main loop of the simulation
while (!isStopped()) {
diff --git a/src/sim/core/Simulation.h b/src/sim/core/Simulation.h
index e432f53c5..e8983fc2c 100644
--- a/src/sim/core/Simulation.h
+++ b/src/sim/core/Simulation.h
@@ -12,6 +12,7 @@
#endif
#ifdef DATA_ANALYTICS
#include
+#include
#endif
#include
#include
@@ -219,7 +220,11 @@ class Simulation {
* the computations between the first and the last leg of the survey.
* @return The number of iterations run in the simulation loop.
*/
- virtual void doSimLoop();
+ virtual void doSimLoop(
+#ifdef DATA_ANALYTICS
+ helios::analytics::HDA_Recorder &ssr
+#endif
+ );
/**
* @brief Stop the simulation
*