mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 07:09:41 +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)
|
if (bone->mChildren[i]->mNode == matrixTransform)
|
||||||
{
|
{
|
||||||
child = bone->mChildren[i];
|
child = bone->mChildren[i].get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!child)
|
if (child == nullptr)
|
||||||
{
|
{
|
||||||
child = new Bone;
|
auto childBone = std::make_unique<Bone>();
|
||||||
bone->mChildren.push_back(child);
|
child = childBone.get();
|
||||||
|
bone->mChildren.push_back(std::move(childBone));
|
||||||
mNeedToUpdateBoneMatrices = true;
|
mNeedToUpdateBoneMatrices = true;
|
||||||
}
|
}
|
||||||
bone = child;
|
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)
|
void Bone::update(const osg::Matrixf* parentMatrixInSkeletonSpace)
|
||||||
{
|
{
|
||||||
if (!mNode)
|
if (!mNode)
|
||||||
|
|
|
@ -15,20 +15,15 @@ namespace SceneUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Bone();
|
Bone();
|
||||||
~Bone();
|
|
||||||
|
|
||||||
osg::Matrixf mMatrixInSkeletonSpace;
|
osg::Matrixf mMatrixInSkeletonSpace;
|
||||||
|
|
||||||
osg::MatrixTransform* mNode;
|
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.
|
/// Update the skeleton-space matrix of this bone and all its children.
|
||||||
void update(const osg::Matrixf* parentMatrixInSkeletonSpace);
|
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.
|
/// @brief Handles the bone matrices for any number of child RigGeometries.
|
||||||
|
|
Loading…
Reference in a new issue