mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
more cleanup; fixes for player handling during physics (unrelated to the actual refactoring bugs); fixed minor bug in character initialisation
This commit is contained in:
parent
4191bb32d1
commit
f8029aaa9e
@ -43,7 +43,7 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicE
|
||||
//used to obtain ingame information of ogre objects (which are faced or selected)
|
||||
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
||||
|
||||
Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode();
|
||||
Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode ("player");
|
||||
playerNode->pitch(Degree(90));
|
||||
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
|
||||
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
||||
|
@ -112,8 +112,6 @@ namespace MWWorld
|
||||
|
||||
void PhysicsSystem::moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics)
|
||||
{
|
||||
mRender.getScene()->getSceneNode(handle)->setPosition(position);
|
||||
|
||||
if(updatePhysics)//TODO: is it an actor? Done?
|
||||
{
|
||||
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
|
||||
|
@ -13,12 +13,14 @@ namespace MWWorld
|
||||
mAutoMove (false), mForwardBackward (0)
|
||||
{
|
||||
mPlayer.base = player;
|
||||
mPlayer.ref.refID = "player";
|
||||
mName = player->name;
|
||||
mMale = !(player->flags & ESM::NPC::Female);
|
||||
mRace = player->race;
|
||||
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
|
||||
std::cout << renderer->getHandle();
|
||||
mPlayer.mData.setHandle (renderer->getHandle());
|
||||
/// \todo Do not make a copy of classes defined in esm/p records.
|
||||
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
||||
}
|
||||
|
||||
@ -29,6 +31,7 @@ namespace MWWorld
|
||||
|
||||
void Player::setPos(float x, float y, float z, bool updateCamera)
|
||||
{
|
||||
/// \todo This fcuntion should be removed during the mwrender-refactoring.
|
||||
mWorld.moveObject (getPlayer(), x, y, z);
|
||||
|
||||
if (updateCamera)
|
||||
|
@ -245,7 +245,7 @@ namespace MWWorld
|
||||
{
|
||||
mCellChanged = false;
|
||||
}
|
||||
|
||||
|
||||
/*#include <cassert>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
@ -673,6 +673,12 @@ namespace MWWorld
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// \todo cell change for non-player ref
|
||||
|
||||
// \todo this should go into the new scene class and eventually into the objects/actors classes.
|
||||
mScene.getMgr()->getSceneNode (ptr.getRefData().getHandle())->
|
||||
setPosition (Ogre::Vector3 (x, y, z));
|
||||
}
|
||||
|
||||
void World::moveObject (Ptr ptr, float x, float y, float z)
|
||||
@ -680,9 +686,7 @@ namespace MWWorld
|
||||
moveObjectImp(ptr, x, y, z);
|
||||
|
||||
mPhysics->moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z),
|
||||
!DoingPhysics::isDoingPhysics());
|
||||
|
||||
// TODO cell change for non-player ref
|
||||
true);
|
||||
}
|
||||
|
||||
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
|
||||
@ -718,11 +722,27 @@ namespace MWWorld
|
||||
float duration)
|
||||
{
|
||||
std::vector< std::pair<std::string, Ogre::Vector3> > vectors = mPhysics->doPhysics (duration, actors);
|
||||
std::vector< std::pair<std::string, Ogre::Vector3> >::iterator it;
|
||||
for(it = vectors.begin(); it != vectors.end(); it++) {
|
||||
MWWorld::Ptr ptr = getPtrViaHandle (it->first);
|
||||
moveObject (ptr, it->second.x, it->second.y, it->second.z);
|
||||
std::vector< std::pair<std::string, Ogre::Vector3> >::iterator player = vectors.end();
|
||||
|
||||
for (std::vector< std::pair<std::string, Ogre::Vector3> >::iterator it = vectors.begin();
|
||||
it!= vectors.end(); ++it)
|
||||
{
|
||||
if (it->first=="player")
|
||||
{
|
||||
player = it;
|
||||
}
|
||||
else
|
||||
{
|
||||
MWWorld::Ptr ptr = getPtrViaHandle (it->first);
|
||||
moveObjectImp (ptr, it->second.x, it->second.y, it->second.z);
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure player is moved last (otherwise the cell might change in the middle of an update
|
||||
// loop)
|
||||
if (player!=vectors.end())
|
||||
moveObjectImp (getPtrViaHandle (player->first),
|
||||
player->second.x, player->second.y, player->second.z);
|
||||
}
|
||||
|
||||
bool World::toggleCollisionMode()
|
||||
|
Loading…
Reference in New Issue
Block a user