1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-04 21:11:32 +00:00

Make BulletShape::makeInstance free function

This commit is contained in:
elsid 2021-10-30 03:16:21 +02:00
parent b905dd17c3
commit fc9a405dc5
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
3 changed files with 6 additions and 9 deletions

View file

@ -99,10 +99,9 @@ bool BulletShape::isAnimated() const
return !mAnimatedShapes.empty(); return !mAnimatedShapes.empty();
} }
osg::ref_ptr<BulletShapeInstance> BulletShape::makeInstance() const osg::ref_ptr<BulletShapeInstance> makeInstance(osg::ref_ptr<const BulletShape> source)
{ {
osg::ref_ptr<BulletShapeInstance> instance (new BulletShapeInstance(this)); return {new BulletShapeInstance(std::move(source))};
return instance;
} }
BulletShapeInstance::BulletShapeInstance(osg::ref_ptr<const BulletShape> source) BulletShapeInstance::BulletShapeInstance(osg::ref_ptr<const BulletShape> source)

View file

@ -21,7 +21,6 @@ namespace Resource
using CollisionShapePtr = std::unique_ptr<btCollisionShape, DeleteCollisionShape>; using CollisionShapePtr = std::unique_ptr<btCollisionShape, DeleteCollisionShape>;
class BulletShapeInstance;
class BulletShape : public osg::Object class BulletShape : public osg::Object
{ {
public: public:
@ -48,8 +47,6 @@ namespace Resource
// we store the node's record index mapped to the child index of the shape in the btCompoundShape. // we store the node's record index mapped to the child index of the shape in the btCompoundShape.
std::map<int, int> mAnimatedShapes; std::map<int, int> mAnimatedShapes;
osg::ref_ptr<BulletShapeInstance> makeInstance() const;
btCollisionShape* getCollisionShape() const; btCollisionShape* getCollisionShape() const;
btCollisionShape* getAvoidCollisionShape() const; btCollisionShape* getAvoidCollisionShape() const;
@ -71,6 +68,8 @@ namespace Resource
osg::ref_ptr<const BulletShape> mSource; osg::ref_ptr<const BulletShape> mSource;
}; };
osg::ref_ptr<BulletShapeInstance> makeInstance(osg::ref_ptr<const BulletShape> source);
// Subclass btBhvTriangleMeshShape to auto-delete the meshInterface // Subclass btBhvTriangleMeshShape to auto-delete the meshInterface
struct TriangleMeshShape : public btBvhTriangleMeshShape struct TriangleMeshShape : public btBvhTriangleMeshShape
{ {

View file

@ -193,9 +193,8 @@ osg::ref_ptr<BulletShapeInstance> BulletShapeManager::createInstance(const std::
{ {
osg::ref_ptr<const BulletShape> shape = getShape(name); osg::ref_ptr<const BulletShape> shape = getShape(name);
if (shape) if (shape)
return shape->makeInstance(); return makeInstance(std::move(shape));
else return osg::ref_ptr<BulletShapeInstance>();
return osg::ref_ptr<BulletShapeInstance>();
} }
void BulletShapeManager::updateCache(double referenceTime) void BulletShapeManager::updateCache(double referenceTime)