mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-24 00:39:49 +00:00
Merge pull request #2696 from akortunov/intersector
Fix LineSegmentIntersector usage
This commit is contained in:
commit
54e7e0c718
@ -150,12 +150,12 @@ void QuadTreeNode::traverseTo(ViewData* vd, float size, const osg::Vec2f& center
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuadTreeNode::intersect(ViewData* vd, TerrainLineIntersector* intersector)
|
void QuadTreeNode::intersect(ViewData* vd, TerrainLineIntersector& intersector)
|
||||||
{
|
{
|
||||||
if (!hasValidBounds())
|
if (!hasValidBounds())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!intersector->intersectAndClip(getBoundingBox()))
|
if (!intersector.intersectAndClip(getBoundingBox()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (getNumChildren() == 0)
|
if (getNumChildren() == 0)
|
||||||
|
@ -20,6 +20,14 @@ namespace Terrain
|
|||||||
_parent = intersector;
|
_parent = intersector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TerrainLineIntersector(osgUtil::LineSegmentIntersector* intersector) :
|
||||||
|
osgUtil::LineSegmentIntersector(intersector->getStart(), intersector->getEnd())
|
||||||
|
{
|
||||||
|
setPrecisionHint(intersector->getPrecisionHint());
|
||||||
|
_intersectionLimit = intersector->getIntersectionLimit();
|
||||||
|
_parent = intersector;
|
||||||
|
}
|
||||||
|
|
||||||
bool intersectAndClip(const osg::BoundingBox& bbInput)
|
bool intersectAndClip(const osg::BoundingBox& bbInput)
|
||||||
{
|
{
|
||||||
osg::Vec3d s(_start), e(_end);
|
osg::Vec3d s(_start), e(_end);
|
||||||
@ -98,7 +106,7 @@ namespace Terrain
|
|||||||
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);
|
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);
|
||||||
|
|
||||||
/// Adds all leaf nodes which intersect the line from start to end
|
/// Adds all leaf nodes which intersect the line from start to end
|
||||||
void intersect(ViewData* vd, TerrainLineIntersector* intersector);
|
void intersect(ViewData* vd, TerrainLineIntersector& intersector);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QuadTreeNode* mParent;
|
QuadTreeNode* mParent;
|
||||||
|
@ -362,11 +362,17 @@ void QuadTreeWorld::accept(osg::NodeVisitor &nv)
|
|||||||
if (!lineIntersector)
|
if (!lineIntersector)
|
||||||
throw std::runtime_error("Cannot update QuadTreeWorld: node visitor is not LineSegmentIntersector");
|
throw std::runtime_error("Cannot update QuadTreeWorld: node visitor is not LineSegmentIntersector");
|
||||||
|
|
||||||
osg::Matrix matrix = osg::Matrix::identity();
|
|
||||||
if (lineIntersector->getCoordinateFrame() == osgUtil::Intersector::CoordinateFrame::MODEL && iv->getModelMatrix() == 0)
|
if (lineIntersector->getCoordinateFrame() == osgUtil::Intersector::CoordinateFrame::MODEL && iv->getModelMatrix() == 0)
|
||||||
matrix = lineIntersector->getTransformation(*iv, osgUtil::Intersector::CoordinateFrame::MODEL);
|
{
|
||||||
osg::ref_ptr<TerrainLineIntersector> terrainIntersector (new TerrainLineIntersector(lineIntersector, matrix));
|
TerrainLineIntersector terrainIntersector(lineIntersector);
|
||||||
mRootNode->intersect(vd, terrainIntersector);
|
mRootNode->intersect(vd, terrainIntersector);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
osg::Matrix matrix(lineIntersector->getTransformation(*iv, lineIntersector->getCoordinateFrame()));
|
||||||
|
TerrainLineIntersector terrainIntersector(lineIntersector, matrix);
|
||||||
|
mRootNode->intersect(vd, terrainIntersector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user