mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add count_num_descendants()
This commit is contained in:
parent
2144050758
commit
8566b388fb
@ -392,6 +392,19 @@ get_child(int n, Thread *current_thread) const {
|
||||
return child;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::count_num_descendants
|
||||
// Access: Published
|
||||
// Description: Returns the number of nodes at and below this level.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int NodePath::
|
||||
count_num_descendants() const {
|
||||
if (is_empty()) {
|
||||
return 0;
|
||||
}
|
||||
return _head->get_node()->count_num_descendants();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::has_parent
|
||||
// Access: Published
|
||||
|
@ -206,6 +206,8 @@ PUBLISHED:
|
||||
INLINE NodePath get_child(int n, Thread *current_thread = Thread::get_current_thread()) const;
|
||||
NodePathCollection get_stashed_children(Thread *current_thread = Thread::get_current_thread()) const;
|
||||
|
||||
INLINE int count_num_descendants() const;
|
||||
|
||||
INLINE bool has_parent(Thread *current_thread = Thread::get_current_thread()) const;
|
||||
INLINE NodePath get_parent(Thread *current_thread = Thread::get_current_thread()) const;
|
||||
int get_sort(Thread *current_thread = Thread::get_current_thread()) const;
|
||||
|
@ -572,6 +572,25 @@ copy_subgraph(Thread *current_thread) const {
|
||||
return r_copy_subgraph(inst_map, current_thread);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PandaNode::count_num_descendants
|
||||
// Access: Published
|
||||
// Description: Returns the number of nodes at and below this level.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int PandaNode::
|
||||
count_num_descendants() const {
|
||||
int count = 1;
|
||||
Children children = get_children();
|
||||
int num_children = children.get_num_children();
|
||||
|
||||
for (int i = 0; i < num_children; ++i) {
|
||||
PandaNode *child = children.get_child(i);
|
||||
count += child->count_num_descendants();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PandaNode::add_child
|
||||
// Access: Published
|
||||
|
@ -124,6 +124,8 @@ PUBLISHED:
|
||||
INLINE int get_child_sort(int n, Thread *current_thread = Thread::get_current_thread()) const;
|
||||
INLINE int find_child(PandaNode *node, Thread *current_thread = Thread::get_current_thread()) const;
|
||||
|
||||
int count_num_descendants() const;
|
||||
|
||||
void add_child(PandaNode *child_node, int sort = 0,
|
||||
Thread *current_thread = Thread::get_current_thread());
|
||||
void remove_child(int child_index, Thread *current_thread = Thread::get_current_thread());
|
||||
|
Loading…
x
Reference in New Issue
Block a user