mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
using real player sight angles on ray cast
This commit is contained in:
parent
0e6e141fd4
commit
4f10138a04
1 changed files with 24 additions and 18 deletions
|
@ -16,8 +16,6 @@
|
|||
#include "ptr.hpp"
|
||||
#include "class.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Ogre;
|
||||
namespace MWWorld
|
||||
{
|
||||
|
@ -46,28 +44,36 @@ namespace MWWorld
|
|||
|
||||
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
||||
{
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||
mRender.getViewport()->getWidth()/2,
|
||||
mRender.getViewport()->getHeight()/2);
|
||||
//let's avoid the capsule shape of the player.
|
||||
centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection());
|
||||
btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y);
|
||||
btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y);
|
||||
btVector3 dir(0, 1, 0);
|
||||
dir = dir.rotate(btVector3(1, 0, 0), mPlayerData.pitch);
|
||||
dir = dir.rotate(btVector3(0, 0, 1), mPlayerData.yaw);
|
||||
dir.setX(-dir.x());
|
||||
|
||||
return mEngine->rayTest(from,to);
|
||||
btVector3 origin(
|
||||
mPlayerData.eyepos.x,
|
||||
mPlayerData.eyepos.y,
|
||||
mPlayerData.eyepos.z);
|
||||
origin += dir * 5;
|
||||
|
||||
btVector3 dest = origin + dir * 500;
|
||||
return mEngine->rayTest(origin, dest);
|
||||
}
|
||||
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedObjects ()
|
||||
{
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||
mRender.getViewport()->getWidth()/2,
|
||||
mRender.getViewport()->getHeight()/2);
|
||||
btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y);
|
||||
btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y);
|
||||
btVector3 dir(0, 1, 0);
|
||||
dir = dir.rotate(btVector3(1, 0, 0), mPlayerData.pitch);
|
||||
dir = dir.rotate(btVector3(0, 0, 1), mPlayerData.yaw);
|
||||
dir.setX(-dir.x());
|
||||
|
||||
return mEngine->rayTest2(from,to);
|
||||
btVector3 origin(
|
||||
mPlayerData.eyepos.x,
|
||||
mPlayerData.eyepos.y,
|
||||
mPlayerData.eyepos.z);
|
||||
origin += dir * 5;
|
||||
|
||||
btVector3 dest = origin + dir * 500;
|
||||
return mEngine->rayTest2(origin, dest);
|
||||
}
|
||||
|
||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedObjects (float mouseX, float mouseY)
|
||||
|
|
Loading…
Reference in a new issue