mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fix NodePath sorting
This commit is contained in:
parent
0e369940cf
commit
f9b2d69d64
@ -1241,32 +1241,6 @@ operator < (const NodePath &other) const {
|
|||||||
return (compare_to(other) < 0);
|
return (compare_to(other) < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: NodePath::compare_to
|
|
||||||
// Access: Published
|
|
||||||
// Description: Returns a number less than zero if this NodePath
|
|
||||||
// sorts before the other one, greater than zero if it
|
|
||||||
// sorts after, or zero if they are equivalent.
|
|
||||||
//
|
|
||||||
// Two NodePaths are considered equivalent if they
|
|
||||||
// consist of exactly the same list of nodes in the same
|
|
||||||
// order. Otherwise, they are different; different
|
|
||||||
// NodePaths will be ranked in a consistent but
|
|
||||||
// undefined ordering; the ordering is useful only for
|
|
||||||
// placing the NodePaths in a sorted container like an
|
|
||||||
// STL set.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE int NodePath::
|
|
||||||
compare_to(const NodePath &other) const {
|
|
||||||
uncollapse_head();
|
|
||||||
other.uncollapse_head();
|
|
||||||
|
|
||||||
// Nowadays, the NodePathComponents at the head are pointerwise
|
|
||||||
// equivalent if and only if the NodePaths are equivalent. So we
|
|
||||||
// only have to compare pointers.
|
|
||||||
return _head - other._head;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::set_tag
|
// Function: NodePath::set_tag
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -3057,6 +3057,35 @@ get_stashed_ancestor() const {
|
|||||||
return not_found();
|
return not_found();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: NodePath::compare_to
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns a number less than zero if this NodePath
|
||||||
|
// sorts before the other one, greater than zero if it
|
||||||
|
// sorts after, or zero if they are equivalent.
|
||||||
|
//
|
||||||
|
// Two NodePaths are considered equivalent if they
|
||||||
|
// consist of exactly the same list of nodes in the same
|
||||||
|
// order. Otherwise, they are different; different
|
||||||
|
// NodePaths will be ranked in a consistent but
|
||||||
|
// undefined ordering; the ordering is useful only for
|
||||||
|
// placing the NodePaths in a sorted container like an
|
||||||
|
// STL set.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
int NodePath::
|
||||||
|
compare_to(const NodePath &other) const {
|
||||||
|
uncollapse_head();
|
||||||
|
other.uncollapse_head();
|
||||||
|
|
||||||
|
// Nowadays, the NodePathComponents at the head are pointerwise
|
||||||
|
// equivalent if and only if the NodePaths are equivalent. So we
|
||||||
|
// only have to compare pointers.
|
||||||
|
if (_head != other._head) {
|
||||||
|
return _head < other._head ? -1 : 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: NodePath::verify_complete
|
// Function: NodePath::verify_complete
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -561,7 +561,7 @@ PUBLISHED:
|
|||||||
INLINE bool operator == (const NodePath &other) const;
|
INLINE bool operator == (const NodePath &other) const;
|
||||||
INLINE bool operator != (const NodePath &other) const;
|
INLINE bool operator != (const NodePath &other) const;
|
||||||
INLINE bool operator < (const NodePath &other) const;
|
INLINE bool operator < (const NodePath &other) const;
|
||||||
INLINE int compare_to(const NodePath &other) const;
|
int compare_to(const NodePath &other) const;
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
bool verify_complete() const;
|
bool verify_complete() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user