diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 0e27baf36b..a9943eb504 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -41,6 +41,7 @@ NodePath(const string &top_node_name) : { PandaNode *top_node = new PandaNode(top_node_name); _head = top_node->get_generic_component(false); + _backup_key = 0; } //////////////////////////////////////////////////////////////////// @@ -61,6 +62,7 @@ NodePath(PandaNode *node) : if (node != (PandaNode *)NULL) { _head = node->get_generic_component(false); } + _backup_key = 0; } //////////////////////////////////////////////////////////////////// @@ -100,6 +102,7 @@ NodePath(const NodePath &parent, PandaNode *child_node) : if (_head != (NodePathComponent *)NULL) { _error_type = ET_ok; } + _backup_key = 0; } //////////////////////////////////////////////////////////////////// @@ -110,6 +113,7 @@ NodePath(const NodePath &parent, PandaNode *child_node) : INLINE NodePath:: NodePath(const NodePath ©) : _head(copy._head), + _backup_key(copy._backup_key), _error_type(copy._error_type) { } @@ -122,6 +126,7 @@ NodePath(const NodePath ©) : INLINE void NodePath:: operator = (const NodePath ©) { _head = copy._head; + _backup_key = copy._backup_key; _error_type = copy._error_type; } @@ -266,7 +271,7 @@ node() const { INLINE int NodePath:: get_key() const { if (is_empty()) { - return 0; + return _backup_key; } return _head->get_key(); } diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index a3c9bafd11..98e4af8cd0 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -473,7 +473,16 @@ remove_node() { PandaNode::detach(_head); } - (*this) = NodePath::removed(); + if (is_empty() || _head->has_key()) { + // Preserve the key we had on the node before we removed it. + int key = get_key(); + (*this) = NodePath::removed(); + _backup_key = key; + + } else { + // We didn't have a key; just clear the NodePath. + (*this) = NodePath::removed(); + } } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 5b2f2ac8e5..5e881dc739 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -111,8 +111,13 @@ class GlobPattern; // +h Do return hidden nodes. // -s Do not return stashed nodes unless explicitly referenced with @@. // +s Return stashed nodes even without any explicit @@ characters. +// -i Node name comparisons are not case insensitive: case must match +// exactly. +// +i Node name comparisons are case insensitive: case is not important. +// This affects matches against the node name only; node type +// and tag strings are always case sensitive. // -// The default flags are +h-s. +// The default flags are +h-s-i. // @@ -630,6 +635,7 @@ private: GraphicsStateGuardianBase *gsg, bool do_retained_mode); PT(NodePathComponent) _head; + int _backup_key; ErrorType _error_type; static int _max_search_depth; diff --git a/panda/src/pgraph/nodePathComponent.I b/panda/src/pgraph/nodePathComponent.I index 817a201c65..ea58494db6 100644 --- a/panda/src/pgraph/nodePathComponent.I +++ b/panda/src/pgraph/nodePathComponent.I @@ -105,6 +105,20 @@ get_node() const { return _node; } +//////////////////////////////////////////////////////////////////// +// Function: NodePathComponent::has_key +// Access: Public +// Description: Returns true if the key for this component has +// already been generated, false otherwise. Even if +// this returns false, calling get_key() will still +// return a valid key; that will simply cause the key to +// be generated on-the-fly. +//////////////////////////////////////////////////////////////////// +INLINE bool NodePathComponent:: +has_key() const { + return (_key != 0); +} + INLINE ostream &operator << (ostream &out, const NodePathComponent &comp) { comp.output(out); return out; diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index 9fff260a93..78280542d4 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -54,6 +54,7 @@ public: INLINE ~NodePathComponent(); INLINE PandaNode *get_node() const; + INLINE bool has_key() const; int get_key() const; bool is_top_node() const;