Nodes: debug print for bNodeTreeZones

Pull Request: https://projects.blender.org/blender/blender/pulls/116903
This commit is contained in:
Iliya Katushenock 2024-01-12 13:56:28 +01:00 committed by Jacques Lucke
parent 024e12b53e
commit 23122338cb
2 changed files with 42 additions and 0 deletions

View File

@ -8,6 +8,8 @@
* \ingroup bke
*/
#include <iosfwd>
#include "DNA_node_types.h"
#include "BLI_vector.hh"
@ -42,6 +44,8 @@ class bNodeTreeZone {
bool contains_node_recursively(const bNode &node) const;
bool contains_zone_recursively(const bNodeTreeZone &other_zone) const;
friend std::ostream &operator<<(std::ostream &stream, const bNodeTreeZone &zone);
};
class bNodeTreeZones {
@ -72,6 +76,8 @@ class bNodeTreeZones {
* nested zone. For nodes that are at the root level, the returned list is empty.
*/
Vector<const bNodeTreeZone *> get_zone_stack_for_node(const int32_t node_id) const;
friend std::ostream &operator<<(std::ostream &stream, const bNodeTreeZones &zones);
};
const bNodeTreeZones *get_tree_zones(const bNodeTree &tree);

View File

@ -2,6 +2,8 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include <iostream>
#include "BKE_node.hh"
#include "BKE_node_runtime.hh"
#include "BKE_node_tree_zones.hh"
@ -351,6 +353,7 @@ static std::unique_ptr<bNodeTreeZones> discover_tree_zones(const bNodeTree &tree
update_zone_border_links(tree, *tree_zones);
// std::cout << *tree_zones << std::endl;
return tree_zones;
}
@ -522,4 +525,37 @@ const bNodeZoneType *zone_type_by_node_type(const int node_type)
return nullptr;
}
std::ostream &operator<<(std::ostream &stream, const bNodeTreeZones &zones)
{
for (const std::unique_ptr<bNodeTreeZone> &zone : zones.zones) {
stream << *zone;
if (zones.zones.last().get() != zone.get()) {
stream << "\n";
}
}
return stream;
}
std::ostream &operator<<(std::ostream &stream, const bNodeTreeZone &zone)
{
stream << zone.index << ": Parent index: ";
if (zone.parent_zone != nullptr) {
stream << zone.parent_zone->index;
}
else {
stream << "*";
}
stream << "; Input: " << (zone.input_node ? zone.input_node->name : "null");
stream << ", Output: " << (zone.output_node ? zone.output_node->name : "null");
stream << "; Border Links: {\n";
for (const bNodeLink *border_link : zone.border_links) {
stream << " " << border_link->fromnode->name << ": " << border_link->fromsock->name << " -> ";
stream << border_link->tonode->name << ": " << border_link->tosock->name << ";\n";
}
stream << "}.";
return stream;
}
} // namespace blender::bke