[Bf-blender-cvs] [fd477e738df] master: Geometry Nodes: remove reference to anonymous attributes in tooltips
Jacques Lucke
noreply at git.blender.org
Tue Oct 26 15:33:05 CEST 2021
Commit: fd477e738dfd65f7bb0f06c1d91c3259ed26295d
Author: Jacques Lucke
Date: Tue Oct 26 15:32:01 2021 +0200
Branches: master
https://developer.blender.org/rBfd477e738dfd65f7bb0f06c1d91c3259ed26295d
Geometry Nodes: remove reference to anonymous attributes in tooltips
This changes socket inspection for fields according to T91881.
Differential Revision: https://developer.blender.org/D13006
===================================================================
M source/blender/blenkernel/BKE_geometry_set.hh
M source/blender/blenkernel/intern/attribute_access.cc
M source/blender/editors/space_node/node_draw.cc
M source/blender/functions/FN_field.hh
M source/blender/functions/intern/field.cc
M source/blender/nodes/NOD_geometry_exec.hh
M source/blender/nodes/NOD_node_tree_ref.hh
M source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_parameter.cc
M source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
M source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
M source/blender/nodes/geometry/nodes/node_geo_input_normal.cc
M source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
M source/blender/nodes/geometry/nodes/node_geo_input_tangent.cc
M source/blender/nodes/geometry/nodes/node_geo_material_selection.cc
M source/blender/nodes/geometry/nodes/node_geo_transfer_attribute.cc
M source/blender/nodes/intern/geometry_nodes_eval_log.cc
M source/blender/nodes/intern/node_geometry_exec.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index f57765e373b..78ccefaed5c 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -736,6 +736,7 @@ class AttributeFieldInput : public fn::FieldInput {
AttributeFieldInput(std::string name, const CPPType &type)
: fn::FieldInput(type, name), name_(std::move(name))
{
+ category_ = Category::NamedAttribute;
}
template<typename T> static fn::Field<T> Create(std::string name)
@@ -764,6 +765,7 @@ class IDAttributeFieldInput : public fn::FieldInput {
public:
IDAttributeFieldInput() : fn::FieldInput(CPPType::get<int>())
{
+ category_ = Category::Generated;
}
static fn::Field<int> Create();
@@ -785,18 +787,25 @@ class AnonymousAttributeFieldInput : public fn::FieldInput {
* automatically.
*/
StrongAnonymousAttributeID anonymous_id_;
+ std::string producer_name_;
public:
- AnonymousAttributeFieldInput(StrongAnonymousAttributeID anonymous_id, const CPPType &type)
- : fn::FieldInput(type, anonymous_id.debug_name()), anonymous_id_(std::move(anonymous_id))
+ AnonymousAttributeFieldInput(StrongAnonymousAttributeID anonymous_id,
+ const CPPType &type,
+ std::string producer_name)
+ : fn::FieldInput(type, anonymous_id.debug_name()),
+ anonymous_id_(std::move(anonymous_id)),
+ producer_name_(producer_name)
{
+ category_ = Category::AnonymousAttribute;
}
- template<typename T> static fn::Field<T> Create(StrongAnonymousAttributeID anonymous_id)
+ template<typename T>
+ static fn::Field<T> Create(StrongAnonymousAttributeID anonymous_id, std::string producer_name)
{
const CPPType &type = CPPType::get<T>();
- auto field_input = std::make_shared<AnonymousAttributeFieldInput>(std::move(anonymous_id),
- type);
+ auto field_input = std::make_shared<AnonymousAttributeFieldInput>(
+ std::move(anonymous_id), type, std::move(producer_name));
return fn::Field<T>{field_input};
}
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 3386d346364..1ea7f522bef 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -1385,7 +1385,7 @@ const GVArray *AttributeFieldInput::get_varray_for_context(const fn::FieldContex
std::string AttributeFieldInput::socket_inspection_name() const
{
std::stringstream ss;
- ss << TIP_("Attribute: ") << name_;
+ ss << '"' << name_ << '"' << TIP_(" attribute from geometry");
return ss.str();
}
@@ -1468,7 +1468,7 @@ const GVArray *AnonymousAttributeFieldInput::get_varray_for_context(
std::string AnonymousAttributeFieldInput::socket_inspection_name() const
{
std::stringstream ss;
- ss << TIP_("Anonymous Attribute: ") << debug_name_;
+ ss << '"' << debug_name_ << '"' << TIP_(" from ") << producer_name_;
return ss.str();
}
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index 3a307777d0a..9e91d394fef 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -907,22 +907,22 @@ static void create_inspection_string_for_gfield(const geo_log::GFieldValueLog &v
}
else {
if (type.is<int>()) {
- ss << TIP_("Integer Field");
+ ss << TIP_("Integer field");
}
else if (type.is<float>()) {
- ss << TIP_("Float Field");
+ ss << TIP_("Float field");
}
else if (type.is<blender::float3>()) {
- ss << TIP_("Vector Field");
+ ss << TIP_("Vector field");
}
else if (type.is<bool>()) {
- ss << TIP_("Boolean Field");
+ ss << TIP_("Boolean field");
}
else if (type.is<std::string>()) {
- ss << TIP_("String Field");
+ ss << TIP_("String field");
}
else if (type.is<blender::ColorGeometry4f>()) {
- ss << TIP_("Color Field");
+ ss << TIP_("Color field");
}
ss << TIP_(" based on:\n");
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh
index ed5064fdf25..5e0302130af 100644
--- a/source/blender/functions/FN_field.hh
+++ b/source/blender/functions/FN_field.hh
@@ -227,9 +227,19 @@ class FieldContext;
* A #FieldNode that represents an input to the entire field-tree.
*/
class FieldInput : public FieldNode {
+ public:
+ /* The order is also used for sorting in socket inspection. */
+ enum class Category {
+ NamedAttribute = 0,
+ Generated = 1,
+ AnonymousAttribute = 2,
+ Unknown,
+ };
+
protected:
const CPPType *type_;
std::string debug_name_;
+ Category category_ = Category::Unknown;
public:
FieldInput(const CPPType &type, std::string debug_name = "");
@@ -245,6 +255,7 @@ class FieldInput : public FieldNode {
virtual std::string socket_inspection_name() const;
blender::StringRef debug_name() const;
const CPPType &cpp_type() const;
+ Category category() const;
const CPPType &output_cpp_type(int output_index) const override;
void foreach_field_input(FunctionRef<void(const FieldInput &)> foreach_fn) const override;
@@ -527,6 +538,11 @@ inline const CPPType &FieldInput::cpp_type() const
return *type_;
}
+inline FieldInput::Category FieldInput::category() const
+{
+ return category_;
+}
+
inline const CPPType &FieldInput::output_cpp_type(int output_index) const
{
BLI_assert(output_index == 0);
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index 5c13db9ec17..4de5e71c910 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -523,6 +523,7 @@ const GVArray *FieldContext::get_varray_for_input(const FieldInput &field_input,
IndexFieldInput::IndexFieldInput() : FieldInput(CPPType::get<int>(), "Index")
{
+ category_ = Category::Generated;
}
GVArray *IndexFieldInput::get_index_varray(IndexMask mask, ResourceScope &scope)
diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh
index 962e1c3c48f..f5775b8a6e0 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -335,6 +335,8 @@ class GeoNodeExecParams {
const GeometryComponent &component,
const AttributeDomain default_domain) const;
+ std::string attribute_producer_name() const;
+
private:
/* Utilities for detecting common errors at when using this class. */
void check_input_access(StringRef identifier, const CPPType *requested_type = nullptr) const;
diff --git a/source/blender/nodes/NOD_node_tree_ref.hh b/source/blender/nodes/NOD_node_tree_ref.hh
index b6e372470c8..9f9dcc69376 100644
--- a/source/blender/nodes/NOD_node_tree_ref.hh
+++ b/source/blender/nodes/NOD_node_tree_ref.hh
@@ -200,6 +200,8 @@ class NodeRef : NonCopyable, NonMovable {
PointerRNA *rna() const;
StringRefNull idname() const;
StringRefNull name() const;
+ StringRefNull label() const;
+ StringRefNull label_or_name() const;
bNodeType *typeinfo() const;
const NodeDeclaration *declaration() const;
@@ -575,6 +577,20 @@ inline StringRefNull NodeRef::name() const
return bnode_->name;
}
+inline StringRefNull NodeRef::label() const
+{
+ return bnode_->label;
+}
+
+inline StringRefNull NodeRef::label_or_name() const
+{
+ const StringRefNull label = this->label();
+ if (!label.is_empty()) {
+ return label;
+ }
+ return this->name();
+}
+
inline bNodeType *NodeRef::typeinfo() const
{
return bnode_->typeinfo;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
index b7352160f89..8ad70cd6d3f 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
@@ -144,7 +144,7 @@ static void geo_node_attribute_capture_exec(GeoNodeExecParams params)
break;
}
- WeakAnonymousAttributeID anonymous_id{"Attribute Capture"};
+ WeakAnonymousAttributeID anonymous_id{"Attribute"};
const CPPType &type = field.cpp_type();
static const Array<GeometryComponentType> types = {
@@ -158,8 +158,8 @@ static void geo_node_attribute_capture_exec(GeoNodeExecParams params)
}
});
- GField output_field{
- std::make_shared<bke::AnonymousAttributeFieldInput>(std::move(anonymous_id), type)};
+ GField output_field{std::make_shared<bke::AnonymousAttributeFieldInput>(
+ std::move(anonymous_id), type, params.attribute_producer_name())};
switch (data_type) {
case CD_PROP_FLOAT: {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
index ee6cf055ecb..fbe5af3bb18 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_endpoint_selection.cc
@@ -56,8 +56,11 @@ class EndpointFieldInput final : public fn::FieldInput {
public:
EndpointFieldInput(Field<int> start_size, Field<int> end_size)
- : FieldInput(CPPType::get<bool>(), "Selection"), start_size_(start_size), end_size_(end_size)
+ : FieldInput(CPPType::get<bool>(), "Endpoint Selection node"),
+ start_size_(start_size),
+ end_size_(end_size)
{
+ category_ = Category::Generated;
}
const GVArray *get_varray_for_context(const fn::FieldContext &context,
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc
index b565b1e4602..3ae330fd5cd 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc
@@ -91,8 +91,9 @@ class HandleTyp
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list