Remove a redundant list.

This commit is contained in:
cc9cii 2014-11-02 17:56:28 +11:00
parent 7f54dab6ef
commit 49d416353e
4 changed files with 16 additions and 51 deletions

View file

@ -333,6 +333,7 @@ namespace CSVRender
//plane X, upvector Y, mOffset x : x-z plane, wheel closer/further //plane X, upvector Y, mOffset x : x-z plane, wheel closer/further
std::pair<Ogre::Vector3, Ogre::Vector3> MouseState::planeAxis() std::pair<Ogre::Vector3, Ogre::Vector3> MouseState::planeAxis()
{ {
// FIXME: explore using signals instread of retrieving each time
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance(); CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
QString coord = userSettings.setting("debug/mouse-reference", QString("screen")); QString coord = userSettings.setting("debug/mouse-reference", QString("screen"));
Ogre::Vector3 dir = getCamera()->getDerivedDirection(); Ogre::Vector3 dir = getCamera()->getDerivedDirection();

View file

@ -74,7 +74,6 @@ namespace CSVWorld
throw std::runtime_error("No physics system found for the given document."); throw std::runtime_error("No physics system found for the given document.");
} }
// delete physics when the last scene widget for the document is closed
void PhysicsManager::removeSceneWidget(CSVRender::WorldspaceWidget *widget) void PhysicsManager::removeSceneWidget(CSVRender::WorldspaceWidget *widget)
{ {
CSVRender::SceneWidget *sceneWidget = static_cast<CSVRender::SceneWidget *>(widget); CSVRender::SceneWidget *sceneWidget = static_cast<CSVRender::SceneWidget *>(widget);

View file

@ -37,13 +37,13 @@ namespace CSVWorld
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, bool placeable) const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, bool placeable)
{ {
bool foundSceneManager = false; bool foundSceneManager = false;
std::list<Ogre::SceneManager *>::const_iterator iter = mSceneManagers.begin(); std::map<Ogre::SceneManager *, CSVRender::SceneWidget *>::const_iterator iter = mSceneWidgets.begin();
for(; iter != mSceneManagers.end(); ++iter) for(; iter != mSceneWidgets.end(); ++iter)
{ {
if((*iter)->hasSceneNode(sceneNodeName)) if((*iter).first->hasSceneNode(sceneNodeName))
{ {
mSceneNodeToRefId[sceneNodeName] = referenceId; mSceneNodeToRefId[sceneNodeName] = referenceId;
mRefIdToSceneNode[referenceId][*iter] = sceneNodeName; mRefIdToSceneNode[referenceId][(*iter).first] = sceneNodeName;
mSceneNodeToMesh[sceneNodeName] = mesh; mSceneNodeToMesh[sceneNodeName] = mesh;
foundSceneManager = true; foundSceneManager = true;
break; break;
@ -54,7 +54,6 @@ namespace CSVWorld
{ {
std::cerr << "Attempt to add an object without a corresponding SceneManager: " std::cerr << "Attempt to add an object without a corresponding SceneManager: "
+ referenceId + " : " + sceneNodeName << std::endl; + referenceId + " : " + sceneNodeName << std::endl;
return; return;
} }
@ -67,19 +66,6 @@ namespace CSVWorld
0, // boxRotation 0, // boxRotation
true, // raycasting true, // raycasting
placeable); placeable);
// update other scene managers if they have the referenceId (may have moved)
// NOTE: this part is not needed if object has not moved
iter = mSceneManagers.begin();
for(; iter != mSceneManagers.end(); ++iter)
{
std::string name = refIdToSceneNode(referenceId, *iter);
if(name != sceneNodeName && (*iter)->hasSceneNode(name))
{
// FIXME: rotation or scale not updated
(*iter)->getSceneNode(name)->setPosition(position);
}
}
} }
} }
@ -96,12 +82,12 @@ namespace CSVWorld
// find which SceneManager has this object // find which SceneManager has this object
Ogre::SceneManager *sceneManager = NULL; Ogre::SceneManager *sceneManager = NULL;
std::list<Ogre::SceneManager *>::const_iterator iter = mSceneManagers.begin(); std::map<Ogre::SceneManager *, CSVRender::SceneWidget *>::const_iterator iter = mSceneWidgets.begin();
for(; iter != mSceneManagers.end(); ++iter) for(; iter != mSceneWidgets.end(); ++iter)
{ {
if((*iter)->hasSceneNode(sceneNodeName)) if((*iter).first->hasSceneNode(sceneNodeName))
{ {
sceneManager = *iter; sceneManager = (*iter).first;
break; break;
} }
} }
@ -110,7 +96,6 @@ namespace CSVWorld
{ {
std::cerr << "Attempt to remove an object without a corresponding SceneManager: " std::cerr << "Attempt to remove an object without a corresponding SceneManager: "
+ sceneNodeName << std::endl; + sceneNodeName << std::endl;
return; return;
} }
@ -167,16 +152,8 @@ namespace CSVWorld
placeable); placeable);
// update other scene managers if they have the referenceId // update other scene managers if they have the referenceId
std::list<Ogre::SceneManager *>::const_iterator iter = mSceneManagers.begin(); // FIXME: rotation or scale not updated
for(; iter != mSceneManagers.end(); ++iter) moveSceneNodeImpl(sceneNodeName, referenceId, position);
{
std::string name = refIdToSceneNode(referenceId, *iter);
if(name != sceneNodeName && (*iter)->hasSceneNode(name))
{
// FIXME: rotation or scale not updated
(*iter)->getSceneNode(name)->setPosition(position);
}
}
} }
} }
@ -190,13 +167,13 @@ namespace CSVWorld
void PhysicsSystem::moveSceneNodeImpl(const std::string sceneNodeName, void PhysicsSystem::moveSceneNodeImpl(const std::string sceneNodeName,
const std::string referenceId, const Ogre::Vector3 &position) const std::string referenceId, const Ogre::Vector3 &position)
{ {
std::list<Ogre::SceneManager *>::const_iterator iter = mSceneManagers.begin(); std::map<Ogre::SceneManager *, CSVRender::SceneWidget *>::const_iterator iter = mSceneWidgets.begin();
for(; iter != mSceneManagers.end(); ++iter) for(; iter != mSceneWidgets.end(); ++iter)
{ {
std::string name = refIdToSceneNode(referenceId, *iter); std::string name = refIdToSceneNode(referenceId, (*iter).first);
if(name != sceneNodeName && (*iter)->hasSceneNode(name)) if(name != sceneNodeName && (*iter).first->hasSceneNode(name))
{ {
(*iter)->getSceneNode(name)->setPosition(position); (*iter).first->getSceneNode(name)->setPosition(position);
} }
} }
} }
@ -301,7 +278,6 @@ namespace CSVWorld
void PhysicsSystem::addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * sceneWidget) void PhysicsSystem::addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * sceneWidget)
{ {
mSceneManagers.push_back(sceneMgr);
mSceneWidgets[sceneMgr] = sceneWidget; mSceneWidgets[sceneMgr] = sceneWidget;
} }
@ -312,15 +288,6 @@ namespace CSVWorld
void PhysicsSystem::removeSceneManager(Ogre::SceneManager *sceneMgr) void PhysicsSystem::removeSceneManager(Ogre::SceneManager *sceneMgr)
{ {
std::list<Ogre::SceneManager *>::iterator iter = mSceneManagers.begin();
for(; iter != mSceneManagers.end(); ++iter)
{
if(*iter == sceneMgr)
{
mSceneManagers.erase(iter);
break;
}
}
mSceneWidgets.erase(sceneMgr); mSceneWidgets.erase(sceneMgr);
} }

View file

@ -3,7 +3,6 @@
#include <string> #include <string>
#include <map> #include <map>
#include <list>
namespace Ogre namespace Ogre
{ {
@ -33,7 +32,6 @@ namespace CSVWorld
std::map<std::string, std::string> mSceneNodeToRefId; std::map<std::string, std::string> mSceneNodeToRefId;
std::map<std::string, std::map<Ogre::SceneManager *, std::string> > mRefIdToSceneNode; std::map<std::string, std::map<Ogre::SceneManager *, std::string> > mRefIdToSceneNode;
std::map<std::string, std::string> mSceneNodeToMesh; std::map<std::string, std::string> mSceneNodeToMesh;
std::list<Ogre::SceneManager *> mSceneManagers;
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> mSceneWidgets; std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> mSceneWidgets;
OEngine::Physic::PhysicEngine* mEngine; OEngine::Physic::PhysicEngine* mEngine;
std::multimap<std::string, Ogre::SceneManager *> mTerrain; std::multimap<std::string, Ogre::SceneManager *> mTerrain;