@@ -80,6 +80,20 @@ class bNodeTreeZones {
|
||||
*/
|
||||
Vector<const bNodeTreeZone *> get_zone_stack_for_node(const int32_t node_id) const;
|
||||
|
||||
/**
|
||||
* Check if a link from the first zone to a socket in the second zone is allowed. Either zone
|
||||
* input may also be null which represents the root tree outside of any zone. Generally, a link
|
||||
* can only go into zones, but not out of zones.
|
||||
*/
|
||||
bool link_between_zones_is_allowed(const bNodeTreeZone *from_zone,
|
||||
const bNodeTreeZone *to_zone) const;
|
||||
|
||||
/**
|
||||
* Get the ordered list of zones that a link going from an outer to an inner zone has to enter.
|
||||
*/
|
||||
Vector<const bNodeTreeZone *> get_zones_to_enter(const bNodeTreeZone *outer_zone,
|
||||
const bNodeTreeZone *inner_zone) const;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &stream, const bNodeTreeZones &zones);
|
||||
};
|
||||
|
||||
|
||||
@@ -434,6 +434,32 @@ Vector<const bNodeTreeZone *> bNodeTreeZones::get_zone_stack_for_node(const int
|
||||
return zone_stack;
|
||||
}
|
||||
|
||||
bool bNodeTreeZones::link_between_zones_is_allowed(const bNodeTreeZone *from_zone,
|
||||
const bNodeTreeZone *to_zone) const
|
||||
{
|
||||
if (!from_zone) {
|
||||
/* Links from the root tree can go to any zone. */
|
||||
return true;
|
||||
}
|
||||
if (!to_zone) {
|
||||
/* Links can not leave a zone and connect to a socket in the root tree. */
|
||||
return false;
|
||||
}
|
||||
return from_zone->contains_zone_recursively(*to_zone);
|
||||
}
|
||||
|
||||
Vector<const bNodeTreeZone *> bNodeTreeZones::get_zones_to_enter(
|
||||
const bNodeTreeZone *outer_zone, const bNodeTreeZone *inner_zone) const
|
||||
{
|
||||
BLI_assert(this->link_between_zones_is_allowed(outer_zone, inner_zone));
|
||||
Vector<const bNodeTreeZone *> zones_to_enter;
|
||||
for (const bNodeTreeZone *zone = inner_zone; zone != outer_zone; zone = zone->parent_zone) {
|
||||
zones_to_enter.append(zone);
|
||||
}
|
||||
std::reverse(zones_to_enter.begin(), zones_to_enter.end());
|
||||
return zones_to_enter;
|
||||
}
|
||||
|
||||
const bNode *bNodeZoneType::get_corresponding_input(const bNodeTree &tree,
|
||||
const bNode &output_bnode) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user