|
|
|
@ -2,12 +2,31 @@
|
|
|
|
|
#define OPENMW_COMPONENTS_TERRAIN_QUADTREENODE_H
|
|
|
|
|
|
|
|
|
|
#include <osg/Group>
|
|
|
|
|
#include <osgUtil/LineSegmentIntersector>
|
|
|
|
|
|
|
|
|
|
#include "defs.hpp"
|
|
|
|
|
|
|
|
|
|
namespace Terrain
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class TerrainLineIntersector : public osgUtil::LineSegmentIntersector
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TerrainLineIntersector(osgUtil::LineSegmentIntersector* intersector, osg::Matrix& matrix) :
|
|
|
|
|
osgUtil::LineSegmentIntersector(intersector->getStart() * matrix, intersector->getEnd() * matrix)
|
|
|
|
|
{
|
|
|
|
|
setPrecisionHint(intersector->getPrecisionHint());
|
|
|
|
|
_intersectionLimit = intersector->getIntersectionLimit();
|
|
|
|
|
_parent = intersector;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool intersectAndClip(const osg::BoundingBox& bbInput)
|
|
|
|
|
{
|
|
|
|
|
osg::Vec3d s(_start), e(_end);
|
|
|
|
|
return osgUtil::LineSegmentIntersector::intersectAndClip(s, e, bbInput);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ChildDirection
|
|
|
|
|
{
|
|
|
|
|
NW = 0,
|
|
|
|
@ -72,9 +91,6 @@ namespace Terrain
|
|
|
|
|
/// center in cell coordinates
|
|
|
|
|
const osg::Vec2f& getCenter() const;
|
|
|
|
|
|
|
|
|
|
/// Traverse the child tree and populate the ViewData
|
|
|
|
|
virtual void traverse(osg::NodeVisitor& nv);
|
|
|
|
|
|
|
|
|
|
/// Optimized version of traverse() that doesn't incur the overhead of NodeVisitor double-dispatch or fetching the various variables.
|
|
|
|
|
/// Note this doesn't do any culling for non-cull visitors (e.g. intersections) so it shouldn't be used for those.
|
|
|
|
|
void traverse(ViewData* vd, osg::NodeVisitor* nv, const osg::Vec3f& viewPoint, bool visible, float maxDist);
|
|
|
|
@ -82,6 +98,9 @@ namespace Terrain
|
|
|
|
|
/// Traverse to a specific node and add only that node.
|
|
|
|
|
void traverseTo(ViewData* vd, float size, const osg::Vec2f& center);
|
|
|
|
|
|
|
|
|
|
/// Adds all leaf nodes which intersect the line from start to end
|
|
|
|
|
void intersect(ViewData* vd, TerrainLineIntersector* intersector);
|
|
|
|
|
|
|
|
|
|
/// Set the Lod callback to use for determining when to stop traversing further down the quad tree.
|
|
|
|
|
void setLodCallback(LodCallback* lodCallback);
|
|
|
|
|
|
|
|
|
|