[Bf-blender-cvs] [77887f95cce] master: Geometry Nodes: make random float node more consistent with other nodes

Jacques Lucke noreply at git.blender.org
Mon Mar 22 12:09:15 CET 2021


Commit: 77887f95cce06540dc5dcdb652546b798e826546
Author: Jacques Lucke
Date:   Mon Mar 22 12:09:06 2021 +0100
Branches: master
https://developer.blender.org/rB77887f95cce06540dc5dcdb652546b798e826546

Geometry Nodes: make random float node more consistent with other nodes

Previously, different Random Float nodes would generate different values
depending on where they are in the node group hierarchy. This can be useful,
but should definitely not be the default behavior, because it is very inconsistent
with other nodes.

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

M	source/blender/nodes/function/nodes/node_fn_random_float.cc

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

diff --git a/source/blender/nodes/function/nodes/node_fn_random_float.cc b/source/blender/nodes/function/nodes/node_fn_random_float.cc
index d156cd431e0..a3c9f44b6a1 100644
--- a/source/blender/nodes/function/nodes/node_fn_random_float.cc
+++ b/source/blender/nodes/function/nodes/node_fn_random_float.cc
@@ -31,11 +31,8 @@ static bNodeSocketTemplate fn_node_random_float_out[] = {
 };
 
 class RandomFloatFunction : public blender::fn::MultiFunction {
- private:
-  uint32_t function_seed_;
-
  public:
-  RandomFloatFunction(uint32_t function_seed) : function_seed_(function_seed)
+  RandomFloatFunction()
   {
     static blender::fn::MFSignature signature = create_signature();
     this->set_signature(&signature);
@@ -64,7 +61,7 @@ class RandomFloatFunction : public blender::fn::MultiFunction {
       const float min_value = min_values[i];
       const float max_value = max_values[i];
       const int seed = seeds[i];
-      const float value = BLI_hash_int_01(static_cast<uint32_t>(seed) ^ function_seed_);
+      const float value = BLI_hash_int_01(static_cast<uint32_t>(seed));
       values[i] = value * (max_value - min_value) + min_value;
     }
   }
@@ -73,17 +70,7 @@ class RandomFloatFunction : public blender::fn::MultiFunction {
 static void fn_node_random_float_expand_in_mf_network(
     blender::nodes::NodeMFNetworkBuilder &builder)
 {
-  uint32_t function_seed = 1746872341u;
-  blender::nodes::DNode node = builder.dnode();
-  const blender::DefaultHash<blender::StringRefNull> hasher;
-  function_seed = 33 * function_seed + hasher(node->name());
-  for (const blender::nodes::DTreeContext *context = node.context();
-       context->parent_node() != nullptr;
-       context = context->parent_context()) {
-    function_seed = 33 * function_seed + hasher(context->parent_node()->name());
-  }
-
-  builder.construct_and_set_matching_fn<RandomFloatFunction>(function_seed);
+  builder.construct_and_set_matching_fn<RandomFloatFunction>();
 }
 
 void register_node_type_fn_random_float()



More information about the Bf-blender-cvs mailing list