mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 09:36:43 +00:00
Merge branch 'collision' of git://github.com/zinnschlag/openmw.git into collisions
This commit is contained in:
commit
b03dec4ad4
8 changed files with 16 additions and 37 deletions
|
@ -183,7 +183,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
focusFrameCounter = 0;
|
focusFrameCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration);
|
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
||||||
|
mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -200,7 +200,7 @@ void MWScene::scaleObject (const std::string& handle, float scale)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWScene::setCollsionMode (bool enabled)
|
void MWScene::toggleCollisionMode()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,9 @@ namespace MWRender
|
||||||
/// Change object's scale.
|
/// Change object's scale.
|
||||||
void scaleObject (const std::string& handle, float scale);
|
void scaleObject (const std::string& handle, float scale);
|
||||||
|
|
||||||
/// Set collision mode for player. If disabled player object should ignore
|
/// Toggle collision mode for player. If disabled player object should ignore
|
||||||
/// collisions and gravity.
|
/// collisions and gravity.
|
||||||
void setCollsionMode (bool enabled);
|
void toggleCollisionMode();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace MWScript
|
||||||
InterpreterContext& context
|
InterpreterContext& context
|
||||||
= static_cast<InterpreterContext&> (runtime.getContext());
|
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
context.getWorld().getPlayer().toggleCollisionMode();
|
context.getWorld().toggleCollisionMode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
|
Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
|
||||||
mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0), mCollisionMode (true),
|
mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0),
|
||||||
mAutoMove (false), mForwardBackward (0)
|
mAutoMove (false), mForwardBackward (0)
|
||||||
{
|
{
|
||||||
mPlayer.base = player;
|
mPlayer.base = player;
|
||||||
|
@ -37,27 +37,6 @@ namespace MWWorld
|
||||||
-mPlayer.ref.pos.pos[1]));
|
-mPlayer.ref.pos.pos[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::moveRel (float &relX, float &relY, float &relZ)
|
|
||||||
{
|
|
||||||
// Move camera relative to its own direction
|
|
||||||
mRenderer->getCamera()->moveRelative (Ogre::Vector3(relX,0,relZ));
|
|
||||||
|
|
||||||
// Up/down movement is always done relative the world axis.
|
|
||||||
mRenderer->getCamera()->move (Ogre::Vector3(0,relY,0));
|
|
||||||
|
|
||||||
// Get new camera position, converting back to MW coords.
|
|
||||||
Ogre::Vector3 pos = mRenderer->getCamera()->getPosition();
|
|
||||||
relX = pos[0];
|
|
||||||
relY = -pos[2];
|
|
||||||
relZ = pos[1];
|
|
||||||
|
|
||||||
// TODO: Collision detection must be used to find the REAL new
|
|
||||||
// position, if mCollisionMode==true
|
|
||||||
|
|
||||||
// Set the position
|
|
||||||
setPos(relX, relY, relZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setClass (const ESM::Class& class_)
|
void Player::setClass (const ESM::Class& class_)
|
||||||
{
|
{
|
||||||
ESM::Class *new_class = new ESM::Class (class_);
|
ESM::Class *new_class = new ESM::Class (class_);
|
||||||
|
|
|
@ -29,7 +29,6 @@ namespace MWWorld
|
||||||
std::string mRace;
|
std::string mRace;
|
||||||
std::string mBirthsign;
|
std::string mBirthsign;
|
||||||
ESM::Class *mClass;
|
ESM::Class *mClass;
|
||||||
bool mCollisionMode;
|
|
||||||
bool mAutoMove;
|
bool mAutoMove;
|
||||||
int mForwardBackward;
|
int mForwardBackward;
|
||||||
|
|
||||||
|
@ -47,10 +46,6 @@ namespace MWWorld
|
||||||
mCellStore = cellStore;
|
mCellStore = cellStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Move the player relative to her own position and
|
|
||||||
/// orientation. After the call, the new position is returned.
|
|
||||||
void moveRel (float &relX, float &relY, float &relZ);
|
|
||||||
|
|
||||||
MWWorld::Ptr getPlayer()
|
MWWorld::Ptr getPlayer()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
||||||
|
@ -106,11 +101,6 @@ namespace MWWorld
|
||||||
return *mClass;
|
return *mClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleCollisionMode()
|
|
||||||
{
|
|
||||||
mCollisionMode = !mCollisionMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getAutoMove()
|
bool getAutoMove()
|
||||||
{
|
{
|
||||||
return mAutoMove;
|
return mAutoMove;
|
||||||
|
|
|
@ -855,4 +855,9 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
mScene.doPhysics (duration, *this, actors);
|
mScene.doPhysics (duration, *this, actors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::toggleCollisionMode()
|
||||||
|
{
|
||||||
|
mScene.toggleCollisionMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,6 +179,10 @@ namespace MWWorld
|
||||||
void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
|
void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
|
||||||
float duration);
|
float duration);
|
||||||
///< Run physics simulation and modify \a world accordingly.
|
///< Run physics simulation and modify \a world accordingly.
|
||||||
|
|
||||||
|
void toggleCollisionMode();
|
||||||
|
///< Toggle collision mode for player. If disabled player object should ignore
|
||||||
|
/// collisions and gravity.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue