forked from mirror/openmw-tes3mp
Multiple document support.
This commit is contained in:
parent
057982b1f8
commit
b328aa1fb9
16 changed files with 83 additions and 81 deletions
|
@ -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
|
||||
|
|
|
@ -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<Files::PathContainer, std::vector<std::string> > 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);
|
||||
|
|
|
@ -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<CSVRender::OverlaySystem> mOverlaySystem;
|
||||
std::auto_ptr<CSVWorld::PhysicsSystem> mPhysicsSystem;
|
||||
std::auto_ptr<CSVWorld::PhysicsManager> mPhysicsManager;
|
||||
CSMDoc::DocumentManager mDocumentManager;
|
||||
CSVDoc::ViewManager mViewManager;
|
||||
CSVDoc::StartupDialogue mStartup;
|
||||
|
|
|
@ -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<RunLogSubView>);
|
||||
|
||||
connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int)));
|
||||
|
||||
CSVWorld::PhysicsManager::instance()->setupPhysics(document);
|
||||
}
|
||||
|
||||
CSVDoc::View::~View()
|
||||
|
|
|
@ -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<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(mSceneMgr, esmLand->mX, esmLand->mY);
|
||||
}
|
||||
}
|
||||
mPhysics->removeHeightField(mSceneMgr, mX, mY);
|
||||
|
||||
for (std::map<std::string, Object *>::iterator iter (mObjects.begin());
|
||||
iter!=mObjects.end(); ++iter)
|
||||
|
@ -201,7 +192,7 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft,
|
|||
for (std::map<std::string, bool>::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;
|
||||
}
|
||||
|
|
|
@ -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<std::string, Object *> mObjects;
|
||||
std::auto_ptr<Terrain::TerrainGrid> 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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include <OgreViewport.h>
|
||||
#include <OgreOverlaySystem.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
|
|
@ -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::vector<CSMWorld:
|
|||
return false;
|
||||
|
||||
mCellId = data.begin()->getId();
|
||||
mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId));
|
||||
mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId, getPhysics()));
|
||||
|
||||
update();
|
||||
emit cellChanged(*data.begin());
|
||||
|
|
|
@ -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<std::string, Ogre::Vector3> CSVRender::WorldspaceWidget::terrainUnderC
|
|||
float x = (float) mouseX / getCamera()->getViewport()->getActualWidth();
|
||||
float y = (float) mouseY / getCamera()->getViewport()->getActualHeight();
|
||||
|
||||
std::pair<std::string, Ogre::Vector3> result =
|
||||
CSVWorld::PhysicsSystem::instance()->castRay(x, y, getSceneManager(), getCamera());
|
||||
std::pair<std::string, Ogre::Vector3> 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<std::string, Ogre::Vector3> CSVRender::WorldspaceWidget::objectUnderCu
|
|||
float x = (float) mouseX / getCamera()->getViewport()->getActualWidth();
|
||||
float y = (float) mouseY / getCamera()->getViewport()->getActualHeight();
|
||||
|
||||
std::pair<std::string, Ogre::Vector3> result =
|
||||
CSVWorld::PhysicsSystem::instance()->castRay(x, y, getSceneManager(), getCamera());
|
||||
std::pair<std::string, Ogre::Vector3> 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<Ogre::SceneManager*, CSVRender::SceneWidget *> sceneWidgets =
|
||||
CSVWorld::PhysicsSystem::instance()->sceneWidgets();
|
||||
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> sceneWidgets = mPhysics->sceneWidgets();
|
||||
|
||||
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *>::iterator iter = sceneWidgets.begin();
|
||||
for(; iter != sceneWidgets.end(); ++iter)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -30,12 +30,10 @@ namespace CSVWorld
|
|||
{
|
||||
class PhysicsSystem
|
||||
{
|
||||
static PhysicsSystem *mPhysicsSystemInstance;
|
||||
std::map<std::string, std::string> mSceneNodeToRefId;
|
||||
std::map<std::string, std::map<Ogre::SceneManager *, std::string> > mRefIdToSceneNode;
|
||||
std::map<std::string, std::string> mSceneNodeToMesh;
|
||||
std::list<Ogre::SceneManager *> mSceneManagers; // FIXME: change to list per OEngine
|
||||
//std::list<CSVRender::SceneWidget *> mSceneWidgets; // FIXME: change to list per OEngine
|
||||
std::list<Ogre::SceneManager *> mSceneManagers;
|
||||
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> mSceneWidgets;
|
||||
OEngine::Physic::PhysicEngine* mEngine;
|
||||
std::multimap<std::string, Ogre::SceneManager *> 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue