mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
add get_net_tag(), etc.
This commit is contained in:
parent
62a3e02bb6
commit
8748cad750
@ -326,7 +326,9 @@ has_parent() const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE NodePath NodePath::
|
||||
get_parent() const {
|
||||
nassertr(has_parent(), NodePath::fail());
|
||||
if (!has_parent()) {
|
||||
return NodePath::fail();
|
||||
}
|
||||
NodePath parent;
|
||||
parent._head = _head->get_next();
|
||||
return parent;
|
||||
@ -1149,11 +1151,15 @@ set_tag(const string &key, const string &value) {
|
||||
// Description: Retrieves the user-defined value that was previously
|
||||
// set on this node for the particular key, if any. If
|
||||
// no value has been previously set, returns the empty
|
||||
// string.
|
||||
// string. See also get_net_tag().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE string NodePath::
|
||||
get_tag(const string &key) const {
|
||||
nassertr_always(!is_empty(), string());
|
||||
// An empty NodePath quietly returns no tags. This makes
|
||||
// get_net_tag() easier to implement.
|
||||
if (is_empty()) {
|
||||
return string();
|
||||
}
|
||||
return node()->get_tag(key);
|
||||
}
|
||||
|
||||
@ -1163,10 +1169,15 @@ get_tag(const string &key) const {
|
||||
// Description: Returns true if a value has been defined on this node
|
||||
// for the particular key (even if that value is the
|
||||
// empty string), or false if no value has been set.
|
||||
// See also has_net_tag().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool NodePath::
|
||||
has_tag(const string &key) const {
|
||||
nassertr_always(!is_empty(), false);
|
||||
// An empty NodePath quietly has no tags. This makes has_net_tag()
|
||||
// easier to implement.
|
||||
if (is_empty()) {
|
||||
return false;
|
||||
}
|
||||
return node()->has_tag(key);
|
||||
}
|
||||
|
||||
@ -1183,6 +1194,32 @@ clear_tag(const string &key) {
|
||||
node()->clear_tag(key);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::get_net_tag
|
||||
// Access: Published
|
||||
// Description: Returns the tag value that has been defined on this
|
||||
// node, or the nearest ancestor node, for the indicated
|
||||
// key. If no value has been defined for the indicated
|
||||
// key on any ancestor node, returns the empty string.
|
||||
// See also get_tag().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE string NodePath::
|
||||
get_net_tag(const string &key) const {
|
||||
return find_net_tag(key).get_tag(key);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::has_net_tag
|
||||
// Access: Published
|
||||
// Description: Returns true if the indicated tag value has been
|
||||
// defined on this node or on any ancestor node, or
|
||||
// false otherwise. See also has_tag().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool NodePath::
|
||||
has_net_tag(const string &key) const {
|
||||
return find_net_tag(key).has_tag(key);
|
||||
}
|
||||
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const NodePath &node_path) {
|
||||
node_path.output(out);
|
||||
|
@ -2936,6 +2936,25 @@ flatten_strong() {
|
||||
return num_removed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::find_net_tag
|
||||
// Access: Published
|
||||
// Description: Returns the lowest ancestor of this node that
|
||||
// contains a tag definition with the indicated key, if
|
||||
// any, or an empty NodePath if no ancestor of this node
|
||||
// contains this tag definition. See set_tag().
|
||||
////////////////////////////////////////////////////////////////////
|
||||
NodePath NodePath::
|
||||
find_net_tag(const string &key) const {
|
||||
if (is_empty()) {
|
||||
return NodePath::not_found();
|
||||
}
|
||||
if (has_tag(key)) {
|
||||
return *this;
|
||||
}
|
||||
return get_parent().find_net_tag(key);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::write_bam_file
|
||||
// Access: Published
|
||||
|
@ -523,6 +523,9 @@ PUBLISHED:
|
||||
INLINE string get_tag(const string &key) const;
|
||||
INLINE bool has_tag(const string &key) const;
|
||||
INLINE void clear_tag(const string &key);
|
||||
INLINE string get_net_tag(const string &key) const;
|
||||
INLINE bool has_net_tag(const string &key) const;
|
||||
NodePath find_net_tag(const string &key) const;
|
||||
|
||||
bool write_bam_file(const string &filename) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user