mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-25 10:09:42 +00:00
Move element filtering back out of castRay().
This commit is contained in:
parent
d65adc4376
commit
8c6890c682
4 changed files with 27 additions and 24 deletions
|
@ -237,7 +237,8 @@ namespace CSVRender
|
||||||
// table feature & its data structure to be completed)
|
// table feature & its data structure to be completed)
|
||||||
// Also need to signal PathgridPoint object of change
|
// Also need to signal PathgridPoint object of change
|
||||||
std::pair<std::string, float> result =
|
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
|
if(result.first != "" && // don't allow pathgrid points under the cursor
|
||||||
!QString(result.first.c_str()).contains(QRegExp("^Pathgrid")))
|
!QString(result.first.c_str()).contains(QRegExp("^Pathgrid")))
|
||||||
|
@ -474,7 +475,20 @@ namespace CSVRender
|
||||||
float x = (float) mouseX / getViewport()->getActualWidth();
|
float x = (float) mouseX / getViewport()->getActualWidth();
|
||||||
float y = (float) mouseY / getViewport()->getActualHeight();
|
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()
|
void MouseState::updateSceneWidgets()
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace CSVRender
|
||||||
bool wheelEvent (QWheelEvent *event);
|
bool wheelEvent (QWheelEvent *event);
|
||||||
|
|
||||||
std::pair<std::string, Ogre::Vector3> underCursor(const int mouseX,
|
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();
|
void cancelDrag();
|
||||||
|
|
||||||
|
|
|
@ -214,8 +214,7 @@ namespace CSVWorld
|
||||||
// WARNING: far clip distance is a global setting, if it changes in future
|
// WARNING: far clip distance is a global setting, if it changes in future
|
||||||
// this method will need to be updated
|
// this method will need to be updated
|
||||||
std::pair<std::string, Ogre::Vector3> PhysicsSystem::castRay(float mouseX,
|
std::pair<std::string, Ogre::Vector3> PhysicsSystem::castRay(float mouseX,
|
||||||
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera,
|
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera)
|
||||||
Ogre::uint32 elements)
|
|
||||||
{
|
{
|
||||||
// NOTE: there could be more than one camera for the scene manager
|
// NOTE: there could be more than one camera for the scene manager
|
||||||
// TODO: check whether camera belongs to sceneMgr
|
// TODO: check whether camera belongs to sceneMgr
|
||||||
|
@ -261,28 +260,19 @@ namespace CSVWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
// result.first is the object's referenceId
|
// result.first is the object's referenceId
|
||||||
if(result.first != "" &&
|
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
|
|
||||||
return std::make_pair("", Ogre::Vector3());
|
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,
|
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;
|
btVector3 _from, _to;
|
||||||
_from = btVector3(position.x, position.y, position.z);
|
_from = btVector3(position.x, position.y, position.z);
|
||||||
_to = btVector3(position.x, position.y, position.z-limit);
|
_to = btVector3(position.x, position.y, position.z-limit);
|
||||||
|
|
||||||
Ogre::uint32 visibilityMask = camera->getViewport()->getVisibilityMask();
|
|
||||||
bool ignoreHeightMap = !(visibilityMask & (Ogre::uint32)CSVRender::Element_Terrain);
|
bool ignoreHeightMap = !(visibilityMask & (Ogre::uint32)CSVRender::Element_Terrain);
|
||||||
bool ignoreObjects = !(visibilityMask & (Ogre::uint32)CSVRender::Element_Reference);
|
bool ignoreObjects = !(visibilityMask & (Ogre::uint32)CSVRender::Element_Reference);
|
||||||
bool ignorePathgrid = ignorePgPoint ||
|
bool ignorePathgrid = ignorePgPoint ||
|
||||||
|
@ -315,13 +305,13 @@ namespace CSVWorld
|
||||||
|
|
||||||
// tries to find the distance to the "top" of the closest object
|
// tries to find the distance to the "top" of the closest object
|
||||||
std::pair<std::string, float> PhysicsSystem::distToClosest(const Ogre::Vector3 &position,
|
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
|
const float thickness = 50; // arbitrary number
|
||||||
|
|
||||||
std::pair<std::string, float> resDown =
|
std::pair<std::string, float> resDown =
|
||||||
distToGround(Ogre::Vector3(position.x, position.y, position.z+thickness),
|
distToGround(Ogre::Vector3(position.x, position.y, position.z+thickness),
|
||||||
camera, limit+thickness, true);
|
visibilityMask, limit+thickness, true);
|
||||||
|
|
||||||
if(resDown.first != "")
|
if(resDown.first != "")
|
||||||
return std::make_pair(resDown.first, resDown.second-thickness);
|
return std::make_pair(resDown.first, resDown.second-thickness);
|
||||||
|
|
|
@ -73,14 +73,13 @@ namespace CSVWorld
|
||||||
|
|
||||||
// return the object's SceneNode name and position for the given SceneManager
|
// return the object's SceneNode name and position for the given SceneManager
|
||||||
std::pair<std::string, Ogre::Vector3> castRay(float mouseX,
|
std::pair<std::string, Ogre::Vector3> castRay(float mouseX,
|
||||||
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera,
|
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera);
|
||||||
Ogre::uint32 elements = 0xFFFFFFFF);
|
|
||||||
|
|
||||||
std::pair<std::string, float> distToGround(const Ogre::Vector3 &position,
|
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,
|
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);
|
std::string refIdToSceneNode(std::string referenceId, Ogre::SceneManager *sceneMgr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue