forked from teamnwah/openmw-tes3coop
Fixed issue with mouse picking accuracy.
This commit is contained in:
parent
fdee3fd919
commit
cca6d0a024
2 changed files with 8 additions and 9 deletions
apps/opencs/view
|
@ -51,7 +51,6 @@ namespace CSVRender
|
||||||
mCamera->setPosition (300, 0, 0);
|
mCamera->setPosition (300, 0, 0);
|
||||||
mCamera->lookAt (0, 0, 0);
|
mCamera->lookAt (0, 0, 0);
|
||||||
mCamera->setNearClipDistance (0.1);
|
mCamera->setNearClipDistance (0.1);
|
||||||
//mCamera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); // FIXME: debugging only
|
|
||||||
|
|
||||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
|
||||||
|
|
|
@ -110,12 +110,16 @@ namespace CSVWorld
|
||||||
/*std::pair<bool, Ogre::Vector3>*/ void PhysicsSystem::castRay(float mouseX, float mouseY,
|
/*std::pair<bool, Ogre::Vector3>*/ void PhysicsSystem::castRay(float mouseX, float mouseY,
|
||||||
Ogre::Vector3* normal, std::string* hit, Ogre::Camera *camera)
|
Ogre::Vector3* normal, std::string* hit, Ogre::Camera *camera)
|
||||||
{
|
{
|
||||||
|
// using a really small value seems to mess up with the projections
|
||||||
|
float nearClipDistance = camera->getNearClipDistance();
|
||||||
|
camera->setNearClipDistance(10.0f); // arbitrary number
|
||||||
Ogre::Ray ray = camera->getCameraToViewportRay(mouseX, mouseY);
|
Ogre::Ray ray = camera->getCameraToViewportRay(mouseX, mouseY);
|
||||||
|
camera->setNearClipDistance(nearClipDistance);
|
||||||
|
|
||||||
Ogre::Vector3 from = ray.getOrigin();
|
Ogre::Vector3 from = ray.getOrigin();
|
||||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat();
|
float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat();
|
||||||
Ogre::Vector3 to = ray.getPoint(farClipDist);
|
Ogre::Vector3 to = ray.getPoint(farClipDist);
|
||||||
//Ogre::Vector3 to = ray.getDirection();
|
|
||||||
|
|
||||||
btVector3 _from, _to;
|
btVector3 _from, _to;
|
||||||
_from = btVector3(from.x, from.y, from.z);
|
_from = btVector3(from.x, from.y, from.z);
|
||||||
|
@ -143,10 +147,6 @@ namespace CSVWorld
|
||||||
if(mSceneMgr->hasSceneNode(result.first))
|
if(mSceneMgr->hasSceneNode(result.first))
|
||||||
{
|
{
|
||||||
// FIXME: for debugging cursor position
|
// FIXME: for debugging cursor position
|
||||||
// If using orthographic projection the cursor position is very accurate,
|
|
||||||
// but with the default perspective view the cursor position is not properly
|
|
||||||
// calculated when using getCameraToViewportRay.
|
|
||||||
// See http://www.ogre3d.org/forums/viewtopic.php?p=241933
|
|
||||||
mSceneMgr->destroyManualObject("manual" + result.first);
|
mSceneMgr->destroyManualObject("manual" + result.first);
|
||||||
Ogre::ManualObject* manual = mSceneMgr->createManualObject("manual" + result.first);
|
Ogre::ManualObject* manual = mSceneMgr->createManualObject("manual" + result.first);
|
||||||
manual->begin("BaseWhite", Ogre::RenderOperation::OT_LINE_LIST);
|
manual->begin("BaseWhite", Ogre::RenderOperation::OT_LINE_LIST);
|
||||||
|
@ -155,17 +155,17 @@ namespace CSVWorld
|
||||||
ray.getPoint(farClipDist*result.second).z);
|
ray.getPoint(farClipDist*result.second).z);
|
||||||
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
||||||
ray.getPoint(farClipDist*result.second).y,
|
ray.getPoint(farClipDist*result.second).y,
|
||||||
ray.getPoint(farClipDist*result.second).z+2000);
|
ray.getPoint(farClipDist*result.second).z+1000);
|
||||||
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
||||||
ray.getPoint(farClipDist*result.second).y,
|
ray.getPoint(farClipDist*result.second).y,
|
||||||
ray.getPoint(farClipDist*result.second).z);
|
ray.getPoint(farClipDist*result.second).z);
|
||||||
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
||||||
ray.getPoint(farClipDist*result.second).y+2000,
|
ray.getPoint(farClipDist*result.second).y+1000,
|
||||||
ray.getPoint(farClipDist*result.second).z);
|
ray.getPoint(farClipDist*result.second).z);
|
||||||
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
manual-> position(ray.getPoint(farClipDist*result.second).x,
|
||||||
ray.getPoint(farClipDist*result.second).y,
|
ray.getPoint(farClipDist*result.second).y,
|
||||||
ray.getPoint(farClipDist*result.second).z);
|
ray.getPoint(farClipDist*result.second).z);
|
||||||
manual-> position(ray.getPoint(farClipDist*result.second).x+2000,
|
manual-> position(ray.getPoint(farClipDist*result.second).x+1000,
|
||||||
ray.getPoint(farClipDist*result.second).y,
|
ray.getPoint(farClipDist*result.second).y,
|
||||||
ray.getPoint(farClipDist*result.second).z);
|
ray.getPoint(farClipDist*result.second).z);
|
||||||
manual->end();
|
manual->end();
|
||||||
|
|
Loading…
Reference in a new issue