B3DImporter: Store animations in unique_ptr
parent
30ae14fae9
commit
acab4c327e
|
@ -93,7 +93,6 @@ void DeleteAllBarePointers(std::vector<T>& x)
|
||||||
|
|
||||||
B3DImporter::~B3DImporter()
|
B3DImporter::~B3DImporter()
|
||||||
{
|
{
|
||||||
DeleteAllBarePointers(_animations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -515,11 +514,11 @@ void B3DImporter::ReadANIM(){
|
||||||
int frames=ReadInt();
|
int frames=ReadInt();
|
||||||
float fps=ReadFloat();
|
float fps=ReadFloat();
|
||||||
|
|
||||||
aiAnimation *anim=new aiAnimation;
|
std::unique_ptr<aiAnimation> anim(new aiAnimation);
|
||||||
_animations.push_back( anim );
|
|
||||||
|
|
||||||
anim->mDuration=frames;
|
anim->mDuration=frames;
|
||||||
anim->mTicksPerSecond=fps;
|
anim->mTicksPerSecond=fps;
|
||||||
|
_animations.emplace_back( std::move(anim) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -601,7 +600,6 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
||||||
|
|
||||||
_nodeAnims.clear();
|
_nodeAnims.clear();
|
||||||
|
|
||||||
DeleteAllBarePointers(_animations);
|
|
||||||
_animations.clear();
|
_animations.clear();
|
||||||
|
|
||||||
string t=ReadChunk();
|
string t=ReadChunk();
|
||||||
|
@ -715,12 +713,12 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
|
||||||
//animations
|
//animations
|
||||||
if( _animations.size()==1 && _nodeAnims.size() ){
|
if( _animations.size()==1 && _nodeAnims.size() ){
|
||||||
|
|
||||||
aiAnimation *anim=_animations.back();
|
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=to_array( _nodeAnims );
|
||||||
|
|
||||||
scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
|
scene->mNumAnimations=static_cast<unsigned int>(_animations.size());
|
||||||
scene->mAnimations=to_array( _animations );
|
scene->mAnimations=unique_to_array( _animations );
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to RH
|
// convert to RH
|
||||||
|
|
|
@ -49,6 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include "BaseImporter.h"
|
#include "BaseImporter.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct aiNodeAnim;
|
struct aiNodeAnim;
|
||||||
|
@ -124,7 +125,7 @@ private:
|
||||||
std::vector<aiNode*> _nodes;
|
std::vector<aiNode*> _nodes;
|
||||||
std::vector<aiMesh*> _meshes;
|
std::vector<aiMesh*> _meshes;
|
||||||
std::vector<aiNodeAnim*> _nodeAnims;
|
std::vector<aiNodeAnim*> _nodeAnims;
|
||||||
std::vector<aiAnimation*> _animations;
|
std::vector<std::unique_ptr<aiAnimation> > _animations;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue