From 4ca03dc890d3237695a5bc23004eb26e2959bc75 Mon Sep 17 00:00:00 2001
From: Mathias Paulin <mathias.paulin@irit.fr>
Date: Thu, 10 Feb 2022 12:52:35 +0100
Subject: [PATCH] [node] Begin NodeAdapterModel usage generalization - editable
 parameter now has ref instead of pointer to data and SourceNodeModel is made
 obsolete (to be removed)

---
 src/Mara/RadiumPlayer.cpp                     |  20 ++
 .../RenderGraphEditorView.cpp                 |  89 ++++--
 .../RadiumNBR/NodeGraph/EditableParameter.hpp |   7 +-
 src/libRender/RadiumNBR/NodeGraph/Node.hpp    |  18 ++
 .../RadiumNBR/NodeGraph/NodeFactory.cpp       |  27 +-
 .../Compositing/LessThanThresholdNode.cpp     |   2 +-
 .../Compositing/MoreThanThresholdNode.cpp     |   2 +-
 .../RenderPasses/AccessibilityBufferNode.cpp  |   4 +-
 .../RenderPasses/ClearColorNode.cpp           |   2 +-
 .../RenderPasses/VolumeVizualisationNode.cpp  |   4 +-
 .../RenderPasses/WireframeNode.cpp            |   2 +-
 .../PremadeNodes/Sources/SourceNode.hpp       |   7 +-
 .../RenderGraphs/fullfeaturerenderer.flow     | 277 ++++++++++--------
 13 files changed, 298 insertions(+), 163 deletions(-)

