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

Visibility mask working correctly.

This commit is contained in:
cc9cii 2014-11-09 17:53:54 +11:00
parent a5a76cadca
commit 895739d6bb
3 changed files with 26 additions and 6 deletions

View file

@ -315,7 +315,6 @@ float CSVRender::Cell::getTerrainHeightAt(const Ogre::Vector3 &pos) const
// FIXME:
// - updating indicies
// - collision mask
// - add pathgrid point above an object
// - adding edges
// - save to document & signals

View file

@ -285,6 +285,10 @@ namespace CSVRender
if(result.first != "")
{
// FIXME: terrain editing goes here
std::cout << "result default/edit release: " << result.first << std::endl;
std::cout << " hit pos "+ QString::number(result.second.x).toStdString()
+ ", " + QString::number(result.second.y).toStdString()
+ ", " + QString::number(result.second.z).toStdString() << std::endl;
}
break;
}
@ -456,6 +460,7 @@ namespace CSVRender
return std::make_pair("", Ogre::Vector3());
}
// NOTE: also returns pathgrids
std::pair<std::string, Ogre::Vector3> MouseState::objectUnderCursor(const int mouseX, const int mouseY)
{
if(!getViewport())
@ -473,8 +478,9 @@ namespace CSVRender
{
uint32_t visibilityMask = getViewport()->getVisibilityMask();
bool ignoreObjects = !(visibilityMask & (uint32_t)CSVRender::Element_Reference);
bool ignorePathgrid = !(visibilityMask & (uint32_t)CSVRender::Element_Pathgrid);
if(!ignoreObjects && mSceneManager->hasSceneNode(result.first))
if((!ignoreObjects || !ignorePathgrid) && mSceneManager->hasSceneNode(result.first))
{
return result;
}

View file

@ -243,14 +243,29 @@ namespace CSVWorld
uint32_t visibilityMask = camera->getViewport()->getVisibilityMask();
bool ignoreHeightMap = !(visibilityMask & (uint32_t)CSVRender::Element_Terrain);
bool ignoreObjects = !(visibilityMask & (uint32_t)CSVRender::Element_Reference);
bool ignorePathgrid = !(visibilityMask & (uint32_t)CSVRender::Element_Pathgrid);
Ogre::Vector3 norm; // not used
std::pair<std::string, float> result =
mEngine->rayTest(_from, _to, !ignoreObjects, ignoreHeightMap, &norm);
std::pair<std::string, float> result = std::make_pair("", -1);
short mask = OEngine::Physic::CollisionType_Raycasting;
std::vector<std::pair<float, std::string> > objects = mEngine->rayTest2(_from, _to, mask);
for (std::vector<std::pair<float, std::string> >::iterator it = objects.begin();
it != objects.end(); ++it)
{
if(ignorePathgrid && QString((*it).second.c_str()).contains(QRegExp("^Pathgrid")))
continue;
else if(ignoreObjects && QString((*it).second.c_str()).contains(QRegExp("^ref#")))
continue;
else if(ignoreHeightMap && QString((*it).second.c_str()).contains(QRegExp("^Height")))
continue;
result = std::make_pair((*it).second, (*it).first);
break;
}
// result.first is the object's referenceId
if(result.first == "")
return std::make_pair("", Ogre::Vector3(0,0,0));
return std::make_pair("", Ogre::Vector3());
else
{
// FIXME: maybe below logic belongs in the caller, i.e. terrainUnderCursor or