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
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-06-22 11:56:21 +0300
committerJacques Lucke <jacques@blender.org>2022-06-22 11:56:21 +0300
commit2d0dc88209e166159bd0b68dc54103280b09193c (patch)
tree3875e9554c810d14fa3a490cbdf003472bd7ee3c /source/blender/nodes/function
parentc57ed65cc88418e290401599e28d51f1acb5dfd9 (diff)
parenta3d0f77ded1c982da93d61fac6942cfc67c9e599 (diff)
Merge branch 'master' into deform-curves-with-surface
Diffstat (limited to 'source/blender/nodes/function')
-rw-r--r--source/blender/nodes/function/nodes/node_fn_compare.cc4
-rw-r--r--source/blender/nodes/function/nodes/node_fn_random_value.cc8
-rw-r--r--source/blender/nodes/function/nodes/node_fn_replace_string.cc18
3 files changed, 14 insertions, 16 deletions
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<float3, float3, float, bool> 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<ColorGeometry4f, ColorGeometry4f, float, bool> 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};
diff --git a/source/blender/nodes/function/nodes/node_fn_random_value.cc b/source/blender/nodes/function/nodes/node_fn_random_value.cc
index a0942ced1be..360695299cb 100644
--- a/source/blender/nodes/function/nodes/node_fn_random_value.cc
+++ b/source/blender/nodes/function/nodes/node_fn_random_value.cc
@@ -57,7 +57,7 @@ static void fn_node_random_value_init(bNodeTree *UNUSED(tree), bNode *node)
static void fn_node_random_value_update(bNodeTree *ntree, bNode *node)
{
const NodeRandomValue &storage = node_storage(*node);
- const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type);
+ const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
bNodeSocket *sock_min_vector = (bNodeSocket *)node->inputs.first;
bNodeSocket *sock_max_vector = sock_min_vector->next;
@@ -86,7 +86,7 @@ static void fn_node_random_value_update(bNodeTree *ntree, bNode *node)
nodeSetSocketAvailability(ntree, sock_out_bool, data_type == CD_PROP_BOOL);
}
-static std::optional<CustomDataType> node_type_from_other_socket(const bNodeSocket &socket)
+static std::optional<eCustomDataType> node_type_from_other_socket(const bNodeSocket &socket)
{
switch (socket.type) {
case SOCK_FLOAT:
@@ -106,7 +106,7 @@ static std::optional<CustomDataType> node_type_from_other_socket(const bNodeSock
static void fn_node_random_value_gather_link_search(GatherLinkSearchOpParams &params)
{
const NodeDeclaration &declaration = *params.node_type().fixed_declaration;
- const std::optional<CustomDataType> type = node_type_from_other_socket(params.other_socket());
+ const std::optional<eCustomDataType> type = node_type_from_other_socket(params.other_socket());
if (!type) {
return;
}
@@ -137,7 +137,7 @@ static void fn_node_random_value_gather_link_search(GatherLinkSearchOpParams &pa
static void fn_node_random_value_build_multi_function(NodeMultiFunctionBuilder &builder)
{
const NodeRandomValue &storage = node_storage(builder.node());
- const CustomDataType data_type = static_cast<CustomDataType>(storage.data_type);
+ const eCustomDataType data_type = static_cast<eCustomDataType>(storage.data_type);
switch (data_type) {
case CD_PROP_FLOAT3: {
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<decl::String>(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)