mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Cleanup bullet objects in the destructors.
This commit is contained in:
parent
9337d6533a
commit
b46df4034d
4 changed files with 34 additions and 4 deletions
|
@ -96,6 +96,19 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager,
|
|||
|
||||
CSVRender::Cell::~Cell()
|
||||
{
|
||||
// TODO: maybe store the cell coordinates rather than searching for them in the destructor?
|
||||
if(mTerrain.get())
|
||||
{
|
||||
const CSMWorld::IdCollection<CSMWorld::Land>& land = mData.getLand();
|
||||
int landIndex = land.searchId(mId);
|
||||
if (landIndex != -1)
|
||||
{
|
||||
const ESM::Land* esmLand = land.getRecord(mId).get().mLand.get();
|
||||
if(esmLand)
|
||||
CSVWorld::PhysicsSystem::instance()->removeHeightField(esmLand->mX, esmLand->mY);
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<std::string, Object *>::iterator iter (mObjects.begin());
|
||||
iter!=mObjects.end(); ++iter)
|
||||
delete iter->second;
|
||||
|
|
|
@ -33,11 +33,12 @@ void CSVRender::Object::clearSceneNode (Ogre::SceneNode *node)
|
|||
|
||||
void CSVRender::Object::clear()
|
||||
{
|
||||
if(!mObject.isNull())
|
||||
CSVWorld::PhysicsSystem::instance()->removeObject(mBase->getName());
|
||||
|
||||
mObject.setNull();
|
||||
|
||||
clearSceneNode (mBase);
|
||||
|
||||
// FIXME: also clear bullet objects
|
||||
}
|
||||
|
||||
void CSVRender::Object::update()
|
||||
|
|
|
@ -53,6 +53,15 @@ namespace CSVWorld
|
|||
|
||||
PhysicsSystem::~PhysicsSystem()
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> >::iterator iter = mSelectedEntities.begin();
|
||||
for(;iter != mSelectedEntities.end(); ++iter)
|
||||
{
|
||||
removeHitPoint(mSceneMgr, iter->first);
|
||||
Ogre::SceneNode *scene = mSceneMgr->getSceneNode(iter->first);
|
||||
scene->removeAndDestroyAllChildren();
|
||||
mSceneMgr->destroySceneNode(iter->first);
|
||||
}
|
||||
|
||||
delete mEngine;
|
||||
}
|
||||
|
||||
|
@ -152,6 +161,11 @@ namespace CSVWorld
|
|||
mEngine->addHeightField(heights, x, y, yoffset, triSize, sqrtVerts);
|
||||
}
|
||||
|
||||
void PhysicsSystem::removeHeightField(int x, int y)
|
||||
{
|
||||
mEngine->removeHeightField(x, y);
|
||||
}
|
||||
|
||||
void PhysicsSystem::toggleDebugRendering()
|
||||
{
|
||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||
|
|
|
@ -53,6 +53,8 @@ namespace CSVWorld
|
|||
void addHeightField(float* heights, int x, int y, float yoffset,
|
||||
float triSize, float sqrtVerts);
|
||||
|
||||
void removeHeightField(int x, int y);
|
||||
|
||||
void toggleDebugRendering();
|
||||
|
||||
std::pair<bool, std::string> castRay(float mouseX, float mouseY,
|
||||
|
|
Loading…
Reference in a new issue