diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c8b496f6b1..c4b086b891 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -884,13 +884,6 @@ void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr) MWBase::Environment::get().getWorld()->scaleObject(ptr, 1.f); } -void RenderingManager::getCameraData(Ogre::Vector3 &eyepos, float &pitch, float &yaw) -{ - eyepos = mCamera->getPosition(); - eyepos.z += mCamera->getHeight(); - mCamera->getSightAngles(pitch, yaw); -} - bool RenderingManager::vanityRotateCamera(const float *rot) { if(!mCamera->isVanityOrPreviewModeEnabled()) diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index b492a0db90..2111b89f19 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -87,8 +87,6 @@ public: bool vanityRotateCamera(const float *rot); - void getCameraData(Ogre::Vector3 &eyepos, float &pitch, float &yaw); - void setupPlayer(const MWWorld::Ptr &ptr); void renderPlayer(const MWWorld::Ptr &ptr); diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 7d63a2362e..3881523769 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -254,15 +254,12 @@ namespace MWWorld std::pair PhysicsSystem::getFacedHandle (MWWorld::World& world, float queryDistance) { - btVector3 dir(0, 1, 0); - dir = dir.rotate(btVector3(1, 0, 0), mCameraData.pitch); - dir = dir.rotate(btVector3(0, 0, 1), mCameraData.yaw); - dir.setX(-dir.x()); + Ray ray = mRender.getCamera()->getCameraToViewportRay(0.5, 0.5); - btVector3 origin(mCameraData.eyepos.x, - mCameraData.eyepos.y, - mCameraData.eyepos.z); - origin += dir * 5; + Ogre::Vector3 origin_ = ray.getOrigin(); + btVector3 origin(origin_.x, origin_.y, origin_.z); + Ogre::Vector3 dir_ = ray.getDirection().normalisedCopy(); + btVector3 dir(dir_.x, dir_.y, dir_.z); btVector3 dest = origin + dir * queryDistance; std::pair result; @@ -273,15 +270,12 @@ namespace MWWorld std::vector < std::pair > PhysicsSystem::getFacedHandles (float queryDistance) { - btVector3 dir(0, 1, 0); - dir = dir.rotate(btVector3(1, 0, 0), mCameraData.pitch); - dir = dir.rotate(btVector3(0, 0, 1), mCameraData.yaw); - dir.setX(-dir.x()); + Ray ray = mRender.getCamera()->getCameraToViewportRay(0.5, 0.5); - btVector3 origin(mCameraData.eyepos.x, - mCameraData.eyepos.y, - mCameraData.eyepos.z); - origin += dir * 5; + Ogre::Vector3 origin_ = ray.getOrigin(); + btVector3 origin(origin_.x, origin_.y, origin_.z); + Ogre::Vector3 dir_ = ray.getDirection().normalisedCopy(); + btVector3 dir(dir_.x, dir_.y, dir_.z); btVector3 dest = origin + dir * queryDistance; std::vector < std::pair > results; @@ -543,11 +537,4 @@ namespace MWWorld return true; } - - void PhysicsSystem::updateCameraData(const Ogre::Vector3 &eyepos, float pitch, float yaw) - { - mCameraData.eyepos = eyepos; - mCameraData.pitch = pitch; - mCameraData.yaw = yaw; - } } diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 7b48f880ee..d7e8532601 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -77,13 +77,7 @@ namespace MWWorld bool getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max); - void updateCameraData(const Ogre::Vector3 &eyepos, float pitch, float yaw); - private: - struct { - Ogre::Vector3 eyepos; - float pitch, yaw; - } mCameraData; OEngine::Render::OgreRenderer &mRender; OEngine::Physic::PhysicEngine* mEngine; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 5c7a400503..a479c9a141 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1234,11 +1234,6 @@ namespace MWWorld mWorldScene->update (duration, paused); - float pitch, yaw; - Ogre::Vector3 eyepos; - mRendering->getCameraData(eyepos, pitch, yaw); - mPhysics->updateCameraData(eyepos, pitch, yaw); - performUpdateSceneQueries (); updateWindowManager ();