diff --git a/code/B3DImporter.cpp b/code/B3DImporter.cpp index 195ee04a8..dd7b0d95e 100644 --- a/code/B3DImporter.cpp +++ b/code/B3DImporter.cpp @@ -546,7 +546,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ node->mParent=parent; node->mTransformation=tform; - aiNodeAnim *nodeAnim=0; + std::unique_ptr nodeAnim; vector meshes; vector children; @@ -564,11 +564,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ ReadANIM(); }else if( t=="KEYS" ){ if( !nodeAnim ){ - nodeAnim=new aiNodeAnim; - _nodeAnims.push_back( nodeAnim ); + nodeAnim.reset(new aiNodeAnim); nodeAnim->mNodeName=node->mName; } - ReadKEYS( nodeAnim ); + ReadKEYS( nodeAnim.get() ); }else if( t=="NODE" ){ aiNode *child=ReadNODE( node ); children.push_back( child ); @@ -576,6 +575,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){ ExitChunk(); } + if (nodeAnim) { + _nodeAnims.emplace_back( std::move(nodeAnim) ); + } + node->mNumMeshes= static_cast(meshes.size()); node->mMeshes=to_array( meshes ); @@ -716,7 +719,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){ aiAnimation *anim = _animations.back().get(); anim->mNumChannels=static_cast(_nodeAnims.size()); - anim->mChannels=to_array( _nodeAnims ); + anim->mChannels = unique_to_array( _nodeAnims ); scene->mNumAnimations=static_cast(_animations.size()); scene->mAnimations=unique_to_array( _animations ); diff --git a/code/B3DImporter.h b/code/B3DImporter.h index f9645f594..342b88a28 100644 --- a/code/B3DImporter.h +++ b/code/B3DImporter.h @@ -124,7 +124,7 @@ private: std::vector _nodes; std::vector > _meshes; - std::vector _nodeAnims; + std::vector > _nodeAnims; std::vector > _animations; };