B3DImporter: Store node animations in unique_ptr

pull/1635/head
Turo Lamminen 2017-12-12 19:39:41 +02:00
parent 08a35d4e1f
commit 824dfc314b
2 changed files with 9 additions and 6 deletions

View File

@ -546,7 +546,7 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
node->mParent=parent; node->mParent=parent;
node->mTransformation=tform; node->mTransformation=tform;
aiNodeAnim *nodeAnim=0; std::unique_ptr<aiNodeAnim> nodeAnim;
vector<unsigned> meshes; vector<unsigned> meshes;
vector<aiNode*> children; vector<aiNode*> children;
@ -564,11 +564,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
ReadANIM(); ReadANIM();
}else if( t=="KEYS" ){ }else if( t=="KEYS" ){
if( !nodeAnim ){ if( !nodeAnim ){
nodeAnim=new aiNodeAnim; nodeAnim.reset(new aiNodeAnim);
_nodeAnims.push_back( nodeAnim );
nodeAnim->mNodeName=node->mName; nodeAnim->mNodeName=node->mName;
} }
ReadKEYS( nodeAnim ); ReadKEYS( nodeAnim.get() );
}else if( t=="NODE" ){ }else if( t=="NODE" ){
aiNode *child=ReadNODE( node ); aiNode *child=ReadNODE( node );
children.push_back( child ); children.push_back( child );
@ -576,6 +575,10 @@ aiNode *B3DImporter::ReadNODE( aiNode *parent ){
ExitChunk(); ExitChunk();
} }
if (nodeAnim) {
_nodeAnims.emplace_back( std::move(nodeAnim) );
}
node->mNumMeshes= static_cast<unsigned int>(meshes.size()); node->mNumMeshes= static_cast<unsigned int>(meshes.size());
node->mMeshes=to_array( meshes ); node->mMeshes=to_array( meshes );
@ -716,7 +719,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
aiAnimation *anim = _animations.back().get(); aiAnimation *anim = _animations.back().get();
anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size()); anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size());
anim->mChannels=to_array( _nodeAnims ); anim->mChannels = unique_to_array( _nodeAnims );
scene->mNumAnimations=static_cast<unsigned int>(_animations.size()); scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
scene->mAnimations=unique_to_array( _animations ); scene->mAnimations=unique_to_array( _animations );

View File

@ -124,7 +124,7 @@ private:
std::vector<aiNode*> _nodes; std::vector<aiNode*> _nodes;
std::vector<std::unique_ptr<aiMesh> > _meshes; std::vector<std::unique_ptr<aiMesh> > _meshes;
std::vector<aiNodeAnim*> _nodeAnims; std::vector<std::unique_ptr<aiNodeAnim> > _nodeAnims;
std::vector<std::unique_ptr<aiAnimation> > _animations; std::vector<std::unique_ptr<aiAnimation> > _animations;
}; };