forked from mirror/openmw-tes3mp
Use the UnrefQueue to delete BulletShapeInstances
This commit is contained in:
parent
afe533e670
commit
1457a0de78
5 changed files with 29 additions and 2 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <components/esm/loadgmst.hpp>
|
||||
#include <components/sceneutil/positionattitudetransform.hpp>
|
||||
#include <components/sceneutil/unrefqueue.hpp>
|
||||
|
||||
#include <components/nifosg/particle.hpp> // FindRecIndexVisitor
|
||||
|
||||
|
@ -533,6 +534,11 @@ namespace MWPhysics
|
|||
setOrigin(btVector3(pos[0], pos[1], pos[2]));
|
||||
}
|
||||
|
||||
const Resource::BulletShapeInstance* getShapeInstance() const
|
||||
{
|
||||
return mShapeInstance.get();
|
||||
}
|
||||
|
||||
void setScale(float scale)
|
||||
{
|
||||
mShapeInstance->getCollisionShape()->setLocalScaling(btVector3(scale,scale,scale));
|
||||
|
@ -690,6 +696,11 @@ namespace MWPhysics
|
|||
delete mBroadphase;
|
||||
}
|
||||
|
||||
void PhysicsSystem::setUnrefQueue(SceneUtil::UnrefQueue *unrefQueue)
|
||||
{
|
||||
mUnrefQueue = unrefQueue;
|
||||
}
|
||||
|
||||
Resource::BulletShapeManager *PhysicsSystem::getShapeManager()
|
||||
{
|
||||
return mShapeManager.get();
|
||||
|
@ -1109,6 +1120,9 @@ namespace MWPhysics
|
|||
{
|
||||
mCollisionWorld->removeCollisionObject(found->second->getCollisionObject());
|
||||
|
||||
if (mUnrefQueue.get())
|
||||
mUnrefQueue->push(found->second->getShapeInstance());
|
||||
|
||||
mAnimatedObjects.erase(found->second);
|
||||
|
||||
delete found->second;
|
||||
|
|
|
@ -25,11 +25,12 @@ namespace MWRender
|
|||
namespace Resource
|
||||
{
|
||||
class BulletShapeManager;
|
||||
class ResourceSystem;
|
||||
}
|
||||
|
||||
namespace Resource
|
||||
namespace SceneUtil
|
||||
{
|
||||
class ResourceSystem;
|
||||
class UnrefQueue;
|
||||
}
|
||||
|
||||
class btCollisionWorld;
|
||||
|
@ -53,6 +54,8 @@ namespace MWPhysics
|
|||
PhysicsSystem (Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> parentNode);
|
||||
~PhysicsSystem ();
|
||||
|
||||
void setUnrefQueue(SceneUtil::UnrefQueue* unrefQueue);
|
||||
|
||||
Resource::BulletShapeManager* getShapeManager();
|
||||
|
||||
void enableWater(float height);
|
||||
|
@ -165,6 +168,8 @@ namespace MWPhysics
|
|||
|
||||
void updateWater();
|
||||
|
||||
osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
|
||||
|
||||
btBroadphaseInterface* mBroadphase;
|
||||
btDefaultCollisionConfiguration* mCollisionConfiguration;
|
||||
btCollisionDispatcher* mDispatcher;
|
||||
|
|
|
@ -263,6 +263,11 @@ namespace MWRender
|
|||
return mWorkQueue.get();
|
||||
}
|
||||
|
||||
SceneUtil::UnrefQueue *RenderingManager::getUnrefQueue()
|
||||
{
|
||||
return mUnrefQueue.get();
|
||||
}
|
||||
|
||||
void RenderingManager::preloadCommonAssets()
|
||||
{
|
||||
osg::ref_ptr<PreloadCommonAssetsWorkItem> workItem (new PreloadCommonAssetsWorkItem(mResourceSystem));
|
||||
|
|
|
@ -72,6 +72,7 @@ namespace MWRender
|
|||
Resource::ResourceSystem* getResourceSystem();
|
||||
|
||||
SceneUtil::WorkQueue* getWorkQueue();
|
||||
SceneUtil::UnrefQueue* getUnrefQueue();
|
||||
|
||||
void preloadCommonAssets();
|
||||
|
||||
|
|
|
@ -466,6 +466,8 @@ namespace MWWorld
|
|||
mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager()));
|
||||
mPreloader->setWorkQueue(mRendering.getWorkQueue());
|
||||
|
||||
mPhysics->setUnrefQueue(rendering.getUnrefQueue());
|
||||
|
||||
float cacheExpiryDelay = Settings::Manager::getFloat("cache expiry delay", "Cells");
|
||||
rendering.getResourceSystem()->setExpiryDelay(cacheExpiryDelay);
|
||||
mPreloader->setExpiryDelay(cacheExpiryDelay);
|
||||
|
|
Loading…
Reference in a new issue