diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 828584452..30e9203f5 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -68,7 +68,7 @@ opencs_units (view/world opencs_units_noqt (view/world subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate - scripthighlighter idvalidator dialoguecreator physicssystem + scripthighlighter idvalidator dialoguecreator physicssystem physicsmanager ) opencs_units (view/widget diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index b566bbe5d..591667ebb 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -21,7 +21,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) : mUserSettings (mCfgMgr), mOverlaySystem (0), mDocumentManager (mCfgMgr), - mViewManager (mDocumentManager), mPhysicsSystem (0), + mViewManager (mDocumentManager), mPhysicsManager (0), mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL) { std::pair > config = readConfig(); @@ -34,7 +34,7 @@ CS::Editor::Editor (OgreInit::OgreInit& ogreInit) ogreInit.init ((mCfgMgr.getUserConfigPath() / "opencsOgre.log").string()); mOverlaySystem.reset (new CSVRender::OverlaySystem); - mPhysicsSystem.reset (new CSVWorld::PhysicsSystem); + mPhysicsManager.reset (new CSVWorld::PhysicsManager); Bsa::registerResources (Files::Collections (config.first, !mFsStrict), config.second, true, mFsStrict); diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index 4d2fdc2eb..d55b0e873 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -28,7 +28,7 @@ #include "view/settings/dialog.hpp" #include "view/render/overlaysystem.hpp" -#include "view/world/physicssystem.hpp" +#include "view/world/physicsmanager.hpp" namespace OgreInit { @@ -45,7 +45,7 @@ namespace CS Files::ConfigurationManager mCfgMgr; CSMSettings::UserSettings mUserSettings; std::auto_ptr mOverlaySystem; - std::auto_ptr mPhysicsSystem; + std::auto_ptr mPhysicsManager; CSMDoc::DocumentManager mDocumentManager; CSVDoc::ViewManager mViewManager; CSVDoc::StartupDialogue mStartup; diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 8a6665cf2..8b5efbea7 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -16,6 +16,7 @@ #include "../../model/world/idtable.hpp" #include "../world/subviews.hpp" +#include "../world/physicsmanager.hpp" #include "../tools/subviews.hpp" @@ -406,6 +407,8 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to mSubViewFactory.add (CSMWorld::UniversalId::Type_RunLog, new SubViewFactory); connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int))); + + CSVWorld::PhysicsManager::instance()->setupPhysics(document); } CSVDoc::View::~View() diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 52e233598..75e11cc10 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -51,7 +51,7 @@ bool CSVRender::Cell::addObjects (int start, int end) std::string id = Misc::StringUtils::lowerCase (references.data ( references.index (i, idColumn)).toString().toUtf8().constData()); - mObjects.insert (std::make_pair (id, new Object (mData, mCellNode, id, false))); + mObjects.insert (std::make_pair (id, new Object (mData, mCellNode, id, false, mPhysics))); modified = true; } } @@ -60,8 +60,8 @@ bool CSVRender::Cell::addObjects (int start, int end) } CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, - const std::string& id, const Ogre::Vector3& origin) -: mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager) + const std::string& id, CSVWorld::PhysicsSystem *physics, const Ogre::Vector3& origin) +: mData (data), mId (Misc::StringUtils::lowerCase (id)), mSceneMgr(sceneManager), mPhysics(physics) { mCellNode = sceneManager->getRootSceneNode()->createChildSceneNode(); mCellNode->setPosition (origin); @@ -88,26 +88,17 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, { float verts = ESM::Land::LAND_SIZE; float worldsize = ESM::Land::REAL_SIZE; - CSVWorld::PhysicsSystem::instance()->addHeightField(sceneManager, - esmLand->mLandData->mHeights, esmLand->mX, esmLand->mY, 0, worldsize / (verts-1), verts); + mX = esmLand->mX; + mY = esmLand->mY; + mPhysics->addHeightField(sceneManager, + esmLand->mLandData->mHeights, mX, mY, 0, worldsize / (verts-1), verts); } } } CSVRender::Cell::~Cell() { - // TODO: maybe store the cell coordinates rather than searching for them in the destructor? - if(mTerrain.get()) - { - const CSMWorld::IdCollection& 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(mSceneMgr, esmLand->mX, esmLand->mY); - } - } + mPhysics->removeHeightField(mSceneMgr, mX, mY); for (std::map::iterator iter (mObjects.begin()); iter!=mObjects.end(); ++iter) @@ -201,7 +192,7 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft, for (std::map::iterator iter (ids.begin()); iter!=ids.end(); ++iter) { mObjects.insert (std::make_pair ( - iter->first, new Object (mData, mCellNode, iter->first, false))); + iter->first, new Object (mData, mCellNode, iter->first, false, mPhysics))); modified = true; } diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 2badc84d2..8bc58714a 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -23,6 +23,11 @@ namespace CSMWorld class Data; } +namespace CSVWorld +{ + class PhysicsSystem; +} + namespace CSVRender { class Cell @@ -32,7 +37,10 @@ namespace CSVRender Ogre::SceneNode *mCellNode; std::map mObjects; std::auto_ptr mTerrain; + CSVWorld::PhysicsSystem *mPhysics; Ogre::SceneManager *mSceneMgr; + int mX; + int mY; /// Ignored if cell does not have an object with the given ID. /// @@ -46,8 +54,8 @@ namespace CSVRender public: - Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, - const std::string& id, const Ogre::Vector3& origin = Ogre::Vector3 (0, 0, 0)); + Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, const std::string& id, + CSVWorld::PhysicsSystem *physics, const Ogre::Vector3& origin = Ogre::Vector3 (0, 0, 0)); ~Cell(); diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 474c79b35..395a4d57e 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -34,7 +34,7 @@ void CSVRender::Object::clearSceneNode (Ogre::SceneNode *node) void CSVRender::Object::clear() { if(!mObject.isNull()) - CSVWorld::PhysicsSystem::instance()->removeObject(mBase->getName()); + mPhysics->removeObject(mBase->getName()); mObject.setNull(); @@ -79,7 +79,7 @@ void CSVRender::Object::update() mObject = NifOgre::Loader::createObjects (mBase, "Meshes\\" + model); mObject->setVisibilityFlags (Element_Reference); - if (!mReferenceId.empty()) + if (mPhysics && !mReferenceId.empty()) { const CSMWorld::CellRef& reference = getReference(); @@ -93,8 +93,7 @@ void CSVRender::Object::update() Ogre::Quaternion yr (Ogre::Radian (-reference.mPos.rot[1]), Ogre::Vector3::UNIT_Y); Ogre::Quaternion zr (Ogre::Radian (-reference.mPos.rot[2]), Ogre::Vector3::UNIT_Z); - CSVWorld::PhysicsSystem::instance()->addObject("meshes\\" + model, - mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr); + mPhysics->addObject("meshes\\" + model, mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr); } } } @@ -133,8 +132,9 @@ const CSMWorld::CellRef& CSVRender::Object::getReference() const } CSVRender::Object::Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode, - const std::string& id, bool referenceable, bool forceBaseToZero) -: mData (data), mBase (0), mForceBaseToZero (forceBaseToZero) + const std::string& id, bool referenceable, CSVWorld::PhysicsSystem *physics, + bool forceBaseToZero) +: mData (data), mBase (0), mForceBaseToZero (forceBaseToZero), mPhysics(physics) { mBase = cellNode->createChildSceneNode(); diff --git a/apps/opencs/view/render/object.hpp b/apps/opencs/view/render/object.hpp index 6a8a933e5..eba2dc814 100644 --- a/apps/opencs/view/render/object.hpp +++ b/apps/opencs/view/render/object.hpp @@ -16,6 +16,11 @@ namespace CSMWorld class CellRef; } +namespace CSVWorld +{ + class PhysicsSystem; +} + namespace CSVRender { class Object @@ -26,6 +31,7 @@ namespace CSVRender Ogre::SceneNode *mBase; NifOgre::ObjectScenePtr mObject; bool mForceBaseToZero; + CSVWorld::PhysicsSystem *mPhysics; /// Not implemented Object (const Object&); @@ -51,7 +57,8 @@ namespace CSVRender public: Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode, - const std::string& id, bool referenceable, bool forceBaseToZero = false); + const std::string& id, bool referenceable, + CSVWorld::PhysicsSystem *physics = NULL, bool forceBaseToZero = false); /// \param forceBaseToZero If this is a reference ignore the coordinates and place /// it at 0, 0, 0 instead. diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index b39f3733f..49e7e1f09 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -109,7 +109,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells() mCells.find (*iter)==mCells.end()) { Cell *cell = new Cell (mDocument.getData(), getSceneManager(), - iter->getId (mWorldspace)); + iter->getId (mWorldspace), getPhysics()); mCells.insert (std::make_pair (*iter, cell)); float height = cell->getTerrainHeightAt(Ogre::Vector3( diff --git a/apps/opencs/view/render/previewwidget.cpp b/apps/opencs/view/render/previewwidget.cpp index 75b4e9396..f972c6361 100644 --- a/apps/opencs/view/render/previewwidget.cpp +++ b/apps/opencs/view/render/previewwidget.cpp @@ -10,7 +10,7 @@ CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data, const std::string& id, bool referenceable, QWidget *parent) : SceneWidget (parent), mData (data), - mObject (data, getSceneManager()->getRootSceneNode(), id, referenceable, true) + mObject (data, getSceneManager()->getRootSceneNode(), id, referenceable, NULL, true) { setNavigation (&mOrbit); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 5611c2243..55cf039fc 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -13,8 +13,6 @@ #include #include -#include "../world/physicssystem.hpp" - #include "../widget/scenetoolmode.hpp" #include "../../model/settings/usersettings.hpp" @@ -66,8 +64,6 @@ namespace CSVRender mOverlaySystem = OverlaySystem::instance().get(); mSceneMgr->addRenderQueueListener(mOverlaySystem); - CSVWorld::PhysicsSystem::instance()->addSceneManager(mSceneMgr, this); - QTimer *timer = new QTimer (this); connect (timer, SIGNAL (timeout()), this, SLOT (update())); @@ -166,8 +162,6 @@ namespace CSVRender SceneWidget::~SceneWidget() { - CSVWorld::PhysicsSystem::instance()->removeSceneManager(mSceneMgr); - if (mWindow) Ogre::Root::getSingleton().destroyRenderTarget (mWindow); diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index aab3791fc..8012b1b24 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -56,7 +56,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& update(); - mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId)); + mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId, getPhysics())); } void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, @@ -98,7 +98,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vectorgetId(); - mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId)); + mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId, getPhysics())); update(); emit cellChanged(*data.begin()); diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 5656b2dd6..448153d37 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -24,6 +24,7 @@ #include "../widget/scenetooltoggle.hpp" #include "../widget/scenetoolrun.hpp" +#include "../world/physicsmanager.hpp" #include "../world/physicssystem.hpp" #include "elements.hpp" @@ -147,6 +148,10 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg connect (debugProfiles, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), this, SLOT (debugProfileAboutToBeRemoved (const QModelIndex&, int, int))); + // associate WorldSpaceWidgets (and their SceneManagers with Documents, then create physics if new document + mPhysics = CSVWorld::PhysicsManager::instance()->addSceneWidget(document, this); + mPhysics->addSceneManager(getSceneManager(), this); + initDebug(); mMouseEventTimer = new QElapsedTimer(); mMouseEventTimer->invalidate(); @@ -166,6 +171,9 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg CSVRender::WorldspaceWidget::~WorldspaceWidget () { + mPhysics->removeSceneManager(getSceneManager()); + CSVWorld::PhysicsManager::instance()->removeSceneWidget(this); + delete mMouseEventTimer; // For debugging only @@ -457,6 +465,12 @@ void CSVRender::WorldspaceWidget::updateOverlay() { } +CSVWorld::PhysicsSystem *CSVRender::WorldspaceWidget::getPhysics() +{ + assert(mPhysics); + return mPhysics; +} + // mouse picking // FIXME: need to virtualise mouse buttons // @@ -525,8 +539,7 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) pos.z += mZOffset; getSceneManager()->getSceneNode(mGrabbedSceneNode)->setPosition(pos+planeResult.second-mOrigMousePos); mCurrentMousePos = planeResult.second; - CSVWorld::PhysicsSystem::instance()->moveSceneNodes(mGrabbedSceneNode, - pos+planeResult.second-mOrigMousePos); + mPhysics->moveSceneNodes(mGrabbedSceneNode, pos+planeResult.second-mOrigMousePos); updateSceneWidgets(); } } @@ -634,8 +647,7 @@ void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event) // print some debug info if(isDebug()) { - std::string referenceId = - CSVWorld::PhysicsSystem::instance()->sceneNodeToRefId(result.first); + std::string referenceId = mPhysics->sceneNodeToRefId(result.first); std::cout << "ReferenceId: " << referenceId << std::endl; const CSMWorld::RefCollection& references = mDocument.getData().getReferences(); int index = references.searchId(referenceId); @@ -719,8 +731,8 @@ void CSVRender::WorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event) // debug drawer. Hence only the first subview that creates the debug drawer // can view the debug lines. Will need to keep a map in OEngine if multiple // subviews are to be supported. - //CSVWorld::PhysicsSystem::instance()->setSceneManager(getSceneManager()); - CSVWorld::PhysicsSystem::instance()->toggleDebugRendering(getSceneManager()); + //mPhysics->setSceneManager(getSceneManager()); + mPhysics->toggleDebugRendering(getSceneManager()); flagAsModified(); } } @@ -746,8 +758,7 @@ void CSVRender::WorldspaceWidget::wheelEvent (QWheelEvent *event) Ogre::Vector3 pos = mOrigObjPos; pos.z += mZOffset; getSceneManager()->getSceneNode(mGrabbedSceneNode)->setPosition(pos+mCurrentMousePos-mOrigMousePos); - CSVWorld::PhysicsSystem::instance()->moveSceneNodes(mGrabbedSceneNode, - pos+mCurrentMousePos-mOrigMousePos); + mPhysics->moveSceneNodes(mGrabbedSceneNode, pos+mCurrentMousePos-mOrigMousePos); updateSceneWidgets(); } break; @@ -844,8 +855,7 @@ std::pair CSVRender::WorldspaceWidget::terrainUnderC float x = (float) mouseX / getCamera()->getViewport()->getActualWidth(); float y = (float) mouseY / getCamera()->getViewport()->getActualHeight(); - std::pair result = - CSVWorld::PhysicsSystem::instance()->castRay(x, y, getSceneManager(), getCamera()); + std::pair result = mPhysics->castRay(x, y, getSceneManager(), getCamera()); if(result.first != "") { // FIXME: is there a better way to distinguish terrain from objects? @@ -867,8 +877,7 @@ std::pair CSVRender::WorldspaceWidget::objectUnderCu float x = (float) mouseX / getCamera()->getViewport()->getActualWidth(); float y = (float) mouseY / getCamera()->getViewport()->getActualHeight(); - std::pair result = - CSVWorld::PhysicsSystem::instance()->castRay(x, y, getSceneManager(), getCamera()); + std::pair result = mPhysics->castRay(x, y, getSceneManager(), getCamera()); if(result.first != "") { // NOTE: anything not terrain is assumed to be an object @@ -910,17 +919,16 @@ void CSVRender::WorldspaceWidget::placeObject(const std::string sceneNode, const getSceneManager()->getSceneNode(sceneNode)->setPosition(pos); // update physics - std::string refId = CSVWorld::PhysicsSystem::instance()->sceneNodeToRefId(sceneNode); - const CSMWorld::CellRef& cellref = - mDocument.getData().getReferences().getRecord (refId).get(); + std::string refId = mPhysics->sceneNodeToRefId(sceneNode); + const CSMWorld::CellRef& cellref = mDocument.getData().getReferences().getRecord (refId).get(); Ogre::Quaternion xr (Ogre::Radian (-cellref.mPos.rot[0]), Ogre::Vector3::UNIT_X); Ogre::Quaternion yr (Ogre::Radian (-cellref.mPos.rot[1]), Ogre::Vector3::UNIT_Y); Ogre::Quaternion zr (Ogre::Radian (-cellref.mPos.rot[2]), Ogre::Vector3::UNIT_Z); // FIXME: adjustRigidBody() seems to lose objects, work around by deleting and recreating objects - //CSVWorld::PhysicsSystem::instance()->moveObject(sceneNode, pos, xr*yr*zr); - std::string mesh = CSVWorld::PhysicsSystem::instance()->sceneNodeToMesh(sceneNode); - CSVWorld::PhysicsSystem::instance()->replaceObject(mesh, sceneNode, refId, cellref.mScale, pos, xr*yr*zr); + //mPhysics->moveObject(sceneNode, pos, xr*yr*zr); + std::string mesh = mPhysics->sceneNodeToMesh(sceneNode); + mPhysics->replaceObject(mesh, sceneNode, refId, cellref.mScale, pos, xr*yr*zr); // update all SceneWidgets and their SceneManagers updateSceneWidgets(); @@ -928,8 +936,7 @@ void CSVRender::WorldspaceWidget::placeObject(const std::string sceneNode, const void CSVRender::WorldspaceWidget::updateSceneWidgets() { - std::map sceneWidgets = - CSVWorld::PhysicsSystem::instance()->sceneWidgets(); + std::map sceneWidgets = mPhysics->sceneWidgets(); std::map::iterator iter = sceneWidgets.begin(); for(; iter != sceneWidgets.end(); ++iter) diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index e74c40e86..431a023be 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -13,6 +13,7 @@ namespace CSMWorld { class UniversalId; } + namespace CSVWidget { class SceneToolMode; @@ -21,6 +22,11 @@ namespace CSVWidget class SceneToolRun; } +namespace CSVWorld +{ + class PhysicsSystem; +} + class QElapsedTimer; namespace CSVRender @@ -35,6 +41,7 @@ namespace CSVRender CSVWidget::SceneToolToggle *mSceneElements; CSVWidget::SceneToolRun *mRun; CSMDoc::Document& mDocument; + CSVWorld::PhysicsSystem *mPhysics; enum MouseState { @@ -113,6 +120,8 @@ namespace CSVRender virtual void updateOverlay(); + CSVWorld::PhysicsSystem *getPhysics(); + virtual void mouseMoveEvent (QMouseEvent *event); virtual void mousePressEvent (QMouseEvent *event); virtual void mouseReleaseEvent (QMouseEvent *event); diff --git a/apps/opencs/view/world/physicssystem.cpp b/apps/opencs/view/world/physicssystem.cpp index 0342ede95..320367906 100644 --- a/apps/opencs/view/world/physicssystem.cpp +++ b/apps/opencs/view/world/physicssystem.cpp @@ -13,13 +13,8 @@ namespace CSVWorld { - PhysicsSystem *PhysicsSystem::mPhysicsSystemInstance = 0; - PhysicsSystem::PhysicsSystem() { - assert(!mPhysicsSystemInstance); - mPhysicsSystemInstance = this; - // Create physics. shapeLoader is deleted by the physic engine NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader(); mEngine = new OEngine::Physic::PhysicEngine(shapeLoader); @@ -28,13 +23,6 @@ namespace CSVWorld PhysicsSystem::~PhysicsSystem() { delete mEngine; - // FIXME: update maps when SceneManagers are destroyed - } - - PhysicsSystem *PhysicsSystem::instance() - { - assert(mPhysicsSystemInstance); - return mPhysicsSystemInstance; } // FIXME: looks up the scene manager based on the scene node name (highly inefficient) @@ -60,7 +48,7 @@ namespace CSVWorld } if(!foundSceneManager) - return; // FIXME: this should be an exception + return; // FIXME: should this be an exception // update physics, only one physics model per referenceId if(mEngine->getRigidBody(referenceId, true) == NULL) diff --git a/apps/opencs/view/world/physicssystem.hpp b/apps/opencs/view/world/physicssystem.hpp index 3232a5e90..8fadf6c8a 100644 --- a/apps/opencs/view/world/physicssystem.hpp +++ b/apps/opencs/view/world/physicssystem.hpp @@ -30,12 +30,10 @@ namespace CSVWorld { class PhysicsSystem { - static PhysicsSystem *mPhysicsSystemInstance; std::map mSceneNodeToRefId; std::map > mRefIdToSceneNode; std::map mSceneNodeToMesh; - std::list mSceneManagers; // FIXME: change to list per OEngine - //std::list mSceneWidgets; // FIXME: change to list per OEngine + std::list mSceneManagers; std::map mSceneWidgets; OEngine::Physic::PhysicEngine* mEngine; std::multimap mTerrain; @@ -44,9 +42,6 @@ namespace CSVWorld PhysicsSystem(); ~PhysicsSystem(); - - static PhysicsSystem *instance(); - void addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * scene); void removeSceneManager(Ogre::SceneManager *sceneMgr);