[Bf-blender-cvs] [4afdb40b4ee] functions: set operation hash for some functions

Jacques Lucke noreply at git.blender.org
Sat Jan 18 20:18:07 CET 2020


Commit: 4afdb40b4eec02442e1579c475e1a81376306027
Author: Jacques Lucke
Date:   Sat Jan 18 20:00:14 2020 +0100
Branches: functions
https://developer.blender.org/rB4afdb40b4eec02442e1579c475e1a81376306027

set operation hash for some functions

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

M	source/blender/functions/intern/multi_functions/constants.cc
M	source/blender/functions/intern/multi_functions/constants.h
M	source/blender/functions/intern/multi_functions/mixed.cc

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

diff --git a/source/blender/functions/intern/multi_functions/constants.cc b/source/blender/functions/intern/multi_functions/constants.cc
index d7425004e8b..995738f879c 100644
--- a/source/blender/functions/intern/multi_functions/constants.cc
+++ b/source/blender/functions/intern/multi_functions/constants.cc
@@ -33,6 +33,11 @@ MF_GenericConstantValue::MF_GenericConstantValue(const CPPType &type, const void
   std::stringstream ss;
   MF_GenericConstantValue::value_to_string(ss, type, value);
   signature.single_output(ss.str(), type);
+
+  if (type == CPP_TYPE<float>()) {
+    uint32_t hash = *(uint32_t *)value;
+    signature.operation_hash(hash);
+  }
 }
 
 void MF_GenericConstantValue::call(IndexMask mask,
diff --git a/source/blender/functions/intern/multi_functions/constants.h b/source/blender/functions/intern/multi_functions/constants.h
index bfe9bfe3c3d..02a91d07c64 100644
--- a/source/blender/functions/intern/multi_functions/constants.h
+++ b/source/blender/functions/intern/multi_functions/constants.h
@@ -4,6 +4,8 @@
 
 #include <sstream>
 
+#include "BLI_hash.h"
+
 namespace FN {
 
 /**
@@ -44,6 +46,19 @@ template<typename T> class MF_ConstantValue : public MultiFunction {
     std::stringstream ss;
     MF_GenericConstantValue::value_to_string(ss, CPP_TYPE<T>(), (const void *)&m_value);
     signature.single_output<T>(ss.str());
+
+    if (CPP_TYPE<T>() == CPP_TYPE<float>()) {
+      uint32_t hash = BLI_hash_int(*(uint *)&m_value);
+      signature.operation_hash(hash);
+    }
+    else if (CPP_TYPE<T>() == CPP_TYPE<int>()) {
+      uint32_t hash = BLI_hash_int(*(uint *)&m_value);
+      signature.operation_hash(hash);
+    }
+    else if (CPP_TYPE<T>() == CPP_TYPE<std::string>()) {
+      uint32_t hash = BLI_hash_string(((std::string *)&m_value)->c_str());
+      signature.operation_hash(hash);
+    }
   }
 
   void call(IndexMask mask, MFParams params, MFContext UNUSED(context)) const override
diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc
index 93b3659be4e..21233c674a8 100644
--- a/source/blender/functions/intern/multi_functions/mixed.cc
+++ b/source/blender/functions/intern/multi_functions/mixed.cc
@@ -175,6 +175,7 @@ void MF_FloatArraySum::call(IndexMask mask, MFParams params, MFContext UNUSED(co
 MF_FloatRange_Amount_Start_Step::MF_FloatRange_Amount_Start_Step()
 {
   MFSignatureBuilder signature = this->get_builder("Float Range");
+  signature.constant_operation_hash();
   signature.single_input<int>("Amount");
   signature.single_input<float>("Start");
   signature.single_input<float>("Step");
@@ -207,6 +208,7 @@ void MF_FloatRange_Amount_Start_Step::call(IndexMask mask,
 MF_FloatRange_Amount_Start_Stop::MF_FloatRange_Amount_Start_Stop()
 {
   MFSignatureBuilder signature = this->get_builder("Float Range");
+  signature.constant_operation_hash();
   signature.single_input<int>("Amount");
   signature.single_input<float>("Start");
   signature.single_input<float>("Stop");



More information about the Bf-blender-cvs mailing list