From 89659d9e78ef0c91caea535afce2981001ef03cc Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 30 Aug 2003 22:11:50 +0000 Subject: [PATCH] add get_sort() --- panda/src/pgraph/nodePath.cxx | 23 +++++++++++++++++++++++ panda/src/pgraph/nodePath.h | 1 + 2 files changed, 24 insertions(+) diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 71802b49a1..2ecef422fd 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -168,6 +168,29 @@ get_stashed_children() const { return result; } +//////////////////////////////////////////////////////////////////// +// Function: NodePath::get_sort +// Access: Published +// Description: Returns the sort value of the referenced node within +// its parent; that is, the sort number passed on the +// last reparenting operation for this node. This will +// control the position of the node within its parent's +// list of children. +//////////////////////////////////////////////////////////////////// +int NodePath:: +get_sort() const { + if (!has_parent()) { + return 0; + } + PandaNode *parent = _head->get_next()->get_node(); + PandaNode *child = node(); + nassertr(parent != (PandaNode *)NULL && child != (PandaNode *)NULL, 0); + int child_index = parent->find_child(child); + nassertr(child_index != -1, 0); + + return parent->get_child_sort(child_index); +} + //////////////////////////////////////////////////////////////////// // Function: NodePath::find // Access: Published diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index bac8a69ddc..268cac3cef 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -186,6 +186,7 @@ PUBLISHED: INLINE bool has_parent() const; INLINE NodePath get_parent() const; + int get_sort() const; NodePath find(const string &path) const; NodePath find_path_to(PandaNode *node) const;