add get_stashed_children()

This commit is contained in:
David Rose 2003-06-09 22:41:43 +00:00
parent 1fee5c727e
commit 03c1c844ea
2 changed files with 43 additions and 7 deletions

View File

@ -144,6 +144,31 @@ get_children() const {
return result;
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::get_stashed_children
// Access: Published
// Description: Returns the set of all child nodes of the referenced
// node that have been stashed. These children are not
// normally visible on the node, and do not appear in
// the list returned by get_children().
////////////////////////////////////////////////////////////////////
NodePathCollection NodePath::
get_stashed_children() const {
NodePathCollection result;
nassertr_always(!is_empty(), result);
PandaNode *bottom_node = node();
int num_stashed = bottom_node->get_num_stashed();
for (int i = 0; i < num_stashed; i++) {
NodePath stashed;
stashed._head = PandaNode::get_component(_head, bottom_node->get_stashed(i));
result.add_path(stashed);
}
return result;
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::find
// Access: Published
@ -377,11 +402,16 @@ attach_new_node(PandaNode *node, int sort) const {
// Normally, this should be called only when you are
// really done with the node. If you want to remove a
// node from the scene graph but keep it around for
// later, you should probably use reparent_to() and put
// it under a holding node instead.
// later, you should probably use detach_node() instead.
//
// After the node is removed, the NodePath will have
// been cleared.
// In practice, the only difference between
// remove_node() and detach_node() is that remove_node()
// also resets the NodePath to empty, which will cause
// the node to be deleted immediately if there are no
// other references. On the other hand, detach_node()
// leaves the NodePath referencing the node, which will
// keep at least one reference to the node for as long
// as the NodePath exists.
////////////////////////////////////////////////////////////////////
void NodePath::
remove_node() {
@ -409,9 +439,14 @@ remove_node() {
// NodePath; otherwise, this NodePath becomes the same
// as another arbitrary instance.
//
// If the NodePath later goes out of scope or is
// reassigned to something else, this will have the same
// effect as remove_node().
// In practice, the only difference between
// remove_node() and detach_node() is that remove_node()
// also resets the NodePath to empty, which will cause
// the node to be deleted immediately if there are no
// other references. On the other hand, detach_node()
// leaves the NodePath referencing the node, which will
// keep at least one reference to the node for as long
// as the NodePath exists.
////////////////////////////////////////////////////////////////////
void NodePath::
detach_node() {

View File

@ -182,6 +182,7 @@ PUBLISHED:
NodePathCollection get_children() const;
INLINE int get_num_children() const;
INLINE NodePath get_child(int n) const;
NodePathCollection get_stashed_children() const;
INLINE bool has_parent() const;
INLINE NodePath get_parent() const;