[Bf-blender-cvs] [74eeb7a759a] functions: improve debug dot output

Jacques Lucke noreply at git.blender.org
Thu Dec 19 13:21:44 CET 2019


Commit: 74eeb7a759a9966d51e957cfc28c7773238d413c
Author: Jacques Lucke
Date:   Thu Dec 19 12:12:24 2019 +0100
Branches: functions
https://developer.blender.org/rB74eeb7a759a9966d51e957cfc28c7773238d413c

improve debug dot output

===================================================================

M	source/blender/functions/intern/inlined_tree_multi_function_network/builder.h
M	source/blender/functions/intern/multi_functions/customizable.h

===================================================================

diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/builder.h b/source/blender/functions/intern/inlined_tree_multi_function_network/builder.h
index da891af5614..2f6a5ebdfff 100644
--- a/source/blender/functions/intern/inlined_tree_multi_function_network/builder.h
+++ b/source/blender/functions/intern/inlined_tree_multi_function_network/builder.h
@@ -298,9 +298,10 @@ class VSocketMFNetworkBuilder {
     return m_network_builder;
   }
 
-  template<typename T> void set_constant_value(const T &value)
+  template<typename T> void set_constant_value(T value)
   {
-    const MultiFunction &fn = m_network_builder.construct_fn<MF_ConstantValue<T>>(value);
+    const MultiFunction &fn = m_network_builder.construct_fn<MF_ConstantValue<T>>(
+        std::move(value));
     this->set_generator_fn(fn);
   }
 
diff --git a/source/blender/functions/intern/multi_functions/customizable.h b/source/blender/functions/intern/multi_functions/customizable.h
index 217015cb663..0f652beac64 100644
--- a/source/blender/functions/intern/multi_functions/customizable.h
+++ b/source/blender/functions/intern/multi_functions/customizable.h
@@ -12,17 +12,40 @@ template<typename T> class MF_ConstantValue : public MultiFunction {
   MF_ConstantValue(T value) : m_value(std::move(value))
   {
     MFSignatureBuilder signature = this->get_builder("Constant " + CPP_TYPE<T>().name());
-    signature.single_output<T>("Output");
+    std::string name = output_name_from_value(m_value);
+    signature.single_output<T>(name);
   }
 
   void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
   {
-    MutableArrayRef<T> output = params.uninitialized_single_output<T>(0, "Output");
+    MutableArrayRef<T> output = params.uninitialized_single_output<T>(0);
 
     mask.foreach_index([&](uint i) { new (output.begin() + i) T(m_value); });
   }
+
+ private:
+  static std::string output_name_from_value(const T &UNUSED(value))
+  {
+    return "Value";
+  }
 };
 
+template<> inline std::string MF_ConstantValue<float>::output_name_from_value(const float &value)
+{
+  return std::to_string(value);
+}
+
+template<> inline std::string MF_ConstantValue<int>::output_name_from_value(const int &value)
+{
+  return std::to_string(value);
+}
+
+template<>
+inline std::string MF_ConstantValue<std::string>::output_name_from_value(const std::string &value)
+{
+  return "\"" + value + "\"";
+}
+
 template<typename FromT, typename ToT> class MF_Convert : public MultiFunction {
  public:
   MF_Convert()



More information about the Bf-blender-cvs mailing list