24 void DataGraphTraverser::CollectedData::
26 if ((
int)_data.size() <= parent_index) {
27 _data.reserve(parent_index + 1);
28 while ((
int)_data.size() <= parent_index) {
33 nassertv(parent_index >= 0 && parent_index < (
int)_data.size());
34 _data[parent_index] = data;
41 DataGraphTraverser(
Thread *current_thread) : _current_thread(current_thread) {
48 ~DataGraphTraverser() {
56 if (node->
is_of_type(DataNode::get_class_type())) {
61 r_transmit(data_node,
nullptr);
80 for (
int i = 0; i < num_children; i++) {
82 if (child_node->
is_of_type(DataNode::get_class_type())) {
87 if (num_parents == 1) {
90 r_transmit(data_node, &output);
95 CollectedData &collected_data = _multipass_data[data_node];
96 int parent_index = data_node->
find_parent(node, _current_thread);
97 nassertv(parent_index != -1);
99 collected_data.set_data(parent_index, output);
100 collected_data._num_parents++;
101 nassertv(collected_data._num_parents <= num_parents);
102 if (collected_data._num_parents == num_parents) {
104 r_transmit(data_node, &collected_data._data[0]);
105 _multipass_data.erase(data_node);
127 while (!_multipass_data.empty()) {
128 MultipassData::iterator mi = _multipass_data.begin();
130 const CollectedData &collected_data = (*mi).second;
133 << *data_node <<
" improperly parented partly outside of data graph.\n";
135 r_transmit(data_node, &collected_data._data[0]);
136 _multipass_data.erase(mi);
145 void DataGraphTraverser::
A basic node of the scene graph or data graph.
int get_num_outputs() const
Returns the number of different outputs that have been defined for this node using define_output().
The fundamental type of node for the data graph.
void collect_leftovers()
Pick up any nodes that didn't get completely traversed.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PandaNode * get_child(size_t n) const
Returns the nth child of the node.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_num_parents
Returns the number of parent nodes this node has.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void traverse_below(PandaNode *node, const DataNodeTransmit &output)
Continues the traversal to all the children of the indicated node, passing in the given data,...
void reserve(int num_wires)
Tells the DataNodeTransmit object how many wires it is expected to store data for.
size_t get_num_children() const
Returns the number of children of the node.
int find_parent(PandaNode *node, Thread *current_thread=Thread::get_current_thread()) const
Returns the index of the indicated parent node, if it is a parent, or -1 if it is not.
get_children
Returns an object that can be used to walk through the list of children of the node.
A thread; that is, a lightweight process.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
void transmit_data(DataGraphTraverser *trav, const DataNodeTransmit inputs[], DataNodeTransmit &output)
Collects the data from all of the parent nodes and puts it into one DataNodeTransmit object,...
Encapsulates the data generated from (or sent into) any particular DataNode.
void traverse(PandaNode *node)
Starts the traversal of the data graph at the indicated root node.