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
This commit is contained in:
parent
b8b9023d8c
commit
fd477e738d
|
@ -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};
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -91,8 +91,9 @@ class HandleTypeFieldInput final : public fn::FieldInput {
|
|||
|
||||
public:
|
||||
HandleTypeFieldInput(BezierSpline::HandleType type, GeometryNodeCurveHandleMode mode)
|
||||
: FieldInput(CPPType::get<bool>(), "Selection"), type_(type), mode_(mode)
|
||||
: FieldInput(CPPType::get<bool>(), "Handle Type Selection node"), type_(type), mode_(mode)
|
||||
{
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const fn::FieldContext &context,
|
||||
|
|
|
@ -150,8 +150,9 @@ static const GVArray *construct_curve_parameter_gvarray(const CurveEval &curve,
|
|||
|
||||
class CurveParameterFieldInput final : public fn::FieldInput {
|
||||
public:
|
||||
CurveParameterFieldInput() : fn::FieldInput(CPPType::get<float>(), "Curve Parameter")
|
||||
CurveParameterFieldInput() : fn::FieldInput(CPPType::get<float>(), "Curve Parameter node")
|
||||
{
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const fn::FieldContext &context,
|
||||
|
|
|
@ -357,17 +357,20 @@ static void geo_node_curve_to_points_exec(GeoNodeExecParams params)
|
|||
if (attribute_outputs.tangent_id) {
|
||||
params.set_output(
|
||||
"Tangent",
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.tangent_id)));
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.tangent_id),
|
||||
params.attribute_producer_name()));
|
||||
}
|
||||
if (attribute_outputs.normal_id) {
|
||||
params.set_output(
|
||||
"Normal",
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.normal_id)));
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.normal_id),
|
||||
params.attribute_producer_name()));
|
||||
}
|
||||
if (attribute_outputs.rotation_id) {
|
||||
params.set_output(
|
||||
"Rotation",
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.rotation_id)));
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.rotation_id),
|
||||
params.attribute_producer_name()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -543,10 +543,10 @@ static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams par
|
|||
|
||||
AttributeOutputs attribute_outputs;
|
||||
if (params.output_is_required("Normal")) {
|
||||
attribute_outputs.normal_id = StrongAnonymousAttributeID("normal");
|
||||
attribute_outputs.normal_id = StrongAnonymousAttributeID("Normal");
|
||||
}
|
||||
if (params.output_is_required("Rotation")) {
|
||||
attribute_outputs.rotation_id = StrongAnonymousAttributeID("rotation");
|
||||
attribute_outputs.rotation_id = StrongAnonymousAttributeID("Rotation");
|
||||
}
|
||||
|
||||
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
|
||||
|
@ -562,12 +562,14 @@ static void geo_node_point_distribute_points_on_faces_exec(GeoNodeExecParams par
|
|||
if (attribute_outputs.normal_id) {
|
||||
params.set_output(
|
||||
"Normal",
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.normal_id)));
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.normal_id),
|
||||
params.attribute_producer_name()));
|
||||
}
|
||||
if (attribute_outputs.rotation_id) {
|
||||
params.set_output(
|
||||
"Rotation",
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.rotation_id)));
|
||||
AnonymousAttributeFieldInput::Create<float3>(std::move(attribute_outputs.rotation_id),
|
||||
params.attribute_producer_name()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,8 +241,9 @@ static const GVArray *construct_curve_normal_gvarray(const CurveComponent &compo
|
|||
|
||||
class NormalFieldInput final : public fn::FieldInput {
|
||||
public:
|
||||
NormalFieldInput() : fn::FieldInput(CPPType::get<float3>(), "Normal")
|
||||
NormalFieldInput() : fn::FieldInput(CPPType::get<float3>(), "Normal node")
|
||||
{
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const fn::FieldContext &context,
|
||||
|
|
|
@ -57,8 +57,9 @@ static const GVArray *construct_spline_length_gvarray(const CurveComponent &comp
|
|||
|
||||
class SplineLengthFieldInput final : public fn::FieldInput {
|
||||
public:
|
||||
SplineLengthFieldInput() : fn::FieldInput(CPPType::get<float>(), "Spline Length")
|
||||
SplineLengthFieldInput() : fn::FieldInput(CPPType::get<float>(), "Spline Length node")
|
||||
{
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const fn::FieldContext &context,
|
||||
|
|
|
@ -121,8 +121,9 @@ static const GVArray *construct_curve_tangent_gvarray(const CurveComponent &comp
|
|||
|
||||
class TangentFieldInput final : public fn::FieldInput {
|
||||
public:
|
||||
TangentFieldInput() : fn::FieldInput(CPPType::get<float3>(), "Tangent")
|
||||
TangentFieldInput() : fn::FieldInput(CPPType::get<float3>(), "Tangent node")
|
||||
{
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const fn::FieldContext &context,
|
||||
|
|
|
@ -59,8 +59,9 @@ class MaterialSelectionFieldInput final : public fn::FieldInput {
|
|||
|
||||
public:
|
||||
MaterialSelectionFieldInput(Material *material)
|
||||
: fn::FieldInput(CPPType::get<bool>(), "Material Selection"), material_(material)
|
||||
: fn::FieldInput(CPPType::get<bool>(), "Material Selection node"), material_(material)
|
||||
{
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const fn::FieldContext &context,
|
||||
|
|
|
@ -628,13 +628,14 @@ class IndexTransferFieldInput : public FieldInput {
|
|||
GField src_field,
|
||||
Field<int> index_field,
|
||||
const AttributeDomain domain)
|
||||
: FieldInput(src_field.cpp_type(), "Attribute Transfer Index"),
|
||||
: FieldInput(src_field.cpp_type(), "Attribute Transfer node"),
|
||||
src_geometry_(std::move(geometry)),
|
||||
src_field_(std::move(src_field)),
|
||||
index_field_(std::move(index_field)),
|
||||
domain_(domain)
|
||||
{
|
||||
src_geometry_.ensure_owns_direct_data();
|
||||
category_ = Category::Generated;
|
||||
}
|
||||
|
||||
const GVArray *get_varray_for_context(const FieldContext &context,
|
||||
|
|
|
@ -177,9 +177,23 @@ const SocketLog *NodeLog::lookup_socket_log(const bNode &node, const bNodeSocket
|
|||
|
||||
GFieldValueLog::GFieldValueLog(fn::GField field, bool log_full_field) : type_(field.cpp_type())
|
||||
{
|
||||
VectorSet<std::reference_wrapper<const FieldInput>> field_inputs;
|
||||
Set<std::reference_wrapper<const FieldInput>> field_inputs_set;
|
||||
field.node().foreach_field_input(
|
||||
[&](const FieldInput &field_input) { field_inputs.add(field_input); });
|
||||
[&](const FieldInput &field_input) { field_inputs_set.add(field_input); });
|
||||
|
||||
Vector<std::reference_wrapper<const FieldInput>> field_inputs;
|
||||
field_inputs.extend(field_inputs_set.begin(), field_inputs_set.end());
|
||||
|
||||
std::sort(
|
||||
field_inputs.begin(), field_inputs.end(), [](const FieldInput &a, const FieldInput &b) {
|
||||
const int index_a = (int)a.category();
|
||||
const int index_b = (int)b.category();
|
||||
if (index_a == index_b) {
|
||||
return a.socket_inspection_name().size() < b.socket_inspection_name().size();
|
||||
}
|
||||
return index_a < index_b;
|
||||
});
|
||||
|
||||
for (const FieldInput &field_input : field_inputs) {
|
||||
input_tooltips_.append(field_input.socket_inspection_name());
|
||||
}
|
||||
|
|
|
@ -183,6 +183,11 @@ AttributeDomain GeoNodeExecParams::get_highest_priority_input_domain(
|
|||
return default_domain;
|
||||
}
|
||||
|
||||
std::string GeoNodeExecParams::attribute_producer_name() const
|
||||
{
|
||||
return provider_->dnode->label_or_name() + TIP_(" node");
|
||||
}
|
||||
|
||||
void GeoNodeExecParams::check_input_access(StringRef identifier,
|
||||
const CPPType *requested_type) const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue