From e07b1b8316392ebf3c51a4671d8b56dc4b222f02 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 24 May 2022 09:49:58 +0200 Subject: Fix T98317: equal vs not-equal modes in compare node are not exact opposites For vectors and colors to be not equal, it is enough when they are not equal in one component. --- source/blender/nodes/function/nodes/node_fn_compare.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 7bc9d2d79e8..e3f13dc7d6b 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -487,7 +487,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) static fn::CustomMF_SI_SI_SI_SO fn{ "Not Equal - Element-wise", [](float3 a, float3 b, float epsilon) { - return abs(a.x - b.x) > epsilon && abs(a.y - b.y) > epsilon && + return abs(a.x - b.x) > epsilon || abs(a.y - b.y) > epsilon || abs(a.z - b.z) > epsilon; }, exec_preset_first_two}; @@ -522,7 +522,7 @@ static const fn::MultiFunction *get_multi_function(bNode &node) static fn::CustomMF_SI_SI_SI_SO fn{ "Not Equal", [](ColorGeometry4f a, ColorGeometry4f b, float epsilon) { - return abs(a.r - b.r) > epsilon && abs(a.g - b.g) > epsilon && + return abs(a.r - b.r) > epsilon || abs(a.g - b.g) > epsilon || abs(a.b - b.b) > epsilon; }, exec_preset_first_two}; -- cgit v1.2.3 From 174c3ffb4adf29e0a7698aacf9468a820f448770 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 24 May 2022 10:21:02 +0200 Subject: Fix T98268: replace string node des not handle empty strings correctly Just use an existing function from blenlib instead of implementing a new version. --- .../nodes/function/nodes/node_fn_replace_string.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/function/nodes/node_fn_replace_string.cc b/source/blender/nodes/function/nodes/node_fn_replace_string.cc index 6abcc79cf29..4b493438a45 100644 --- a/source/blender/nodes/function/nodes/node_fn_replace_string.cc +++ b/source/blender/nodes/function/nodes/node_fn_replace_string.cc @@ -15,19 +15,17 @@ static void fn_node_replace_string_declare(NodeDeclarationBuilder &b) b.add_output(N_("String")); } -static std::string replace_all(std::string str, const std::string &from, const std::string &to) +static std::string replace_all(const StringRefNull str, + const StringRefNull from, + const StringRefNull to) { - if (from.length() <= 0) { + if (from.is_empty()) { return str; } - const size_t step = to.length() > 0 ? to.length() : 1; - - size_t offset = 0; - while ((offset = str.find(from, offset)) != std::string::npos) { - str.replace(offset, from.length(), to); - offset += step; - } - return str; + char *new_str_ptr = BLI_str_replaceN(str.c_str(), from.c_str(), to.c_str()); + std::string new_str{new_str_ptr}; + MEM_freeN(new_str_ptr); + return new_str; } static void fn_node_replace_string_build_multi_function(NodeMultiFunctionBuilder &builder) -- cgit v1.2.3 From ec5b53a01806465a08ca56a4dcd18092d29d66c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 24 May 2022 10:35:17 +0200 Subject: Fix T98247 EEVEE: Regression: Shader To RGB not displaying textures This was caused by the nodetree branch duplication not handling incoming links to the copied node, making all bsdfs nodes use their default values. --- source/blender/nodes/shader/node_shader_tree.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc index c5f40a46ca3..ec97637ccd2 100644 --- a/source/blender/nodes/shader/node_shader_tree.cc +++ b/source/blender/nodes/shader/node_shader_tree.cc @@ -587,10 +587,11 @@ static bNode *ntree_shader_copy_branch(bNodeTree *ntree, } } } - /* Recreate links between copied nodes. */ + /* Recreate links between copied nodes AND incomming links to the copied nodes. */ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { - if (link->fromnode->tmp_flag >= 0 && link->tonode->tmp_flag >= 0) { - bNode *fromnode = nodes_copy[link->fromnode->tmp_flag]; + if (link->tonode->tmp_flag >= 0) { + bool from_node_copied = link->fromnode->tmp_flag >= 0; + bNode *fromnode = from_node_copied ? nodes_copy[link->fromnode->tmp_flag] : link->fromnode; bNode *tonode = nodes_copy[link->tonode->tmp_flag]; bNodeSocket *fromsock = ntree_shader_node_find_output(fromnode, link->fromsock->identifier); bNodeSocket *tosock = ntree_shader_node_find_input(tonode, link->tosock->identifier); -- cgit v1.2.3