Cleanup: Use fmt library for geometry nodes error messages
Pull Request: https://projects.blender.org/blender/blender/pulls/108910
This commit is contained in:
parent
dc874b9f24
commit
31145ffce5
@ -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)
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
#include "node_geometry_util.hh"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
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);
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include "NOD_socket_search_link.hh"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
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));
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include "node_geometry_util.hh"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
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<GeometrySet>("Geometry");
|
||||
std::string name = params.extract_input<std::string>("Name");
|
||||
const std::string name = params.extract_input<std::string>("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));
|
||||
|
Loading…
Reference in New Issue
Block a user