mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-18 13:12:50 +00:00
added object movement code in mwscene (will be replaced by physics code later); does not work well, because OpenEngine manipulates camera instead of player node
This commit is contained in:
parent
9c6bc4975c
commit
5c1aae3e26
@ -107,11 +107,23 @@ void MWScene::doPhysics (float duration, MWWorld::World& world)
|
||||
// stop changes to world from being reported back to the physics system
|
||||
MWWorld::DoingPhysics scopeGuard;
|
||||
|
||||
// move object directly for now -> TODO replace with physics
|
||||
for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (mMovement.begin());
|
||||
iter!=mMovement.end(); ++iter)
|
||||
{
|
||||
MWWorld::Ptr ptr = world.getPtrViaHandle (iter->first);
|
||||
|
||||
Ogre::SceneNode *sceneNode = rend.getScene()->getSceneNode (iter->first);
|
||||
|
||||
Ogre::Vector3 newPos = sceneNode->getPosition() + sceneNode->getOrientation() * iter->second;
|
||||
|
||||
world.moveObject (ptr, newPos.x, newPos.y, newPos.z);
|
||||
}
|
||||
}
|
||||
|
||||
void MWScene::setMovement (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
|
||||
{
|
||||
|
||||
mMovement = actors;
|
||||
}
|
||||
|
||||
void MWScene::addObject (const std::string& handle, const std::string& mesh,
|
||||
@ -131,8 +143,9 @@ void MWScene::removeObject (const std::string& handle)
|
||||
|
||||
}
|
||||
|
||||
void MWScene::moveObject (const std::string& handle, const Ogre::Vector3& position)
|
||||
void MWScene::moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics)
|
||||
{
|
||||
rend.getScene()->getSceneNode (handle)->setPosition (position);
|
||||
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
@ -40,6 +41,8 @@ namespace MWRender
|
||||
|
||||
MWRender::Player *mPlayer;
|
||||
|
||||
std::vector<std::pair<std::string, Ogre::Vector3> > mMovement;
|
||||
|
||||
public:
|
||||
|
||||
MWScene (OEngine::Render::OgreRenderer &_rend);
|
||||
@ -78,7 +81,7 @@ namespace MWRender
|
||||
void removeObject (const std::string& handle);
|
||||
|
||||
/// Move object.
|
||||
void moveObject (const std::string& handle, const Ogre::Vector3& position);
|
||||
void moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics);
|
||||
|
||||
/// Change object's orientation.
|
||||
void rotateObject (const std::string& handle, const Ogre::Quaternion& rotation);
|
||||
|
@ -510,7 +510,8 @@ namespace MWWorld
|
||||
|
||||
Ptr World::getPtrViaHandle (const std::string& handle)
|
||||
{
|
||||
// TODO player
|
||||
if (mPlayer->getPlayer().getRefData().getHandle()==handle)
|
||||
return mPlayer->getPlayer();
|
||||
|
||||
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
||||
iter!=mActiveCells.end(); ++iter)
|
||||
@ -804,12 +805,13 @@ namespace MWWorld
|
||||
changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false);
|
||||
}
|
||||
|
||||
if (!DoingPhysics::isDoingPhysics())
|
||||
mScene.moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mScene.moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z),
|
||||
!DoingPhysics::isDoingPhysics());
|
||||
|
||||
// TODO cell change for non-player ref
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user