forked from teamnwah/openmw-tes3coop
various bits of clean up
This commit is contained in:
parent
afa84b72e0
commit
40853e292f
10 changed files with 34 additions and 84 deletions
|
@ -50,8 +50,6 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicE
|
|||
|
||||
|
||||
mPlayer = new MWRender::Player (getCamera(), playerNode->getName());
|
||||
|
||||
mFreeFly = true;
|
||||
}
|
||||
|
||||
MWScene::~MWScene()
|
||||
|
@ -75,34 +73,6 @@ std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
|
|||
return eng->rayTest(from,to);
|
||||
}
|
||||
|
||||
bool MWScene::toggleCollisionMode()
|
||||
{
|
||||
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
|
||||
{
|
||||
OEngine::Physic::PhysicActor* act = it->second;
|
||||
bool cmode = act->getCollisionMode();
|
||||
if(cmode)
|
||||
{
|
||||
act->enableCollisions(false);
|
||||
act->setGravity(0.);
|
||||
act->setVerticalVelocity(0);
|
||||
mFreeFly = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mFreeFly = false;
|
||||
act->enableCollisions(true);
|
||||
act->setGravity(4.);
|
||||
act->setVerticalVelocity(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false; // This should never happen, but it shall not bother us now, since
|
||||
// this part of the code needs a rewrite anyway.
|
||||
}
|
||||
|
||||
bool MWScene::toggleRenderMode (int mode)
|
||||
{
|
||||
switch (mode)
|
||||
|
|
|
@ -44,8 +44,6 @@ namespace MWRender
|
|||
|
||||
MWRender::Player *mPlayer;
|
||||
|
||||
bool mFreeFly;
|
||||
|
||||
public:
|
||||
|
||||
MWScene (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng);
|
||||
|
@ -65,11 +63,6 @@ namespace MWRender
|
|||
/// can be faced
|
||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||
|
||||
/// Toggle collision mode for player. If disabled player object should ignore
|
||||
/// collisions and gravity.
|
||||
/// \return Resulting mode
|
||||
bool toggleCollisionMode();
|
||||
|
||||
/// Toggle render mode
|
||||
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
|
||||
/// when the mw*-refactoring is done.
|
||||
|
|
|
@ -106,24 +106,21 @@ namespace MWWorld
|
|||
mEngine->deleteRigidBody(handle);
|
||||
}
|
||||
|
||||
void PhysicsSystem::moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics)
|
||||
void PhysicsSystem::moveObject (const std::string& handle, const Ogre::Vector3& position)
|
||||
{
|
||||
if(updatePhysics)//TODO: is it an actor? Done?
|
||||
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
||||
{
|
||||
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
||||
{
|
||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||
// start positions others than 0, 0, 0
|
||||
btTransform tr = body->getWorldTransform();
|
||||
tr.setOrigin(btVector3(position.x,position.y,position.z));
|
||||
body->setWorldTransform(tr);
|
||||
}
|
||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
||||
{
|
||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||
// start positions others than 0, 0, 0
|
||||
act->setPosition(btVector3(position.x,position.y,position.z));
|
||||
}
|
||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||
// start positions others than 0, 0, 0
|
||||
btTransform tr = body->getWorldTransform();
|
||||
tr.setOrigin(btVector3(position.x,position.y,position.z));
|
||||
body->setWorldTransform(tr);
|
||||
}
|
||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
||||
{
|
||||
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||
// start positions others than 0, 0, 0
|
||||
act->setPosition(btVector3(position.x,position.y,position.z));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace MWWorld
|
|||
|
||||
void removeObject (const std::string& handle);
|
||||
|
||||
void moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics);
|
||||
void moveObject (const std::string& handle, const Ogre::Vector3& position);
|
||||
|
||||
void rotateObject (const std::string& handle, const Ogre::Quaternion& rotation);
|
||||
|
||||
|
|
|
@ -29,16 +29,10 @@ namespace MWWorld
|
|||
delete mClass;
|
||||
}
|
||||
|
||||
void Player::setPos(float x, float y, float z, bool updateCamera)
|
||||
void Player::setPos(float x, float y, float z)
|
||||
{
|
||||
/// \todo This fcuntion should be removed during the mwrender-refactoring.
|
||||
mWorld.moveObject (getPlayer(), x, y, z);
|
||||
|
||||
if (updateCamera)
|
||||
mRenderer->getCamera()->setPosition (Ogre::Vector3 (
|
||||
mPlayer.ref.pos.pos[0],
|
||||
mPlayer.ref.pos.pos[2],
|
||||
-mPlayer.ref.pos.pos[1]));
|
||||
}
|
||||
|
||||
void Player::setClass (const ESM::Class& class_)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace MWWorld
|
|||
~Player();
|
||||
|
||||
/// Set the player position. Uses Morrowind coordinates.
|
||||
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
||||
void setPos(float x, float y, float z);
|
||||
|
||||
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace MWWorld
|
|||
bool adjustPlayerPos)
|
||||
{
|
||||
if (adjustPlayerPos)
|
||||
mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2], false);
|
||||
mWorld->getPlayer().setPos (position.pos[0], position.pos[1], position.pos[2]);
|
||||
|
||||
mWorld->getPlayer().setCell (cell);
|
||||
// TODO orientation
|
||||
|
@ -187,7 +187,7 @@ namespace MWWorld
|
|||
return mCellChanged;
|
||||
}
|
||||
|
||||
const std::map<Ptr::CellStore *, MWRender::CellRender *>& Scene::getActiveCells ()
|
||||
const Scene::CellRenderCollection& Scene::getActiveCells() const
|
||||
{
|
||||
return mActiveCells;
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@ namespace MWWorld
|
|||
|
||||
public:
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
||||
|
||||
private:
|
||||
|
||||
MWRender::MWScene& mScene;
|
||||
Ptr::CellStore *mCurrentCell; // the cell, the player is in
|
||||
CellRenderCollection mActiveCells;
|
||||
|
@ -65,12 +65,11 @@ namespace MWWorld
|
|||
World *mWorld;
|
||||
PhysicsSystem *mPhysics;
|
||||
|
||||
|
||||
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
|
||||
bool adjustPlayerPos = true);
|
||||
public:
|
||||
|
||||
Scene (Environment& environment, World *world, MWRender::MWScene& scene, PhysicsSystem *physics);
|
||||
Scene (Environment& environment, World *world, MWRender::MWScene& scene, PhysicsSystem *physics);
|
||||
|
||||
~Scene();
|
||||
|
||||
|
@ -84,7 +83,7 @@ namespace MWWorld
|
|||
|
||||
Ptr::CellStore* getCurrentCell ();
|
||||
|
||||
const CellRenderCollection& getActiveCells ();
|
||||
const CellRenderCollection& getActiveCells () const;
|
||||
|
||||
bool hasCellChanged() const;
|
||||
///< Has the player moved to a different cell, since the last frame?
|
||||
|
@ -97,7 +96,7 @@ namespace MWWorld
|
|||
|
||||
void markCellAsUnchanged();
|
||||
|
||||
std::string getFacedHandle();
|
||||
// std::string getFacedHandle();
|
||||
|
||||
void insertCell(ESMS::CellStore<MWWorld::RefData> &cell);
|
||||
};
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace MWWorld
|
|||
|
||||
MWRender::CellRender *World::searchRender (Ptr::CellStore *store)
|
||||
{
|
||||
CellRenderCollection::const_iterator iter = mWorldScene->getActiveCells().find (store);
|
||||
Scene::CellRenderCollection::const_iterator iter = mWorldScene->getActiveCells().find (store);
|
||||
|
||||
if (iter!=mWorldScene->getActiveCells().end())
|
||||
{
|
||||
|
@ -405,7 +405,7 @@ namespace MWWorld
|
|||
}
|
||||
|
||||
// active cells
|
||||
for (CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
for (Scene::CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
iter!=mWorldScene->getActiveCells().end(); ++iter)
|
||||
{
|
||||
Ptr ptr = getPtr (name, *iter->first);
|
||||
|
@ -427,7 +427,7 @@ namespace MWWorld
|
|||
if (mPlayer->getPlayer().getRefData().getHandle()==handle)
|
||||
return mPlayer->getPlayer();
|
||||
|
||||
for (CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
for (Scene::CellRenderCollection::const_iterator iter (mWorldScene->getActiveCells().begin());
|
||||
iter!=mWorldScene->getActiveCells().end(); ++iter)
|
||||
{
|
||||
Ptr ptr = getPtrViaHandle (handle, *iter->first);
|
||||
|
@ -683,8 +683,7 @@ namespace MWWorld
|
|||
{
|
||||
moveObjectImp(ptr, x, y, z);
|
||||
|
||||
mPhysics->moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z),
|
||||
true);
|
||||
mPhysics->moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z));
|
||||
}
|
||||
|
||||
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
|
||||
|
@ -746,7 +745,7 @@ namespace MWWorld
|
|||
|
||||
bool World::toggleCollisionMode()
|
||||
{
|
||||
return mScene.toggleCollisionMode();
|
||||
return mPhysics->toggleCollisionMode();
|
||||
}
|
||||
|
||||
bool World::toggleRenderMode (RenderMode mode)
|
||||
|
|
|
@ -65,8 +65,6 @@ namespace MWWorld
|
|||
|
||||
private:
|
||||
|
||||
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
||||
|
||||
MWRender::MWScene mScene;
|
||||
MWWorld::Scene *mWorldScene;
|
||||
MWWorld::Player *mPlayer;
|
||||
|
@ -79,7 +77,7 @@ namespace MWWorld
|
|||
Environment& mEnvironment;
|
||||
MWRender::RenderingManager *mRenderingManager;
|
||||
int mNextDynamicRecord;
|
||||
|
||||
|
||||
std::map<std::string, Ptr::CellStore> mInteriors;
|
||||
std::map<std::pair<int, int>, Ptr::CellStore> mExteriors;
|
||||
|
||||
|
@ -96,9 +94,9 @@ namespace MWWorld
|
|||
MWRender::CellRender *searchRender (Ptr::CellStore *store);
|
||||
|
||||
int getDaysPerMonth (int month) const;
|
||||
|
||||
|
||||
void moveObjectImp (Ptr ptr, float x, float y, float z);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng,
|
||||
|
@ -107,9 +105,9 @@ namespace MWWorld
|
|||
Environment& environment, const std::string& encoding);
|
||||
|
||||
~World();
|
||||
|
||||
|
||||
Ptr::CellStore *getExterior (int x, int y);
|
||||
|
||||
|
||||
Ptr::CellStore *getInterior (std::string name);
|
||||
|
||||
void removeScripts (Ptr::CellStore *cell);
|
||||
|
@ -121,7 +119,7 @@ namespace MWWorld
|
|||
MWWorld::Player& getPlayer();
|
||||
|
||||
const ESMS::ESMStore& getStore() const;
|
||||
|
||||
|
||||
ESM::ESMReader& getEsmReader();
|
||||
|
||||
const ScriptList& getLocalScripts() const;
|
||||
|
|
Loading…
Reference in a new issue