mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 03:39:42 +00:00
Use unique_ptr to manage Bone lifetime
This commit is contained in:
parent
f393fee9d1
commit
e4f599575e
2 changed files with 6 additions and 17 deletions
|
@ -80,15 +80,16 @@ Bone* Skeleton::getBone(const std::string &name)
|
|||
{
|
||||
if (bone->mChildren[i]->mNode == matrixTransform)
|
||||
{
|
||||
child = bone->mChildren[i];
|
||||
child = bone->mChildren[i].get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!child)
|
||||
if (child == nullptr)
|
||||
{
|
||||
child = new Bone;
|
||||
bone->mChildren.push_back(child);
|
||||
auto childBone = std::make_unique<Bone>();
|
||||
child = childBone.get();
|
||||
bone->mChildren.push_back(std::move(childBone));
|
||||
mNeedToUpdateBoneMatrices = true;
|
||||
}
|
||||
bone = child;
|
||||
|
@ -165,13 +166,6 @@ Bone::Bone()
|
|||
{
|
||||
}
|
||||
|
||||
Bone::~Bone()
|
||||
{
|
||||
for (unsigned int i=0; i<mChildren.size(); ++i)
|
||||
delete mChildren[i];
|
||||
mChildren.clear();
|
||||
}
|
||||
|
||||
void Bone::update(const osg::Matrixf* parentMatrixInSkeletonSpace)
|
||||
{
|
||||
if (!mNode)
|
||||
|
|
|
@ -15,20 +15,15 @@ namespace SceneUtil
|
|||
{
|
||||
public:
|
||||
Bone();
|
||||
~Bone();
|
||||
|
||||
osg::Matrixf mMatrixInSkeletonSpace;
|
||||
|
||||
osg::MatrixTransform* mNode;
|
||||
|
||||
std::vector<Bone*> mChildren;
|
||||
std::vector<std::unique_ptr<Bone>> mChildren;
|
||||
|
||||
/// Update the skeleton-space matrix of this bone and all its children.
|
||||
void update(const osg::Matrixf* parentMatrixInSkeletonSpace);
|
||||
|
||||
private:
|
||||
Bone(const Bone&);
|
||||
void operator=(const Bone&);
|
||||
};
|
||||
|
||||
/// @brief Handles the bone matrices for any number of child RigGeometries.
|
||||
|
|
Loading…
Reference in a new issue