diff --git a/src/Mara/RadiumPlayer.cpp b/src/Mara/RadiumPlayer.cpp
index eb33a9a..e49edd4 100644
--- a/src/Mara/RadiumPlayer.cpp
+++ b/src/Mara/RadiumPlayer.cpp
@@ -218,6 +218,25 @@ void RadiumPlayer::addRenderers() {
         // 2 - Initialize the renderer using default or customized NodeGraphController
         auto renderControl       = new RadiumNBR::NodeGraphController;
         auto myRenderer          = std::make_shared<RadiumNBR::NodeBasedRenderer>( *renderControl );
+// TODO find why this is problematic as the graph is not displayed in the editor
+#if 1
+        // 3 - load default graph or user provided graph
+        auto resourcesCheck =
+            Ra::Core::Resources::getResourcesPath( nullptr, { "Resources/RadiumNBR" } );
+        if ( !resourcesCheck )
+        {
+            LOG( Ra::Core::Utils::logERROR ) << "Unable to find resources for FakeNBRRenderer!";
+            return;
+        }
+
+        if ( m_graphOption.has_value() ) { myRenderer->setJsonFilePath( m_graphOption.value() ); }
+        else
+        {
+            auto resourcesPath{ *resourcesCheck };
+            myRenderer->setJsonFilePath( resourcesPath + "RenderGraphs/fullfeaturerenderer.flow" );
+        }
+        myRenderer->signalReloadJson();
+#endif
 
         std::string rendererName = myRenderer->getRendererName();
         // The panel returned by buildNodeGraphControllerGui will manage the Qt NodeEditor window
@@ -226,6 +245,7 @@ void RadiumPlayer::addRenderers() {
         auto controlPanel        = RadiumNBR::buildNodeGraphControllerGui(
             myRenderer.get(), [this]() { this->askForUpdate(); } );
 
+
         mainWindow->addRenderer( rendererName, myRenderer, controlPanel );
     }
 
diff --git a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp
index bc82db9..c8fe4aa 100644
--- a/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp
+++ b/src/libRender/RadiumNBR/Gui/RenderGraphEditor/RenderGraphEditorView.cpp
@@ -6,6 +6,8 @@
 #include <QColorDialog>
 #include <QCoreApplication>
 
+#include <RadiumNBR/EnvMap.hpp>
+
 #include <RadiumNBR/Gui/PowerSlider.hpp>
 #include <RadiumNBR/Gui/RenderGraphEditor/ColorSlider.hpp>
 #include <RadiumNBR/Gui/TransferEditor.hpp>
@@ -16,6 +18,7 @@
 
 #include <RadiumNBR/NodeBasedRenderer.hpp>
 #include <RadiumNBR/Gui/RenderGraphEditor/WidgetFactory.hpp>
+#include <RadiumNBR/Gui/RendererPanel.hpp>
 
 RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( parent, Qt::Window ) {
     QtNodes::ConnectionStyle::setConnectionStyle(
@@ -66,13 +69,55 @@ RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( paren
     QCoreApplication::instance()->installEventFilter( this );
 
     // Create widgets
+    WidgetFactory::registerWidget<std::shared_ptr<RadiumNBR::EnvMap>>(
+        [] (EditableParameterBase* editableParameter) {
+        auto editableEnvMap =
+            dynamic_cast<EditableParameter<std::shared_ptr<RadiumNBR::EnvMap>>*>( editableParameter );
+
+        auto controlPanel = new RadiumNBR::Gui::RendererPanel( "EnvMap", false );
+        auto envmpClbck = [editableEnvMap, controlPanel]( const std::string& files ) {
+            if ( files.empty() ) { editableEnvMap->m_data = nullptr; }
+            else
+            {
+                auto t = ( files.find( ';' ) != files.npos )
+                               ? RadiumNBR::EnvMap::EnvMapType::ENVMAP_CUBE
+                               : RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM;
+                if ( t == RadiumNBR::EnvMap::EnvMapType::ENVMAP_PFM )
+                {
+                    auto ext = files.substr( files.size() - 3 );
+                    if ( ext != "pfm" ) { t = RadiumNBR::EnvMap::EnvMapType::ENVMAP_LATLON; }
+                }
+                // for now, only skyboxes are managed
+                editableEnvMap->m_data = std::make_shared<RadiumNBR::EnvMap>( files, t, true );
+                auto slider = controlPanel->findChild<PowerSlider*>( "Strength" );
+                if ( slider ) { editableEnvMap->m_data->setEnvStrength( slider->value() / 100. ); }
+            }
+        };
+        controlPanel->addFileInput(
+            "Image(s)", envmpClbck, "../", "Images (*.png *.jpg *.pfm *.exr *hdr)" );
+
+        auto strengthClbk = [editableEnvMap]( double v ) {
+            if ( editableEnvMap->m_data )
+            {
+                auto* env = editableEnvMap->m_data.get();
+                if ( env ) { env->setEnvStrength( v / 100. ); }
+            }
+        };
+        float s_init = 100.;
+        if ( editableEnvMap->m_data ) { s_init = editableEnvMap->m_data->getEnvStrength() * 100.; }
+        controlPanel->addPowerSliderInput( "Strength", strengthClbk, s_init, 0., 100 );
+        controlPanel->setVisible( true );
+        return controlPanel;
+        }
+    );
+
     WidgetFactory::registerWidget<Scalar>(
         [] (EditableParameterBase* editableParameter) {
             auto editableScalar =
                 dynamic_cast<EditableParameter<Scalar>*>( editableParameter );
 
             auto powerSlider = new PowerSlider();
-            powerSlider->setValue( *editableScalar->m_data );
+            powerSlider->setValue( editableScalar->m_data );
             if ( editableScalar->additionalData.size() >= 2 )
             {
                 powerSlider->setRange( editableScalar->additionalData[0],
@@ -84,7 +129,7 @@ RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( paren
             PowerSlider::connect( powerSlider,
                                   &PowerSlider::valueChanged,
                                   [editableScalar]( double value ) {
-                                      *( editableScalar->m_data ) = value;
+                                      editableScalar->m_data = value;
                                   } );
             return powerSlider;
         }
@@ -96,11 +141,11 @@ RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( paren
                 dynamic_cast<EditableParameter<bool>*>( editableParameter );
 
             auto checkBox = new QCheckBox();
-            checkBox->setCheckState(*(editableBoolean->m_data) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
+            checkBox->setCheckState(editableBoolean->m_data ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
             QCheckBox::connect( checkBox, &QCheckBox::stateChanged, [editableBoolean]( int state ) {
-                if ( state == Qt::Unchecked ) { *(editableBoolean->m_data) = false; }
+                if ( state == Qt::Unchecked ) { editableBoolean->m_data = false; }
                 else if ( state == Qt::Checked )
-                { *(editableBoolean->m_data) = true; }
+                { editableBoolean->m_data = true; }
             } );
             return checkBox;
         }
@@ -118,15 +163,15 @@ RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( paren
 #endif
 
             QColor tmpColor;
-            tmpColor.setRed( editableColor->m_data->x() * 255);
-            tmpColor.setRed( editableColor->m_data->y() * 255);
-            tmpColor.setRed( editableColor->m_data->z() * 255);
+            tmpColor.setRed( editableColor->m_data.x() * 255);
+            tmpColor.setRed( editableColor->m_data.y() * 255);
+            tmpColor.setRed( editableColor->m_data.z() * 255);
             colorDialog->setCurrentColor( tmpColor );
             ColorSlider::connect( colorDialog, &QColorDialog::currentColorChanged, [editableColor]( QColor value ) {
                 int newR, newG, newB;
                 value.getRgb( &newR, &newG, &newB );
 
-                *(editableColor->m_data) = ( NodeTypeColor::sRGBToLinearRGB(NodeTypeColor::fromRGB(
+                editableColor->m_data = ( NodeTypeColor::sRGBToLinearRGB(NodeTypeColor::fromRGB(
                     Ra::Core::Utils::ColorBase<float>( newR / 255.0f, newG / 255.0f, newB / 255.0f )
                         .rgb() ) ) );
             } );
@@ -154,13 +199,13 @@ RenderGraphEditorView::RenderGraphEditorView( QWidget* parent ) : QWidget( paren
                                          int pos = 0;
                                          for (int i = 0; i < 256; i++) {
                                              unsigned int color = transferEditor->colorAt( i );
-                                             editableTransferFunction->m_data->at(pos) =
+                                             editableTransferFunction->m_data.at(pos) =
                                                  (unsigned char)( ( 0x00ff0000 & color ) >> 16 ) / 255.f;
-                                             editableTransferFunction->m_data->at( pos + 1 ) =
+                                             editableTransferFunction->m_data.at( pos + 1 ) =
                                                  (unsigned char)( ( 0x0000ff00 & color ) >> 8 ) / 255.f;
-                                             editableTransferFunction->m_data->at( pos + 2 ) =
+                                             editableTransferFunction->m_data.at( pos + 2 ) =
                                                  (unsigned char)( ( 0x000000ff & color ) ) / 255.f;
-                                             editableTransferFunction->m_data->at( pos + 3 ) =
+                                             editableTransferFunction->m_data.at( pos + 3 ) =
                                                  (unsigned char)( ( 0xff000000 & color ) >> 24 ) / 255.f;
                                              pos                = pos + 4;
                                          }
@@ -255,19 +300,21 @@ std::shared_ptr<DataModelRegistry> initializeNodeRegistry(RenderGraph* renderGra
         NodeCreator<NodeAdapterModel<WireframeNode>>( renderGraph ),
         "Premade Nodes" );
 
-    ret->registerModel<SourceNodeModel<NodeTypeColor>>(
-        NodeCreator<SourceNodeModel<NodeTypeColor>>( renderGraph ),
+    ret->registerModel<NodeAdapterModel<SourceNode<NodeTypeColor>>>(
+        NodeCreator<NodeAdapterModel<SourceNode<NodeTypeColor>>>( renderGraph ),
         "Sources" );
-    ret->registerModel<SourceNodeModel<bool>>(
-        NodeCreator<SourceNodeModel<bool>>( renderGraph ), "Sources" );
-    ret->registerModel<SourceNodeModel<float>>(
-        NodeCreator<SourceNodeModel<float>>( renderGraph ), "Sources" );
+    ret->registerModel<NodeAdapterModel<SourceNode<bool>>>(
+        NodeCreator<NodeAdapterModel<SourceNode<bool>>>( renderGraph ), "Sources" );
+    ret->registerModel<NodeAdapterModel<SourceNode<float>>>(
+        NodeCreator<NodeAdapterModel<SourceNode<float>>>( renderGraph ), "Sources" );
+    ret->registerModel<NodeAdapterModel<SourceNode<EnvMapData>>>(
+        NodeCreator<NodeAdapterModel<SourceNode<EnvMapData>>>( renderGraph ), "Sources" );
+
     ret->registerModel<SourceColorTextureModel>(
         NodeCreator<SourceColorTextureModel>( renderGraph ), "Sources" );
     ret->registerModel<SourceDepthTextureModel>(
         NodeCreator<SourceDepthTextureModel>( renderGraph ), "Sources" );
-    ret->registerModel<EnvMapSourceModel>(
-        NodeCreator<EnvMapSourceModel>( renderGraph ), "Sources" );
+
 
     ret->registerModel<NodeAdapterModel<DisplaySinkNode>>(
         NodeCreator<NodeAdapterModel<DisplaySinkNode>>( renderGraph ),
diff --git a/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp b/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp
index 5ba5305..73f5a1e 100644
--- a/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp
+++ b/src/libRender/RadiumNBR/NodeGraph/EditableParameter.hpp
@@ -14,12 +14,13 @@ struct EditableParameterBase {
 
 template <typename T>
 struct EditableParameter : public EditableParameterBase {
-    EditableParameter( std::string name, T* data ) :
+    EditableParameter() = delete;
+    EditableParameter( std::string name, T& data ) :
         EditableParameterBase( name, typeid( T ).hash_code() ), m_data( data ){};
 
     void addAdditionalData( T newData ) { additionalData.push_back( newData );
     }
 
-    T* m_data{ nullptr };
+    T& m_data;
     std::vector<T> additionalData;
-};
\ No newline at end of file
+};
diff --git a/src/libRender/RadiumNBR/NodeGraph/Node.hpp b/src/libRender/RadiumNBR/NodeGraph/Node.hpp
index 4669d96..eb0ae0d 100644
--- a/src/libRender/RadiumNBR/NodeGraph/Node.hpp
+++ b/src/libRender/RadiumNBR/NodeGraph/Node.hpp
@@ -27,9 +27,27 @@ constexpr std::string_view type_name() {
 #elif defined( _MSC_VER )
     std::string_view p = __FUNCSIG__;
     return std::string_view( p.data() + 84, p.size() - 84 - 7 );
+#else
+    return type_id(T).type_name();
 #endif
 }
 
+
+inline std::size_t replace_all_in_string(std::string& inout, std::string_view what, std::string_view with)
+{
+    std::size_t count{};
+    for (std::string::size_type pos{};
+          inout.npos != (pos = inout.find(what.data(), pos, what.length()));
+          pos += with.length(), ++count) {
+        inout.replace(pos, what.length(), with.data(), with.length());
+    }
+    return count;
+}
+
+inline std::size_t remove_all_in_string(std::string& inout, std::string_view what) {
+    return replace_all_in_string(inout, what, "");
+}
+
 #include <Core/Utils/Color.hpp>
 #include <Engine/Data/ShaderProgramManager.hpp>
 #include <Engine/Data/Texture.hpp>
diff --git a/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp b/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp
index e18f9cc..4949c9c 100644
--- a/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/NodeFactory.cpp
@@ -14,7 +14,14 @@ Node* createNode( std::string& nodeType, const nlohmann::json& data ) {
     if ( nodesCreators.find( nodeType ) != nodesCreators.end() )
     { return nodesCreators[nodeType]( data ); }
     else
-    { std::cerr << "NodeFactory: no defined node for type " << nodeType << "." << std::endl; }
+    {
+        std::cerr << "NodeFactory: no defined node for type " << nodeType << "." << std::endl;
+        std::cerr << "Available nodes are : " << std::endl;
+        for(const auto&e : nodesCreators ) {
+            std::cerr << "\t" << e.first << std::endl;
+        }
+
+    }
     return nullptr;
 }
 
@@ -41,7 +48,8 @@ void initializeNodeFactory() {
         NodeFactory::registerNode<SourceNode<bool>>( []( const nlohmann::json& data ) {
             std::string value = data["model"]["boolean"];
             auto sourceBoolean =
-                new SourceNode<bool>( "boolean" + std::to_string( NodeFactory::newNodeId() ), ( value == "1" ) );
+                new SourceNode<bool>( "boolean" + std::to_string( NodeFactory::newNodeId() ) );
+            sourceBoolean->setData(value == "1");
             return sourceBoolean;
         } );
 
@@ -49,7 +57,8 @@ void initializeNodeFactory() {
             std::string value = data["model"]["number"];
             float scalar      = std::stof( value );
             auto sourceScalar =
-                new SourceNode<float>( "float" + std::to_string( NodeFactory::newNodeId() ), scalar );
+                new SourceNode<float>( "float" + std::to_string( NodeFactory::newNodeId() ) );
+            sourceScalar->setData( scalar );
             return sourceScalar;
         } );
 
@@ -61,9 +70,10 @@ void initializeNodeFactory() {
             float green            = std::stof( valueGreen ) / 255.0f;
             float blue             = std::stof( valueBlue ) / 255.0f;
             auto sourceColor       = new SourceNode<NodeTypeColor>(
-                "color" + std::to_string( NodeFactory::newNodeId() ),
-                NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB(
-                    Ra::Core::Utils::ColorBase<float>( red, green, blue ).rgb() ) ) );
+                "color" + std::to_string( NodeFactory::newNodeId() ) );
+
+            sourceColor->setData(NodeTypeColor::sRGBToLinearRGB( NodeTypeColor::fromRGB(
+                Ra::Core::Utils::ColorBase<float>( red, green, blue ).rgb() ) ));
             return sourceColor;
         } );
 
@@ -193,7 +203,7 @@ void initializeNodeFactory() {
             if ( !envmap_exist )
             {
                 auto node = new SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>(
-                    name + "_" + std::to_string( NodeFactory::newNodeId() ), nullptr );
+                    name + "_" + std::to_string( NodeFactory::newNodeId() ) );
                 return node;
             }
             else
@@ -201,7 +211,8 @@ void initializeNodeFactory() {
                 auto envmp = std::make_shared<RadiumNBR::EnvMap>( files, envType, true );
                 envmp->setEnvStrength( s );
                 auto node = new SourceNode<std::shared_ptr<RadiumNBR::EnvMap>>(
-                    name + "_" + std::to_string( NodeFactory::newNodeId() ), envmp );
+                    name + "_" + std::to_string( NodeFactory::newNodeId() ) );
+                node->setData( envmp );
                 return node;
             }
         } );
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp
index c797b5b..66ad96e 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/LessThanThresholdNode.cpp
@@ -24,7 +24,7 @@ LessThanThresholdNode::LessThanThresholdNode( const std::string& name ) : Node(
     auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
     addOutput( portOutColorTex, m_colorTexture );
 
-    auto editableThreshold = new EditableParameter<float>( "threshold", &m_editableThreshold );
+    auto editableThreshold = new EditableParameter<float>( "threshold", m_editableThreshold );
     editableThreshold->addAdditionalData(0.0f);
     editableThreshold->addAdditionalData(1.0f);
     addEditableParameter( editableThreshold );
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp
index 8b03d51..010c61e 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Compositing/MoreThanThresholdNode.cpp
@@ -24,7 +24,7 @@ MoreThanThresholdNode::MoreThanThresholdNode( const std::string& name ) : Node(
     auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
     addOutput( portOutColorTex, m_colorTexture );
 
-    auto editableThreshold = new EditableParameter<float>( "threshold", &m_editableThreshold );
+    auto editableThreshold = new EditableParameter<float>( "threshold", m_editableThreshold );
     editableThreshold->addAdditionalData(0.0f);
     editableThreshold->addAdditionalData(1.0f);
     addEditableParameter( editableThreshold );
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp
index 99b24e5..ae2811c 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/AccessibilityBufferNode.cpp
@@ -33,11 +33,11 @@ AccessibilityBufferNode::AccessibilityBufferNode( const std::string& name ) : No
     auto portOutAO = new PortOut<NodeTypeTexture>( "outAO", this );
     addOutput( portOutAO, m_AO );
 
-    auto editableRadius = new EditableParameter( "radius", &m_editableAORadius );
+    auto editableRadius = new EditableParameter( "radius", m_editableAORadius );
     editableRadius->addAdditionalData( 0. );
     editableRadius->addAdditionalData( 100. );
     addEditableParameter( editableRadius );
-    auto editableSamples = new EditableParameter( "samples", &m_editableSamples );
+    auto editableSamples = new EditableParameter( "samples", m_editableSamples );
     editableSamples->addAdditionalData( 0. );
     editableSamples->addAdditionalData( 4096. );
     addEditableParameter( editableSamples );
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp
index dbb8624..a809d7b 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/ClearColorNode.cpp
@@ -18,7 +18,7 @@ ClearColorNode::ClearColorNode( const std::string& name ) : Node( name ) {
     auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColor", this );
     addOutput( portOutColorTex, m_colorTexture );
 
-    auto editableColor = new EditableParameter("clear color", &m_editableClearColor);
+    auto editableColor = new EditableParameter("clear color", m_editableClearColor);
     addEditableParameter(editableColor);
 }
 
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp
index 636264d..6a7cc33 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/VolumeVizualisationNode.cpp
@@ -18,7 +18,7 @@ VolumeVizualisationNode::VolumeVizualisationNode( const std::string& name ) : No
     auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
     addOutput( portOutColorTex, m_colorTexture );
 
-    auto editableTransferFunction = new EditableParameter<std::array<float, 256 * 4>>( "transfer function", &m_editableTransferFunction);
+    auto editableTransferFunction = new EditableParameter<std::array<float, 256 * 4>>( "transfer function", m_editableTransferFunction);
     addEditableParameter( editableTransferFunction );
 }
 
@@ -251,4 +251,4 @@ void VolumeVizualisationNode::buildRenderTechnique( const Ra::Engine::Rendering:
         rt.setConfiguration( theConfig, m_idx );
     }
     rt.setParametersProvider( paramProvider, m_idx );
-}
\ No newline at end of file
+}
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp
index ce345ea..07357fa 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/RenderPasses/WireframeNode.cpp
@@ -108,7 +108,7 @@ WireframeNode::WireframeNode( const std::string& name ) : Node( name ) {
     auto portOutColorTex = new PortOut<NodeTypeTexture>( "outColorTexture", this );
     addOutput( portOutColorTex, m_colorTexture );
 
-    auto editableActivate = new EditableParameter("activate", &m_editableActivate);
+    auto editableActivate = new EditableParameter("activate", m_editableActivate);
     addEditableParameter(editableActivate);
 }
 
diff --git a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp
index e7b6796..52797cb 100644
--- a/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp
+++ b/src/libRender/RadiumNBR/NodeGraph/PremadeNodes/Sources/SourceNode.hpp
@@ -8,11 +8,11 @@ template <typename T>
 class SourceNode : public Node
 {
   public:
-    SourceNode( const std::string& name, T data ) : Node( name ), m_data( data ) {
+    SourceNode( const std::string& name ) : Node( name ) {
         auto portOut = new PortOut<T>( "to", this );
         addOutput( portOut, &m_data );
 
-        auto editableData = new EditableParameter( "data", &m_data );
+        auto editableData = new EditableParameter( "data", m_data );
         addEditableParameter( editableData );
     }
 
@@ -59,9 +59,10 @@ class SourceNode : public Node
             templatedTypeName = templatedTypeName.substr( pos + 1, templatedTypeName.size() ); }
         pos = templatedTypeName.find_first_of('>');
         if (pos != std::string::npos) { templatedTypeName = templatedTypeName.substr( 0, pos ); }*/
+        remove_all_in_string(templatedTypeName, "::__1"); // --> HACK to put in type_name<T>
         return "Source " + templatedTypeName;
     }
 
   private:
-    T m_data;
+    T m_data {};
 };
diff --git a/src/libRender/Resources/RadiumNBR/RenderGraphs/fullfeaturerenderer.flow b/src/libRender/Resources/RadiumNBR/RenderGraphs/fullfeaturerenderer.flow
index 8b3ff57..78366f6 100644
--- a/src/libRender/Resources/RadiumNBR/RenderGraphs/fullfeaturerenderer.flow
+++ b/src/libRender/Resources/RadiumNBR/RenderGraphs/fullfeaturerenderer.flow
@@ -1,46 +1,64 @@
 {
     "connections": [
         {
-            "in_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
-            "in_index": 0,
-            "out_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
+            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "in_index": 4,
+            "out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
             "out_index": 0
         },
         {
-            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
+            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
             "in_index": 3,
-            "out_id": "{b6e2da15-7b3c-4b85-b656-79a46d94c33d}",
+            "out_id": "{ab3678ab-f0fd-4815-8fa7-7cd08bb239fd}",
             "out_index": 0
         },
         {
-            "in_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
-            "in_index": 4,
-            "out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
+            "in_id": "{4eabb57e-6858-49aa-bfe2-c6a0a20850c3}",
+            "in_index": 3,
+            "out_id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
             "out_index": 0
         },
         {
-            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
+            "in_id": "{4eabb57e-6858-49aa-bfe2-c6a0a20850c3}",
+            "in_index": 2,
+            "out_id": "{ab3678ab-f0fd-4815-8fa7-7cd08bb239fd}",
+            "out_index": 0
+        },
+        {
+            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
             "in_index": 1,
             "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
             "out_index": 0
         },
         {
-            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
-            "in_index": 0,
-            "out_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
+            "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
+            "in_index": 3,
+            "out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
             "out_index": 0
         },
         {
-            "in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
-            "in_index": 0,
-            "out_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
+            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "in_index": 2,
+            "out_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
             "out_index": 0
         },
         {
-            "in_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
+            "in_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
+            "in_index": 4,
+            "out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
+            "out_index": 0
+        },
+        {
+            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
+            "in_index": 2,
+            "out_id": "{9579a8e2-d2d0-4107-b7b5-32b4aa1e7ce9}",
+            "out_index": 0
+        },
+        {
+            "in_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
             "in_index": 1,
-            "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
-            "out_index": 2
+            "out_id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
+            "out_index": 0
         },
         {
             "in_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
@@ -49,9 +67,15 @@
             "out_index": 0
         },
         {
-            "in_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
-            "in_index": 1,
-            "out_id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
+            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
+            "in_index": 0,
+            "out_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
+            "out_index": 0
+        },
+        {
+            "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
+            "in_index": 4,
+            "out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
             "out_index": 0
         },
         {
@@ -66,10 +90,16 @@
             "out_id": "{b6e2da15-7b3c-4b85-b656-79a46d94c33d}",
             "out_index": 0
         },
+        {
+            "in_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
+            "in_index": 3,
+            "out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
+            "out_index": 0
+        },
         {
             "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
-            "in_index": 2,
-            "out_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
+            "in_index": 0,
+            "out_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
             "out_index": 0
         },
         {
@@ -79,57 +109,63 @@
             "out_index": 1
         },
         {
-            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
-            "in_index": 4,
-            "out_id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
+            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
+            "in_index": 3,
+            "out_id": "{b6e2da15-7b3c-4b85-b656-79a46d94c33d}",
             "out_index": 0
         },
         {
             "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
-            "in_index": 1,
-            "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
-            "out_index": 0
-        },
-        {
-            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
             "in_index": 2,
             "out_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
             "out_index": 0
         },
         {
             "in_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
-            "in_index": 3,
-            "out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
+            "in_index": 0,
+            "out_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
             "out_index": 0
         },
         {
-            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
-            "in_index": 5,
-            "out_id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
+            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
+            "in_index": 4,
+            "out_id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
             "out_index": 0
         },
         {
-            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
-            "in_index": 3,
-            "out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
+            "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
+            "in_index": 1,
+            "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
             "out_index": 0
         },
         {
-            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "in_id": "{aa0f14a1-bb34-43a6-a11d-5b88404d254d}",
+            "in_index": 0,
+            "out_id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
+            "out_index": 0
+        },
+        {
+            "in_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
             "in_index": 1,
             "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
-            "out_index": 0
+            "out_index": 2
         },
         {
-            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
+            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
             "in_index": 2,
-            "out_id": "{9579a8e2-d2d0-4107-b7b5-32b4aa1e7ce9}",
+            "out_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
             "out_index": 0
         },
         {
-            "in_id": "{4eabb57e-6858-49aa-bfe2-c6a0a20850c3}",
-            "in_index": 0,
-            "out_id": "{62ad7aec-1ea4-4f10-85cb-4be1ecda4263}",
+            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "in_index": 5,
+            "out_id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
+            "out_index": 0
+        },
+        {
+            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "in_index": 1,
+            "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
             "out_index": 0
         },
         {
@@ -139,9 +175,9 @@
             "out_index": 0
         },
         {
-            "in_id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "in_id": "{4eabb57e-6858-49aa-bfe2-c6a0a20850c3}",
             "in_index": 0,
-            "out_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
+            "out_id": "{62ad7aec-1ea4-4f10-85cb-4be1ecda4263}",
             "out_index": 0
         },
         {
@@ -150,6 +186,12 @@
             "out_id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
             "out_index": 0
         },
+        {
+            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
+            "in_index": 1,
+            "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
+            "out_index": 0
+        },
         {
             "in_id": "{9579a8e2-d2d0-4107-b7b5-32b4aa1e7ce9}",
             "in_index": 0,
@@ -157,15 +199,15 @@
             "out_index": 0
         },
         {
-            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
-            "in_index": 0,
-            "out_id": "{4eabb57e-6858-49aa-bfe2-c6a0a20850c3}",
+            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
+            "in_index": 3,
+            "out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
             "out_index": 0
         },
         {
-            "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
-            "in_index": 2,
-            "out_id": "{cb6e4c08-38bf-48fd-8cf2-392a5491751b}",
+            "in_id": "{d79d27a4-64c1-4fa1-adc8-c39fd9da3008}",
+            "in_index": 0,
+            "out_id": "{4eabb57e-6858-49aa-bfe2-c6a0a20850c3}",
             "out_index": 0
         },
         {
@@ -173,46 +215,60 @@
             "in_index": 4,
             "out_id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
             "out_index": 0
-        },
+        }
+    ],
+    "nodes": [
         {
-            "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
-            "in_index": 3,
-            "out_id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
-            "out_index": 0
+            "id": "{ab3678ab-f0fd-4815-8fa7-7cd08bb239fd}",
+            "model": {
+                "files": "/Users/mathias/Professionnel/Data/skyboxes/Spherical/spiaggia_di_mondello.jpg",
+                "name": "Source std::shared_ptr<RadiumNBR::EnvMap>",
+                "strength": "100",
+                "type": "2"
+            },
+            "position": {
+                "x": 555.6,
+                "y": -454.8
+            }
         },
         {
-            "in_id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
-            "in_index": 4,
-            "out_id": "{6ceda554-f6d1-4cf0-a36d-e811fc0ad3f1}",
-            "out_index": 0
+            "id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
+            "model": {
+                "name": "Local Light Pass"
+            },
+            "position": {
+                "x": 1986.3119999999997,
+                "y": 270.06399999999996
+            }
         },
         {
-            "in_id": "{34e8d2d1-a2de-4ebe-a18f-4dcd5b440d1c}",
-            "in_index": 1,
-            "out_id": "{9654598f-d4d4-494d-9f14-65d75606f1af}",
-            "out_index": 0
-        }
-    ],
-    "nodes": [
+            "id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
+            "model": {
+                "name": "Environment Light Pass"
+            },
+            "position": {
+                "x": 1491.0201599999996,
+                "y": -25.388160000000028
+            }
+        },
         {
-            "id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
+            "id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
             "model": {
-                "name": "Lights"
+                "name": "Wireframe Pass"
             },
             "position": {
-                "x": 1345.2000000000003,
-                "y": 722.3999999999999
+                "x": 3098.303999999999,
+                "y": 412.9919999999999
             }
         },
         {
-            "id": "{9579a8e2-d2d0-4107-b7b5-32b4aa1e7ce9}",
+            "id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
             "model": {
-                "filteredType": "Transparent",
-                "name": "Filter RenderObjects By Type"
+                "name": "Cameras"
             },
             "position": {
-                "x": 1717.9199999999996,
-                "y": 879.8399999999998
+                "x": -298.08,
+                "y": 73.09440000000001
             }
         },
         {
@@ -225,6 +281,27 @@
                 "y": 627.6
             }
         },
+        {
+            "id": "{c6d4682c-2a02-467a-9c5c-5511b63b17ba}",
+            "model": {
+                "name": "Lights"
+            },
+            "position": {
+                "x": 1345.2000000000003,
+                "y": 722.3999999999999
+            }
+        },
+        {
+            "id": "{9579a8e2-d2d0-4107-b7b5-32b4aa1e7ce9}",
+            "model": {
+                "filteredType": "Transparent",
+                "name": "Filter RenderObjects By Type"
+            },
+            "position": {
+                "x": 1717.9199999999996,
+                "y": 879.8399999999998
+            }
+        },
         {
             "id": "{d07939d8-46d5-4d48-90fa-4ab2a4eebf30}",
             "model": {
@@ -324,46 +401,6 @@
                 "x": 528.5280000000002,
                 "y": 201.216
             }
-        },
-        {
-            "id": "{dbdcd645-0ee6-4f1f-8835-8ab1a04feb4c}",
-            "model": {
-                "name": "Cameras"
-            },
-            "position": {
-                "x": -298.08,
-                "y": 73.09440000000001
-            }
-        },
-        {
-            "id": "{c4f37638-3568-46cd-acbe-622013f79c13}",
-            "model": {
-                "name": "Wireframe Pass"
-            },
-            "position": {
-                "x": 3098.303999999999,
-                "y": 412.9919999999999
-            }
-        },
-        {
-            "id": "{c66eb0ff-d015-4974-b729-a272678bce05}",
-            "model": {
-                "name": "Environment Light Pass"
-            },
-            "position": {
-                "x": 1491.0201599999996,
-                "y": -25.388160000000028
-            }
-        },
-        {
-            "id": "{bdfe05be-3655-4d56-924d-ff3b1bbd709b}",
-            "model": {
-                "name": "Local Light Pass"
-            },
-            "position": {
-                "x": 1986.3119999999997,
-                "y": 270.06399999999996
-            }
         }
     ]
 }
-- 
GitLab