B3DImporter: Store animations in unique_ptr

pull/1635/head
Turo Lamminen 2017-12-12 18:42:14 +02:00
parent 30ae14fae9
commit acab4c327e
2 changed files with 6 additions and 7 deletions

View File

@ -93,7 +93,6 @@ void DeleteAllBarePointers(std::vector<T>& x)
B3DImporter::~B3DImporter()
{
DeleteAllBarePointers(_animations);
}
// ------------------------------------------------------------------------------------------------
@ -515,11 +514,11 @@ void B3DImporter::ReadANIM(){
int frames=ReadInt();
float fps=ReadFloat();
aiAnimation *anim=new aiAnimation;
_animations.push_back( anim );
std::unique_ptr<aiAnimation> anim(new aiAnimation);
anim->mDuration=frames;
anim->mTicksPerSecond=fps;
_animations.emplace_back( std::move(anim) );
}
// ------------------------------------------------------------------------------------------------
@ -601,7 +600,6 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
_nodeAnims.clear();
DeleteAllBarePointers(_animations);
_animations.clear();
string t=ReadChunk();
@ -715,12 +713,12 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
//animations
if( _animations.size()==1 && _nodeAnims.size() ){
aiAnimation *anim=_animations.back();
aiAnimation *anim = _animations.back().get();
anim->mNumChannels=static_cast<unsigned int>(_nodeAnims.size());
anim->mChannels=to_array( _nodeAnims );
scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
scene->mAnimations=to_array( _animations );
scene->mAnimations=unique_to_array( _animations );
}
// convert to RH

View File

@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h>
#include "BaseImporter.h"
#include <memory>
#include <vector>
struct aiNodeAnim;
@ -124,7 +125,7 @@ private:
std::vector<aiNode*> _nodes;
std::vector<aiMesh*> _meshes;
std::vector<aiNodeAnim*> _nodeAnims;
std::vector<aiAnimation*> _animations;
std::vector<std::unique_ptr<aiAnimation> > _animations;
};
}