mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 17:11:33 +00:00
Use unique_ptr to avoid possible memory leak
This commit is contained in:
parent
8e71c246bf
commit
ed5a4e195b
1 changed files with 3 additions and 2 deletions
|
@ -83,7 +83,8 @@ public:
|
||||||
return osg::ref_ptr<BulletShape>();
|
return osg::ref_ptr<BulletShape>();
|
||||||
|
|
||||||
osg::ref_ptr<BulletShape> shape (new BulletShape);
|
osg::ref_ptr<BulletShape> shape (new BulletShape);
|
||||||
btBvhTriangleMeshShape* triangleMeshShape = new TriangleMeshShape(mTriangleMesh.release(), true);
|
|
||||||
|
auto triangleMeshShape = std::make_unique<TriangleMeshShape>(mTriangleMesh.release(), true);
|
||||||
btVector3 aabbMin = triangleMeshShape->getLocalAabbMin();
|
btVector3 aabbMin = triangleMeshShape->getLocalAabbMin();
|
||||||
btVector3 aabbMax = triangleMeshShape->getLocalAabbMax();
|
btVector3 aabbMax = triangleMeshShape->getLocalAabbMax();
|
||||||
shape->mCollisionBox.mExtents[0] = (aabbMax[0] - aabbMin[0]) / 2.0f;
|
shape->mCollisionBox.mExtents[0] = (aabbMax[0] - aabbMin[0]) / 2.0f;
|
||||||
|
@ -92,7 +93,7 @@ public:
|
||||||
shape->mCollisionBox.mCenter = osg::Vec3f( (aabbMax[0] + aabbMin[0]) / 2.0f,
|
shape->mCollisionBox.mCenter = osg::Vec3f( (aabbMax[0] + aabbMin[0]) / 2.0f,
|
||||||
(aabbMax[1] + aabbMin[1]) / 2.0f,
|
(aabbMax[1] + aabbMin[1]) / 2.0f,
|
||||||
(aabbMax[2] + aabbMin[2]) / 2.0f );
|
(aabbMax[2] + aabbMin[2]) / 2.0f );
|
||||||
shape->mCollisionShape.reset(triangleMeshShape);
|
shape->mCollisionShape.reset(triangleMeshShape.release());
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue