Commit: b40bdad10419d57c647bc8cf01643cb567017999 Author: Jacques Lucke Date: Sun Jan 19 10:57:14 2020 +0100 Branches: functions https://developer.blender.org/rBb40bdad10419d57c647bc8cf01643cb567017999
utility to generate constant random numbers per line =================================================================== A source/blender/blenlib/BLI_rand_cxx.h M source/blender/blenlib/CMakeLists.txt M source/blender/functions/intern/node_tree_multi_function_network/generate.cc =================================================================== diff --git a/source/blender/blenlib/BLI_rand_cxx.h b/source/blender/blenlib/BLI_rand_cxx.h new file mode 100644 index 00000000000..bb21dfd8e71 --- /dev/null +++ b/source/blender/blenlib/BLI_rand_cxx.h @@ -0,0 +1,26 @@ +#ifndef __BLI_RAND_CXX_H__ +#define __BLI_RAND_CXX_H__ + +#include "BLI_utildefines.h" + +#include <iostream> + +namespace BLI { + +inline uint32_t hash_from_path_and_line(const char *path, uint32_t line) +{ + uint32_t hash = 5381; + const char *str = path; + char c = 0; + while ((c = *str++)) { + hash = hash * 37 + c; + } + hash = hash ^ ((line + 573259433) * 654188383); + return hash; +} + +} // namespace BLI + +#define BLI_RAND_PER_LINE_UINT32 BLI::hash_from_path_and_line(__FILE__, __LINE__) + +#endif /* __BLI_RAND_CXX_H__ */ diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 40f6fa6f769..bafd0b8bf41 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -277,6 +277,7 @@ set(SRC BLI_parallel.h BLI_string_multi_map.h BLI_index_to_ref_map.h + BLI_rand_cxx.h ) set(LIB diff --git a/source/blender/functions/intern/node_tree_multi_function_network/generate.cc b/source/blender/functions/intern/node_tree_multi_function_network/generate.cc index 6e845290f53..f60bc77ee85 100644 --- a/source/blender/functions/intern/node_tree_multi_function_network/generate.cc +++ b/source/blender/functions/intern/node_tree_multi_function_network/generate.cc @@ -270,10 +270,10 @@ std::unique_ptr<FunctionTreeMFNetwork> generate_node_tree_multi_function_network BLI_assert(false); } - // optimize_network__constant_folding(network_builder, resources); - // optimize_network__remove_duplicates(network_builder); - // optimize_network__remove_unused_nodes(network_builder); - // network_builder.to_dot__clipboard(); + optimize_network__constant_folding(network_builder, resources); + optimize_network__remove_duplicates(network_builder); + optimize_network__remove_unused_nodes(network_builder); + network_builder.to_dot__clipboard(); auto function_tree_network = build(function_tree, network_builder, dummy_socket_mapping); return function_tree_network; } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs