diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index bce14a642..a399b5b5b 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -43,6 +43,3 @@ void CSVDoc::SubView::closeRequest() { emit closeRequest (this); } - -void CSVDoc::SubView::updateScene() -{} diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index 9acb7a5ae..a8aa3cda1 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -52,8 +52,6 @@ namespace CSVDoc virtual void updateUserSetting (const QString& name, const QStringList& value); - virtual void updateScene(); - private: void closeEvent (QCloseEvent *event); @@ -68,8 +66,6 @@ namespace CSVDoc void updateSubViewIndicies (SubView *view = 0); - void refreshSubViews(); - protected slots: void closeRequest(); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 932dab3aa..8a6665cf2 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -16,7 +16,6 @@ #include "../../model/world/idtable.hpp" #include "../world/subviews.hpp" -#include "../doc/subview.hpp" #include "../tools/subviews.hpp" @@ -301,15 +300,6 @@ void CSVDoc::View::setupUi() setupDebugMenu(); } -void CSVDoc::View::refreshSubViews() -{ - QList::iterator iter = mSubViews.begin(); - for(; iter != mSubViews.end(); ++iter) - { - (*iter)->updateScene(); - } -} - void CSVDoc::View::updateTitle() { std::ostringstream stream; @@ -537,8 +527,6 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin connect (view, SIGNAL (updateSubViewIndicies (SubView *)), this, SLOT (updateSubViewIndicies (SubView *))); - connect (view, SIGNAL (refreshSubViews()), this, SLOT (refreshSubViews())); - view->show(); } diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index c6bb206d6..55ea5ee51 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -139,8 +139,6 @@ namespace CSVDoc // called when subviews are added or removed void updateSubViewIndicies (SubView *view = 0); - void refreshSubViews(); - private slots: void newView(); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index aa00de022..5611c2243 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -66,7 +66,7 @@ namespace CSVRender mOverlaySystem = OverlaySystem::instance().get(); mSceneMgr->addRenderQueueListener(mOverlaySystem); - CSVWorld::PhysicsSystem::instance()->addSceneManager(mSceneMgr); + CSVWorld::PhysicsSystem::instance()->addSceneManager(mSceneMgr, this); QTimer *timer = new QTimer (this); diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index f25a24158..5656b2dd6 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -527,7 +527,7 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) mCurrentMousePos = planeResult.second; CSVWorld::PhysicsSystem::instance()->moveSceneNodes(mGrabbedSceneNode, pos+planeResult.second-mOrigMousePos); - emit signalAsModified(); + updateSceneWidgets(); } } } @@ -748,7 +748,7 @@ void CSVRender::WorldspaceWidget::wheelEvent (QWheelEvent *event) getSceneManager()->getSceneNode(mGrabbedSceneNode)->setPosition(pos+mCurrentMousePos-mOrigMousePos); CSVWorld::PhysicsSystem::instance()->moveSceneNodes(mGrabbedSceneNode, pos+mCurrentMousePos-mOrigMousePos); - emit signalAsModified(); + updateSceneWidgets(); } break; } @@ -923,7 +923,19 @@ void CSVRender::WorldspaceWidget::placeObject(const std::string sceneNode, const CSVWorld::PhysicsSystem::instance()->replaceObject(mesh, sceneNode, refId, cellref.mScale, pos, xr*yr*zr); // update all SceneWidgets and their SceneManagers - emit signalAsModified(); + updateSceneWidgets(); +} + +void CSVRender::WorldspaceWidget::updateSceneWidgets() +{ + std::map sceneWidgets = + CSVWorld::PhysicsSystem::instance()->sceneWidgets(); + + std::map::iterator iter = sceneWidgets.begin(); + for(; iter != sceneWidgets.end(); ++iter) + { + (*iter).second->updateScene(); + } } bool CSVRender::WorldspaceWidget::isDebug() diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index e69fbe08e..e74c40e86 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -130,12 +130,14 @@ namespace CSVRender virtual std::string getStartupInstruction() = 0; void placeObject(const std::string sceneNode, const Ogre::Vector3 &pos); - bool isDebug(); std::pair terrainUnderCursor(const int mouseX, const int mouseY); std::pair objectUnderCursor(const int mouseX, const int mouseY); std::pair mousePositionOnPlane(const QPoint &pos, const Ogre::Plane &plane); void updateSelectionHighlight(const std::string sceneNode, const Ogre::Vector3 &position); + void updateSceneWidgets(); + bool isDebug(); + private slots: void selectNavigationMode (const std::string& mode); @@ -170,8 +172,6 @@ namespace CSVRender void closeRequest(); void dataDropped(const std::vector& data); - - void signalAsModified(); }; } diff --git a/apps/opencs/view/world/physicssystem.cpp b/apps/opencs/view/world/physicssystem.cpp index 58d8e7662..0342ede95 100644 --- a/apps/opencs/view/world/physicssystem.cpp +++ b/apps/opencs/view/world/physicssystem.cpp @@ -276,9 +276,15 @@ namespace CSVWorld return mSceneNodeToMesh[sceneNodeName]; } - void PhysicsSystem::addSceneManager(Ogre::SceneManager *sceneMgr) + void PhysicsSystem::addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * sceneWidget) { mSceneManagers.push_back(sceneMgr); + mSceneWidgets[sceneMgr] = sceneWidget; + } + + std::map PhysicsSystem::sceneWidgets() + { + return mSceneWidgets; } void PhysicsSystem::removeSceneManager(Ogre::SceneManager *sceneMgr) @@ -292,6 +298,7 @@ namespace CSVWorld break; } } + mSceneWidgets.erase(sceneMgr); } void PhysicsSystem::toggleDebugRendering(Ogre::SceneManager *sceneMgr) diff --git a/apps/opencs/view/world/physicssystem.hpp b/apps/opencs/view/world/physicssystem.hpp index 0742bbf47..3232a5e90 100644 --- a/apps/opencs/view/world/physicssystem.hpp +++ b/apps/opencs/view/world/physicssystem.hpp @@ -35,6 +35,8 @@ namespace CSVWorld 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::map mSceneWidgets; OEngine::Physic::PhysicEngine* mEngine; std::multimap mTerrain; @@ -45,7 +47,7 @@ namespace CSVWorld static PhysicsSystem *instance(); - void addSceneManager(Ogre::SceneManager *sceneMgr); + void addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * scene); void removeSceneManager(Ogre::SceneManager *sceneMgr); void addObject(const std::string &mesh, @@ -80,6 +82,8 @@ namespace CSVWorld std::string sceneNodeToMesh(std::string sceneNodeName); + std::map sceneWidgets(); + private: void moveSceneNodeImpl(const std::string sceneNodeName, diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index b02c14f12..433bb828f 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -62,8 +62,6 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D makeConnections(newWidget); } - connect (worldspaceWidget, SIGNAL (signalAsModified()), this, SIGNAL (refreshSubViews())); - replaceToolbarAndWorldspace(worldspaceWidget, makeToolbar(worldspaceWidget, whatWidget)); layout->insertLayout (0, mLayout, 1); @@ -133,7 +131,6 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp void CSVWorld::SceneSubView::setEditLock (bool locked) { - } void CSVWorld::SceneSubView::updateEditorSetting(const QString &settingName, const QString &settingValue) @@ -151,11 +148,6 @@ void CSVWorld::SceneSubView::useHint (const std::string& hint) mScene->useViewHint (hint); } -void CSVWorld::SceneSubView::updateScene() -{ - if(mScene) mScene->updateScene(); -} - std::string CSVWorld::SceneSubView::getTitle() const { return mTitle; diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index 0bf19ee69..fc45347d0 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -60,8 +60,6 @@ namespace CSVWorld virtual std::string getTitle() const; - virtual void updateScene(); - private: void makeConnections(CSVRender::PagedWorldspaceWidget* widget);