|
|
@@ -477,7 +477,7 @@ protected:
|
|
|
*
|
|
|
* @return Pointer to the newly created node.
|
|
|
*/
|
|
|
- virtual Node* cloneSingleNode(CloneContext &context) const;
|
|
|
+ virtual Node* cloneSingleNode(NodeCloneContext &context) const;
|
|
|
|
|
|
/**
|
|
|
* Recursively clones this node and its children.
|
|
|
@@ -486,7 +486,7 @@ protected:
|
|
|
*
|
|
|
* @return The newly created node.
|
|
|
*/
|
|
|
- Node* cloneRecursive(CloneContext &context) const;
|
|
|
+ Node* cloneRecursive(NodeCloneContext &context) const;
|
|
|
|
|
|
/**
|
|
|
* Copies the data from this node into the given node.
|
|
|
@@ -494,7 +494,7 @@ protected:
|
|
|
* @param node The node to copy the data to.
|
|
|
* @param context The clone context.
|
|
|
*/
|
|
|
- void cloneInto(Node* node, CloneContext &context) const;
|
|
|
+ void cloneInto(Node* node, NodeCloneContext &context) const;
|
|
|
|
|
|
/**
|
|
|
* Removes this node from its parent.
|
|
|
@@ -550,6 +550,79 @@ protected:
|
|
|
mutable BoundingSphere _bounds;
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * NodeCloneContext represents the context data that is kept when cloning a node.
|
|
|
+ *
|
|
|
+ * The NodeCloneContext is used to make sure objects don't get cloned twice.
|
|
|
+ */
|
|
|
+class NodeCloneContext
|
|
|
+{
|
|
|
+public:
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Constructor.
|
|
|
+ */
|
|
|
+ NodeCloneContext();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Destructor.
|
|
|
+ */
|
|
|
+ ~NodeCloneContext();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Finds the cloned animation of the given animation or NULL if this animation was not registered with this context.
|
|
|
+ *
|
|
|
+ * @param animation The animation to search for the cloned copy of.
|
|
|
+ *
|
|
|
+ * @return The cloned animation or NULL if not found.
|
|
|
+ */
|
|
|
+ Animation* findClonedAnimation(const Animation* animation);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Registers the cloned animation with this context so that it doesn't get cloned twice.
|
|
|
+ *
|
|
|
+ * @param original The pointer to the original animation.
|
|
|
+ * @param clone The pointer to the cloned animation.
|
|
|
+ */
|
|
|
+ void registerClonedAnimation(const Animation* original, Animation* clone);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Finds the cloned node of the given node or NULL if this node was not registered with this context.
|
|
|
+ *
|
|
|
+ * @param node The node to search for the cloned copy of.
|
|
|
+ *
|
|
|
+ * @return The cloned node or NULL if not found.
|
|
|
+ */
|
|
|
+ Node* findClonedNode(const Node* node);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Registers the cloned node with this context so that it doens't get cloned twice.
|
|
|
+ *
|
|
|
+ * @param original The pointer to the original node.
|
|
|
+ * @param clone The pointer to the cloned node.
|
|
|
+ */
|
|
|
+ void registerClonedNode(const Node* original, Node* clone);
|
|
|
+
|
|
|
+private:
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Hidden copy constructor.
|
|
|
+ */
|
|
|
+ NodeCloneContext(const NodeCloneContext&);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Hidden copy assignment operator.
|
|
|
+ */
|
|
|
+ NodeCloneContext& operator=(const NodeCloneContext&);
|
|
|
+
|
|
|
+private:
|
|
|
+ typedef std::map<const Animation*, Animation*> AnimationMap;
|
|
|
+ typedef std::map<const Node*, Node*> NodeMap;
|
|
|
+
|
|
|
+ AnimationMap _clonedAnimations;
|
|
|
+ NodeMap _clonedNodes;
|
|
|
+};
|
|
|
+
|
|
|
}
|
|
|
|
|
|
#endif
|