Panda3D
|
This global object records NodePaths that are referenced by scene graph attribs, such as ClipPlaneAttribs and LightAttribs. More...
#include "attribNodeRegistry.h"
Public Member Functions | |
void | add_node (const NodePath &attrib_node) |
Adds the indicated NodePath to the registry. | |
void | clear () |
Removes all nodes from the registry. | |
int | find_node (const NodePath &attrib_node) const |
Returns the index number of the indicated NodePath in the registry (assuming its name hasn't changed since it was recorded in the registry), or -1 if the NodePath cannot be found (for instance, because its name has changed). | |
int | find_node (TypeHandle type, const std::string &name) const |
Returns the index number of the node with the indicated type and name in the registry, or -1 if there is no such node in the registry. | |
NodePath | get_node (int n) const |
std::string | get_node_name (int n) const |
Returns the name of the nth node, as recorded in the registry. | |
TypeHandle | get_node_type (int n) const |
Returns the type of the nth node, as recorded in the registry. | |
int | get_num_nodes () const |
NodePath | lookup_node (const NodePath &orig_node) const |
Looks up the indicated NodePath in the registry. | |
void | output (std::ostream &out) const |
bool | remove_node (const NodePath &attrib_node) |
Removes the indicated NodePath from the registry. | |
void | remove_node (int n) |
Removes the nth node from the registry. | |
void | write (std::ostream &out) const |
Static Public Member Functions | |
static AttribNodeRegistry * | get_global_ptr () |
Public Attributes | |
get_node | |
Returns the nth NodePath recorded in the registry. | |
get_num_nodes | |
Returns the total number of nodes in the registry. | |
This global object records NodePaths that are referenced by scene graph attribs, such as ClipPlaneAttribs and LightAttribs.
Its primary purpose is to unify attribs that are loaded in from bam files. Attrib nodes are identified by name and type; when a bam file that contains references to some attrib nodes is loaded, those nodes are first looked up here in the AttribNodeRegistry. If there is a match (by name and node type), the identified node is used instead of the node referenced within the bam file itself.
Definition at line 33 of file attribNodeRegistry.h.
void AttribNodeRegistry::add_node | ( | const NodePath & | attrib_node | ) |
Adds the indicated NodePath to the registry.
The name and type of the node are noted at the time of this call; if the name changes later, it will not update the registry index.
The NodePath must reference some kind of an attribute node, such as a LightNode or a PlaneNode. When bam files that reference an attribute node of the same type and the same name are loaded, they will quietly be redirected to reference this NodePath.
If there is already a node matching the indicated name and type, it will be replaced.
Definition at line 39 of file attribNodeRegistry.cxx.
References NodePath::is_empty().
void AttribNodeRegistry::clear | ( | ) |
Removes all nodes from the registry.
Definition at line 173 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::clear().
int AttribNodeRegistry::find_node | ( | const NodePath & | attrib_node | ) | const |
Returns the index number of the indicated NodePath in the registry (assuming its name hasn't changed since it was recorded in the registry), or -1 if the NodePath cannot be found (for instance, because its name has changed).
Definition at line 135 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), ordered_vector< Key, Compare, Vector >::end(), and NodePath::is_empty().
Referenced by OccluderEffect::complete_pointers(), ClipPlaneAttrib::finalize(), and LightAttrib::finalize().
int AttribNodeRegistry::find_node | ( | TypeHandle | type, |
const std::string & | name ) const |
Returns the index number of the node with the indicated type and name in the registry, or -1 if there is no such node in the registry.
Definition at line 150 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), and ordered_vector< Key, Compare, Vector >::end().
|
inlinestatic |
Definition at line 17 of file attribNodeRegistry.I.
std::string AttribNodeRegistry::get_node_name | ( | int | n | ) | const |
Returns the name of the nth node, as recorded in the registry.
This will be the node name as it was at the time the node was recorded; if the node has changed names since then, this will still return the original name.
Definition at line 122 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::size().
TypeHandle AttribNodeRegistry::get_node_type | ( | int | n | ) | const |
Returns the type of the nth node, as recorded in the registry.
Definition at line 110 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::size().
Looks up the indicated NodePath in the registry.
If there is a node already in the registry with the matching name and type, returns that NodePath instead; otherwise, returns the original NodePath.
Definition at line 76 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::end(), and NodePath::is_empty().
void AttribNodeRegistry::output | ( | std::ostream & | out | ) | const |
Definition at line 182 of file attribNodeRegistry.cxx.
bool AttribNodeRegistry::remove_node | ( | const NodePath & | attrib_node | ) |
Removes the indicated NodePath from the registry.
The name of the node must not have changed since the matching call to add_node(), or it will not be successfully removed.
Returns true if the NodePath is found and removed, false if it is not found (for instance, because the name has changed).
Definition at line 59 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::end(), and NodePath::is_empty().
void AttribNodeRegistry::remove_node | ( | int | n | ) |
Removes the nth node from the registry.
Definition at line 163 of file attribNodeRegistry.cxx.
References ordered_vector< Key, Compare, Vector >::begin(), and ordered_vector< Key, Compare, Vector >::size().
void AttribNodeRegistry::write | ( | std::ostream & | out | ) | const |
Definition at line 213 of file attribNodeRegistry.cxx.
NodePath AttribNodeRegistry::get_node |
Returns the nth NodePath recorded in the registry.
Definition at line 44 of file attribNodeRegistry.h.
Referenced by OccluderEffect::complete_pointers(), ClipPlaneAttrib::finalize(), and LightAttrib::finalize().
int AttribNodeRegistry::get_num_nodes |
Returns the total number of nodes in the registry.
Definition at line 44 of file attribNodeRegistry.h.