Panda3D
Public Member Functions | Public Attributes | List of all members
WorkingNodePath Class Reference

This is a class designed to support low-overhead traversals of the complete scene graph, with a memory of the complete path through the graph at any given point. More...

#include "workingNodePath.h"

Public Member Functions

 WorkingNodePath (const NodePath &start)
 Creates a WorkingNodePath that is the same as the indicated NodePath. More...
 
 WorkingNodePath (const WorkingNodePath &copy)
 
 WorkingNodePath (const WorkingNodePath &parent, PandaNode *child)
 Creates a WorkingNodePath that is the same as the indicated WorkingNodePath, plus one node. More...
 
PandaNodeget_node (int index) const
 Returns the nth node of the path, where 0 is the referenced (bottom) node and get_num_nodes() - 1 is the top node. More...
 
NodePath get_node_path () const
 
int get_num_nodes () const
 Returns the number of nodes in the path from the root to the current node. More...
 
bool is_valid () const
 
PandaNodenode () const
 Returns the node traversed to so far. More...
 
void operator= (const WorkingNodePath &copy)
 
void output (std::ostream &out) const
 

Public Attributes

 get_node_path
 Constructs and returns an actual NodePath that represents the same path we have just traversed. More...
 
 is_valid
 Returns true if the WorkingNodePath object appears to be a valid NodePath reference, false otherwise. More...
 

Detailed Description

This is a class designed to support low-overhead traversals of the complete scene graph, with a memory of the complete path through the graph at any given point.

You could just use a regular NodePath to do this, but since the NodePath requires storing NodePathComponents on each node as it is constructed, and then removing them when it destructs, there is considerable overhead in that approach.

The WorkingNodePath eliminates this overhead (but does not guarantee consistency if the scene graph changes while the path is held).

At any given point, you may ask the WorkingNodePath for its actual NodePath, and it will construct and return a new NodePath representing the complete generated chain.

Definition at line 39 of file workingNodePath.h.

Constructor & Destructor Documentation

◆ WorkingNodePath() [1/2]

WorkingNodePath::WorkingNodePath ( const NodePath start)
inline

Creates a WorkingNodePath that is the same as the indicated NodePath.

This is generally used to begin the traversal of a scene graph with the root NodePath.

Definition at line 20 of file workingNodePath.I.

◆ WorkingNodePath() [2/2]

WorkingNodePath::WorkingNodePath ( const WorkingNodePath parent,
PandaNode child 
)
inline

Creates a WorkingNodePath that is the same as the indicated WorkingNodePath, plus one node.

This is generally used to continue the traversal to the next node.

Definition at line 46 of file workingNodePath.I.

Member Function Documentation

◆ get_node()

PandaNode * WorkingNodePath::get_node ( int  index) const

Returns the nth node of the path, where 0 is the referenced (bottom) node and get_num_nodes() - 1 is the top node.

This requires iterating through the path.

Definition at line 57 of file workingNodePath.cxx.

◆ get_num_nodes()

int WorkingNodePath::get_num_nodes ( ) const

Returns the number of nodes in the path from the root to the current node.

Since a WorkingNodePath always consists of, at minimum, a nonempty parent NodePath and one child node, this method will always return at least 2.

Definition at line 41 of file workingNodePath.cxx.

◆ node()

PandaNode * WorkingNodePath::node ( ) const
inline

Returns the node traversed to so far.

Definition at line 89 of file workingNodePath.I.

Referenced by FindApproxLevelEntry::consider_node(), and CollisionLevelStateBase::node().

Member Data Documentation

◆ get_node_path

NodePath WorkingNodePath::get_node_path
inline

Constructs and returns an actual NodePath that represents the same path we have just traversed.

Definition at line 60 of file workingNodePath.h.

Referenced by FindApproxLevelEntry::consider_node(), and CollisionLevelStateBase::get_node_path().

◆ is_valid

bool WorkingNodePath::is_valid

Returns true if the WorkingNodePath object appears to be a valid NodePath reference, false otherwise.

Definition at line 59 of file workingNodePath.h.


The documentation for this class was generated from the following files: