Geometry Nodes: improve dot graph export of lazy function graph

* Dim default input values.
* Print default input values instead of type name.
* Add node/socket names to group input/output nodes.
This commit is contained in:
2022-12-16 12:18:49 +01:00
parent ba89f640fe
commit c37e07bc01
5 changed files with 103 additions and 11 deletions

View File

@@ -48,13 +48,16 @@ FunctionNode &Graph::add_function(const LazyFunction &fn)
return node;
}
DummyNode &Graph::add_dummy(Span<const CPPType *> input_types, Span<const CPPType *> output_types)
DummyNode &Graph::add_dummy(Span<const CPPType *> input_types,
Span<const CPPType *> output_types,
const DummyDebugInfo *debug_info)
{
DummyNode &node = *allocator_.construct<DummyNode>().release();
node.fn_ = nullptr;
node.inputs_ = allocator_.construct_elements_and_pointer_array<InputSocket>(input_types.size());
node.outputs_ = allocator_.construct_elements_and_pointer_array<OutputSocket>(
output_types.size());
node.debug_info_ = debug_info;
for (const int i : input_types.index_range()) {
InputSocket &socket = *node.inputs_[i];
@@ -100,6 +103,8 @@ bool Graph::node_indices_are_valid() const
return true;
}
static const char *fallback_name = "No Name";
std::string Socket::name() const
{
if (node_->is_function()) {
@@ -110,15 +115,41 @@ std::string Socket::name() const
}
return fn.output_name(index_in_node_);
}
return "Unnamed";
const DummyNode &dummy_node = *static_cast<const DummyNode *>(node_);
if (dummy_node.debug_info_) {
if (is_input_) {
return dummy_node.debug_info_->input_name(index_in_node_);
}
return dummy_node.debug_info_->output_name(index_in_node_);
}
return fallback_name;
}
std::string Node::name() const
{
if (fn_ == nullptr) {
return static_cast<const DummyNode *>(this)->name_;
if (this->is_function()) {
return fn_->name();
}
return fn_->name();
const DummyNode &dummy_node = *static_cast<const DummyNode *>(this);
if (dummy_node.debug_info_) {
return dummy_node.debug_info_->node_name();
}
return fallback_name;
}
std::string DummyDebugInfo::node_name() const
{
return fallback_name;
}
std::string DummyDebugInfo::input_name(const int /*i*/) const
{
return fallback_name;
}
std::string DummyDebugInfo::output_name(const int /*i*/) const
{
return fallback_name;
}
std::string Graph::to_dot() const
@@ -166,10 +197,11 @@ std::string Graph::to_dot() const
value_string = type.to_string(default_value);
}
else {
value_string = "<" + type.name() + ">";
value_string = type.name();
}
dot::Node &default_value_dot_node = digraph.new_node(value_string);
default_value_dot_node.set_shape(dot::Attr_shape::Ellipse);
default_value_dot_node.attributes.set("color", "#00000055");
digraph.new_edge(default_value_dot_node, to_dot_port);
}
}