diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d9104199..69c1f620c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -144,6 +144,7 @@ Bug #5159: NiMaterialColorController can only control the diffuse color Bug #5161: Creature companions can't be activated when they are knocked down Bug #5164: Faction owned items handling is incorrect + Bug #5163: UserData is not copied during node cloning Bug #5166: Scripts still should be executed after player's death Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI diff --git a/components/sceneutil/clone.cpp b/components/sceneutil/clone.cpp index d1cca5b31..04fd5d78d 100644 --- a/components/sceneutil/clone.cpp +++ b/components/sceneutil/clone.cpp @@ -6,8 +6,9 @@ #include #include -#include +#include +#include #include namespace SceneUtil @@ -30,6 +31,15 @@ namespace SceneUtil return const_cast(stateset); } + osg::Object* CopyOp::operator ()(const osg::Object* node) const + { + // We should copy node transformations when we copy node + if (const NifOsg::NodeUserData* data = dynamic_cast(node)) + return osg::clone(data, *this); + + return osg::CopyOp::operator()(node); + } + osg::Node* CopyOp::operator ()(const osg::Node* node) const { if (const osgParticle::ParticleProcessor* processor = dynamic_cast(node)) diff --git a/components/sceneutil/clone.hpp b/components/sceneutil/clone.hpp index 662dad543..8a18eeb20 100644 --- a/components/sceneutil/clone.hpp +++ b/components/sceneutil/clone.hpp @@ -32,6 +32,7 @@ namespace SceneUtil virtual osg::Drawable* operator() (const osg::Drawable* drawable) const; virtual osg::StateSet* operator() (const osg::StateSet* stateset) const; + virtual osg::Object* operator ()(const osg::Object* node) const; private: // maps new ParticleProcessor to their old ParticleSystem pointer