Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-03-22 14:09:06 +0300
committerJacques Lucke <jacques@blender.org>2021-03-22 14:09:06 +0300
commit77887f95cce06540dc5dcdb652546b798e826546 (patch)
treee003a90f17f9b1385bf8b76b1241f22dd482566e /source
parent01b6c4b32bf0aa3f2add0d4d51de9f777cf5c51c (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/nodes/function/nodes/node_fn_random_float.cc19
1 files changed, 3 insertions, 16 deletions
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()