From ddd3f7048b8441303e38cda60ce2e86f55c8f1ad Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 20 Mar 2002 16:30:12 +0000 Subject: [PATCH] instanceUnderNode --- panda/src/pgraph/qpnodePath.cxx | 21 ++++++++++++++++----- panda/src/pgraph/qpnodePath.h | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/panda/src/pgraph/qpnodePath.cxx b/panda/src/pgraph/qpnodePath.cxx index 454568b4e5..89d22f5014 100644 --- a/panda/src/pgraph/qpnodePath.cxx +++ b/panda/src/pgraph/qpnodePath.cxx @@ -267,6 +267,22 @@ instance_to(const qpNodePath &other, int sort) const { return new_instance; } +//////////////////////////////////////////////////////////////////// +// Function: qpNodePath::instance_under_node +// Access: Published +// Description: Behaves like instance_to(), but implicitly creates a +// new node to instance the geometry under, and returns a +// NodePath to that new node. This allows the +// programmer to set a unique state and/or transform on +// this instance. +//////////////////////////////////////////////////////////////////// +qpNodePath qpNodePath:: +instance_under_node(const qpNodePath &other, const string &name, int sort) const { + qpNodePath new_node = other.attach_new_node(name, sort); + instance_to(new_node); + return new_node; +} + //////////////////////////////////////////////////////////////////// // Function: qpNodePath::copy_to // Access: Published @@ -275,11 +291,6 @@ instance_to(const qpNodePath &other, int sort) const { // descendents, which is then parented to the indicated // node. A qpNodePath to the newly created copy is // returned. -// -// Certain kinds of nodes (like a Camera, for instance, -// whose pointer value is important) may not be copied; -// if one of these is encountered, the node will be -// instanced, instead of actually copied. //////////////////////////////////////////////////////////////////// qpNodePath qpNodePath:: copy_to(const qpNodePath &other, int sort) const { diff --git a/panda/src/pgraph/qpnodePath.h b/panda/src/pgraph/qpnodePath.h index dd0d366704..79084c16e4 100644 --- a/panda/src/pgraph/qpnodePath.h +++ b/panda/src/pgraph/qpnodePath.h @@ -196,6 +196,8 @@ PUBLISHED: void reparent_to(const qpNodePath &other, int sort = 0); void wrt_reparent_to(const qpNodePath &other, int sort = 0); qpNodePath instance_to(const qpNodePath &other, int sort = 0) const; + qpNodePath instance_under_node(const qpNodePath &other, const string &name, + int sort = 0) const; qpNodePath copy_to(const qpNodePath &other, int sort = 0) const; qpNodePath attach_new_node(PandaNode *node, int sort = 0) const; INLINE qpNodePath attach_new_node(const string &name, int sort = 0) const;