diff --git a/source/blender/nodes/geometry/CMakeLists.txt b/source/blender/nodes/geometry/CMakeLists.txt index 4dcb9a3d20d..9ba6c45c03c 100644 --- a/source/blender/nodes/geometry/CMakeLists.txt +++ b/source/blender/nodes/geometry/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../../makesrna ../../render ../../windowmanager + ../../../../extern/fmtlib/include ../../../../intern/guardedalloc # RNA_prototypes.h ${CMAKE_BINARY_DIR}/source/blender/makesrna @@ -204,6 +205,7 @@ set(LIB bf_functions bf_geometry bf_nodes + extern_fmtlib ) if(WITH_BULLET) diff --git a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc index cf730f12879..e924dd8a08e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_on_surface.cc @@ -29,6 +29,8 @@ #include "node_geometry_util.hh" +#include + namespace blender::nodes::node_geo_deform_curves_on_surface_cc { using bke::CurvesGeometry; @@ -274,18 +276,16 @@ static void node_geo_exec(GeoNodeExecParams params) if (!mesh_attributes_eval.contains(uv_map_name)) { pass_through_input(); - char *message = BLI_sprintfN(TIP_("Evaluated surface missing UV map: \"%s\""), - uv_map_name.c_str()); + const std::string message = fmt::format(TIP_("Evaluated surface missing UV map: \"{}\""), + std::string_view(uv_map_name)); params.error_message_add(NodeWarningType::Error, message); - MEM_freeN(message); return; } if (!mesh_attributes_orig.contains(uv_map_name)) { pass_through_input(); - char *message = BLI_sprintfN(TIP_("Original surface missing UV map: \"%s\""), - uv_map_name.c_str()); + const std::string message = fmt::format(TIP_("Original surface missing UV map: \"{}\""), + std::string_view(uv_map_name)); params.error_message_add(NodeWarningType::Error, message); - MEM_freeN(message); return; } if (!mesh_attributes_eval.contains(rest_position_name)) { @@ -398,10 +398,9 @@ static void node_geo_exec(GeoNodeExecParams params) curves.tag_positions_changed(); if (invalid_uv_count) { - char *message = BLI_sprintfN(TIP_("Invalid surface UVs on %d curves"), - invalid_uv_count.load()); + const std::string message = fmt::format(TIP_("Invalid surface UVs on {} curves"), + invalid_uv_count.load()); params.error_message_add(NodeWarningType::Warning, message); - MEM_freeN(message); } params.set_output("Curves", curves_geometry); diff --git a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc index 895c4978317..133d993cdf0 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_remove_attribute.cc @@ -6,6 +6,8 @@ #include "NOD_socket_search_link.hh" +#include + namespace blender::nodes::node_geo_remove_attribute_cc { static void node_declare(NodeDeclarationBuilder &b) @@ -62,15 +64,13 @@ static void node_geo_exec(GeoNodeExecParams params) } if (!attribute_exists) { - char *message = BLI_sprintfN(TIP_("Attribute does not exist: \"%s\""), name.c_str()); + const std::string message = fmt::format(TIP_("Attribute does not exist: \"{}\""), name); params.error_message_add(NodeWarningType::Warning, message); - MEM_freeN(message); } if (cannot_delete) { - char *message = BLI_sprintfN(TIP_("Cannot delete built-in attribute with name \"%s\""), - name.c_str()); + const std::string message = fmt::format(TIP_("Cannot delete built-in attribute: \"{}\""), + name); params.error_message_add(NodeWarningType::Warning, message); - MEM_freeN(message); } params.set_output("Geometry", std::move(geometry_set)); diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 51c8860b746..45a416a4e31 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -15,6 +15,8 @@ #include "node_geometry_util.hh" +#include + namespace blender::nodes::node_geo_store_named_attribute_cc { NODE_STORAGE_FUNCS(NodeGeometryStoreNamedAttribute) @@ -94,7 +96,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) static void node_geo_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); - std::string name = params.extract_input("Name"); + const std::string name = params.extract_input("Name"); if (name.empty()) { params.set_output("Geometry", std::move(geometry_set)); @@ -182,13 +184,12 @@ static void node_geo_exec(GeoNodeExecParams params) RNA_enum_name_from_value(rna_enum_attribute_domain_items, domain, &domain_name); const char *type_name = nullptr; RNA_enum_name_from_value(rna_enum_attribute_type_items, data_type, &type_name); - char *message = BLI_sprintfN( - TIP_("Failed to write to attribute \"%s\" with domain \"%s\" and type \"%s\""), - name.c_str(), + const std::string message = fmt::format( + TIP_("Failed to write to attribute \"{}\" with domain \"{}\" and type \"{}\""), + name, TIP_(domain_name), TIP_(type_name)); params.error_message_add(NodeWarningType::Warning, message); - MEM_freeN(message); } params.set_output("Geometry", std::move(geometry_set));