1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-24 23:53:50 +00:00

Move element filtering back out of castRay().

This commit is contained in:
cc9cii 2014-11-12 22:28:41 +11:00
parent d65adc4376
commit 8c6890c682
4 changed files with 27 additions and 24 deletions

View file

@ -237,7 +237,8 @@ namespace CSVRender
// table feature & its data structure to be completed)
// Also need to signal PathgridPoint object of change
std::pair<std::string, float> result =
mPhysics->distToClosest(pos, getCamera(), 600); // snap
mPhysics->distToClosest(pos,
getCamera()->getViewport()->getVisibilityMask(), 600); // snap
if(result.first != "" && // don't allow pathgrid points under the cursor
!QString(result.first.c_str()).contains(QRegExp("^Pathgrid")))
@ -474,7 +475,20 @@ namespace CSVRender
float x = (float) mouseX / getViewport()->getActualWidth();
float y = (float) mouseY / getViewport()->getActualHeight();
return mPhysics->castRay(x, y, mSceneManager, getCamera(), elements);
std::pair<std::string, Ogre::Vector3> result = mPhysics->castRay(x, y, mSceneManager, getCamera());
if(result.first != "" &&
((elements & (Ogre::uint32)CSVRender::Element_Terrain &&
QString(result.first.c_str()).contains(QRegExp("^Height"))) ||
(elements & (Ogre::uint32)CSVRender::Element_Reference &&
QString(result.first.c_str()).contains(QRegExp("^ref#"))) ||
(elements & (Ogre::uint32)CSVRender::Element_Pathgrid &&
QString(result.first.c_str()).contains(QRegExp("^Pathgrid")))))
{
return result;
}
else
return std::make_pair("", Ogre::Vector3());
}
void MouseState::updateSceneWidgets()

View file

@ -73,7 +73,7 @@ namespace CSVRender
bool wheelEvent (QWheelEvent *event);
std::pair<std::string, Ogre::Vector3> underCursor(const int mouseX,
const int mouseY, Ogre::uint32 elements);
const int mouseY, Ogre::uint32 elements = 0xFFFFFFFF);
void cancelDrag();

View file

@ -214,8 +214,7 @@ namespace CSVWorld
// WARNING: far clip distance is a global setting, if it changes in future
// this method will need to be updated
std::pair<std::string, Ogre::Vector3> PhysicsSystem::castRay(float mouseX,
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera,
Ogre::uint32 elements)
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera)
{
// NOTE: there could be more than one camera for the scene manager
// TODO: check whether camera belongs to sceneMgr
@ -261,28 +260,19 @@ namespace CSVWorld
}
// result.first is the object's referenceId
if(result.first != "" &&
((elements & (Ogre::uint32)CSVRender::Element_Terrain &&
QString(result.first.c_str()).contains(QRegExp("^Height"))) ||
(elements & (Ogre::uint32)CSVRender::Element_Reference &&
QString(result.first.c_str()).contains(QRegExp("^ref#"))) ||
(elements & (Ogre::uint32)CSVRender::Element_Pathgrid &&
QString(result.first.c_str()).contains(QRegExp("^Pathgrid")))))
{
return std::make_pair(result.first, ray.getPoint(farClipDist*result.second));
}
else
if(result.first == "")
return std::make_pair("", Ogre::Vector3());
else
return std::make_pair(result.first, ray.getPoint(farClipDist*result.second));
}
std::pair<std::string, float> PhysicsSystem::distToGround(const Ogre::Vector3 &position,
Ogre::Camera *camera, const float limit, bool ignorePgPoint)
Ogre::uint32 visibilityMask, const float limit, bool ignorePgPoint)
{
btVector3 _from, _to;
_from = btVector3(position.x, position.y, position.z);
_to = btVector3(position.x, position.y, position.z-limit);
Ogre::uint32 visibilityMask = camera->getViewport()->getVisibilityMask();
bool ignoreHeightMap = !(visibilityMask & (Ogre::uint32)CSVRender::Element_Terrain);
bool ignoreObjects = !(visibilityMask & (Ogre::uint32)CSVRender::Element_Reference);
bool ignorePathgrid = ignorePgPoint ||
@ -315,13 +305,13 @@ namespace CSVWorld
// tries to find the distance to the "top" of the closest object
std::pair<std::string, float> PhysicsSystem::distToClosest(const Ogre::Vector3 &position,
Ogre::Camera *camera, const float limit)
Ogre::uint32 visibilityMask, const float limit)
{
const float thickness = 50; // arbitrary number
std::pair<std::string, float> resDown =
distToGround(Ogre::Vector3(position.x, position.y, position.z+thickness),
camera, limit+thickness, true);
visibilityMask, limit+thickness, true);
if(resDown.first != "")
return std::make_pair(resDown.first, resDown.second-thickness);

View file

@ -73,14 +73,13 @@ namespace CSVWorld
// return the object's SceneNode name and position for the given SceneManager
std::pair<std::string, Ogre::Vector3> castRay(float mouseX,
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera,
Ogre::uint32 elements = 0xFFFFFFFF);
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera);
std::pair<std::string, float> distToGround(const Ogre::Vector3 &position,
Ogre::Camera *camera, const float limit = 300000, bool ignorePgPoint = false);
Ogre::uint32 visibilityMask, const float limit = 300000, bool ignorePgPoint = false);
std::pair<std::string, float> distToClosest(const Ogre::Vector3 &position,
Ogre::Camera *camera, const float limit = 100.0f);
Ogre::uint32 visibilityMask, const float limit = 100.0f);
std::string refIdToSceneNode(std::string referenceId, Ogre::SceneManager *sceneMgr);