mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 19:53:53 +00:00
Fix: castRenderingRay doesnt hit terrain
This commit is contained in:
parent
317aee134f
commit
dd77c81557
1 changed files with 7 additions and 1 deletions
|
@ -1061,9 +1061,15 @@ namespace MWRender
|
||||||
auto test = [&](const osgUtil::LineSegmentIntersector::Intersection& intersection) {
|
auto test = [&](const osgUtil::LineSegmentIntersector::Intersection& intersection) {
|
||||||
PtrHolder* ptrHolder = nullptr;
|
PtrHolder* ptrHolder = nullptr;
|
||||||
std::vector<RefnumMarker*> refnumMarkers;
|
std::vector<RefnumMarker*> refnumMarkers;
|
||||||
|
bool hitNonObjectWorld = false;
|
||||||
for (osg::NodePath::const_iterator it = intersection.nodePath.begin(); it != intersection.nodePath.end();
|
for (osg::NodePath::const_iterator it = intersection.nodePath.begin(); it != intersection.nodePath.end();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
|
// Terrain doesnt contain any user data ptrs or flags, so we have to check the name
|
||||||
|
// TODO: better solution for this that could also be used for water and other world pieces with flags
|
||||||
|
if (!hitNonObjectWorld)
|
||||||
|
hitNonObjectWorld = (*it)->getName() == std::string_view("Terrain Root");
|
||||||
|
|
||||||
osg::UserDataContainer* userDataContainer = (*it)->getUserDataContainer();
|
osg::UserDataContainer* userDataContainer = (*it)->getUserDataContainer();
|
||||||
if (!userDataContainer)
|
if (!userDataContainer)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1109,7 +1115,7 @@ namespace MWRender
|
||||||
vertexCounter += refnumMarkers[i]->mNumVertices;
|
vertexCounter += refnumMarkers[i]->mNumVertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.mHitObject.isEmpty() || result.mHitRefnum.isSet())
|
if (!result.mHitObject.isEmpty() || result.mHitRefnum.isSet() || hitNonObjectWorld)
|
||||||
{
|
{
|
||||||
result.mHit = true;
|
result.mHit = true;
|
||||||
result.mHitPointWorld = intersection.getWorldIntersectPoint();
|
result.mHitPointWorld = intersection.getWorldIntersectPoint();
|
||||||
|
|
Loading…
Reference in a new issue