Replaced DimensionMask naming with more appropriate PrimitiveMask nameing.
This commit is contained in:
@@ -24,13 +24,6 @@ namespace osgUtil
|
||||
class OSGUTIL_EXPORT PolytopeIntersector : public Intersector
|
||||
{
|
||||
public:
|
||||
/// dimension enum to specify primitive types to check.
|
||||
enum {
|
||||
DimZero = (1<<0), ///< check for points
|
||||
DimOne = (1<<1), ///< check for lines
|
||||
DimTwo = (1<<2), ///< check for triangles, quad
|
||||
AllDims = (DimZero | DimOne | DimTwo)
|
||||
};
|
||||
|
||||
/** Construct a PolytopeIntersector using specified polytope in MODEL coordinates.*/
|
||||
PolytopeIntersector(const osg::Polytope& polytope);
|
||||
@@ -93,15 +86,20 @@ class OSGUTIL_EXPORT PolytopeIntersector : public Intersector
|
||||
|
||||
inline Intersection getFirstIntersection() { Intersections& intersections = getIntersections(); return intersections.empty() ? Intersection() : *(intersections.begin()); }
|
||||
|
||||
inline unsigned int getDimensionMask() const { return _dimensionMask; }
|
||||
|
||||
/** set the dimension mask.
|
||||
* As polytope-triangle and polytope-quad intersections are expensive to compute
|
||||
* it is possible to turn them off by calling setDimensionMask( DimZero | DimOne )
|
||||
*/
|
||||
inline void setDimensionMask(unsigned int dimensionMask) { _dimensionMask = dimensionMask; }
|
||||
/// dimension enum to specify primitive types to check.
|
||||
enum {
|
||||
POINT_PRIMITIVES = (1<<0), /// check for points
|
||||
LINE_PRIMITIVES = (1<<1), /// check for lines
|
||||
TRIANGLE_PRIMITIVES = (1<<2), /// check for triangles and other primitives like quad, polygons that can be decomposed into triangles
|
||||
ALL_PRIMITIVES = ( POINT_PRIMITIVES | LINE_PRIMITIVES | TRIANGLE_PRIMITIVES )
|
||||
};
|
||||
|
||||
inline const osg::Plane& getReferencePlane() const { return _referencePlane; }
|
||||
/** Set which Primitives should be tested for intersections.*/
|
||||
void setPrimitiveMask(unsigned int mask) { _primitiveMask = mask; }
|
||||
|
||||
/** Get which Primitives should be tested for intersections.*/
|
||||
unsigned int getPrimitiveMask() const { return _primitiveMask; }
|
||||
|
||||
/** set the plane used to sort the intersections.
|
||||
* The intersections are sorted by the distance of the localIntersectionPoint
|
||||
@@ -110,7 +108,25 @@ class OSGUTIL_EXPORT PolytopeIntersector : public Intersector
|
||||
*/
|
||||
inline void setReferencePlane(const osg::Plane& plane) { _referencePlane = plane; }
|
||||
|
||||
public:
|
||||
inline const osg::Plane& getReferencePlane() const { return _referencePlane; }
|
||||
|
||||
#ifdef USE_DEPRECATED_API
|
||||
|
||||
enum {
|
||||
DimZero = POINT_PRIMITIVES, /// deprecated, use POINT_PRIMITIVES
|
||||
DimOne = LINE_PRIMITIVES, /// deprecated, use POINT_PRIMITIVES
|
||||
DimTwo = TRIANGLE_PRIMITIVES, /// deprecated, use POINT_PRIMITIVES
|
||||
AllDims = ALL_PRIMITIVES /// deprecated, use ALL_PRIMITIVES
|
||||
};
|
||||
|
||||
/** deprecated, use setPrimtiveMask() */
|
||||
inline void setDimensionMask(unsigned int mask) { setPrimitiveMask(mask); }
|
||||
|
||||
/** deprecated, use getPrimtiveMask() */
|
||||
inline unsigned int getDimensionMask() const { return getPrimitiveMask(); }
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
virtual Intersector* clone(osgUtil::IntersectionVisitor& iv);
|
||||
|
||||
@@ -130,7 +146,7 @@ class OSGUTIL_EXPORT PolytopeIntersector : public Intersector
|
||||
|
||||
osg::Polytope _polytope;
|
||||
|
||||
unsigned int _dimensionMask; ///< mask which dimensions should be checked
|
||||
unsigned int _primitiveMask; ///< mask which dimensions should be checked
|
||||
osg::Plane _referencePlane; ///< plane to use for sorting intersections
|
||||
|
||||
Intersections _intersections;
|
||||
|
||||
@@ -33,14 +33,14 @@ struct Settings : public osg::Referenced
|
||||
_iv(0),
|
||||
_drawable(0),
|
||||
_limitOneIntersection(false),
|
||||
_dimensionMask( PolytopeIntersector::AllDims ) {}
|
||||
_primitiveMask( PolytopeIntersector::ALL_PRIMITIVES ) {}
|
||||
|
||||
osgUtil::PolytopeIntersector* _polytopeIntersector;
|
||||
osgUtil::IntersectionVisitor* _iv;
|
||||
osg::Drawable* _drawable;
|
||||
osg::ref_ptr<osg::Vec3Array> _vertices;
|
||||
bool _limitOneIntersection;
|
||||
unsigned int _dimensionMask;
|
||||
unsigned int _primitiveMask;
|
||||
};
|
||||
|
||||
template<typename Vec3>
|
||||
@@ -258,7 +258,7 @@ struct IntersectFunctor
|
||||
|
||||
++_primitiveIndex;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimZero)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::POINT_PRIMITIVES)==0) return;
|
||||
|
||||
// initialize the set of vertices to test.
|
||||
src.clear();
|
||||
@@ -295,7 +295,7 @@ struct IntersectFunctor
|
||||
|
||||
++_primitiveIndex;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimOne)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::LINE_PRIMITIVES)==0) return;
|
||||
|
||||
src.clear();
|
||||
src.push_back(v0);
|
||||
@@ -314,7 +314,7 @@ struct IntersectFunctor
|
||||
|
||||
++_primitiveIndex;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimTwo)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) return;
|
||||
|
||||
src.clear();
|
||||
src.push_back(v0);
|
||||
@@ -334,7 +334,7 @@ struct IntersectFunctor
|
||||
|
||||
++_primitiveIndex;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimTwo)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) return;
|
||||
|
||||
src.clear();
|
||||
|
||||
@@ -354,7 +354,7 @@ struct IntersectFunctor
|
||||
{
|
||||
if (_settings->_limitOneIntersection && _hit) return;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimZero)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::POINT_PRIMITIVES)==0) return;
|
||||
|
||||
if (contains((*vertices)[p0]))
|
||||
{
|
||||
@@ -368,7 +368,7 @@ struct IntersectFunctor
|
||||
{
|
||||
if (_settings->_limitOneIntersection && _hit) return;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimOne)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::LINE_PRIMITIVES)==0) return;
|
||||
|
||||
if (contains((*vertices)[p0], (*vertices)[p1]))
|
||||
{
|
||||
@@ -382,7 +382,7 @@ struct IntersectFunctor
|
||||
{
|
||||
if (_settings->_limitOneIntersection && _hit) return;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimTwo)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) return;
|
||||
|
||||
if (contains((*vertices)[p0], (*vertices)[p1], (*vertices)[p2]))
|
||||
{
|
||||
@@ -396,7 +396,7 @@ struct IntersectFunctor
|
||||
{
|
||||
if (_settings->_limitOneIntersection && _hit) return;
|
||||
|
||||
if ((_settings->_dimensionMask&PolytopeIntersector::DimTwo)==0) return;
|
||||
if ((_settings->_primitiveMask&PolytopeIntersector::TRIANGLE_PRIMITIVES)==0) return;
|
||||
|
||||
if (contains((*vertices)[p0], (*vertices)[p1], (*vertices)[p2], (*vertices)[p3]))
|
||||
{
|
||||
@@ -419,7 +419,7 @@ struct IntersectFunctor
|
||||
PolytopeIntersector::PolytopeIntersector(const osg::Polytope& polytope):
|
||||
_parent(0),
|
||||
_polytope(polytope),
|
||||
_dimensionMask( AllDims )
|
||||
_primitiveMask( ALL_PRIMITIVES )
|
||||
{
|
||||
if (!_polytope.getPlaneList().empty())
|
||||
{
|
||||
@@ -431,7 +431,7 @@ PolytopeIntersector::PolytopeIntersector(CoordinateFrame cf, const osg::Polytope
|
||||
Intersector(cf),
|
||||
_parent(0),
|
||||
_polytope(polytope),
|
||||
_dimensionMask( AllDims )
|
||||
_primitiveMask( ALL_PRIMITIVES )
|
||||
{
|
||||
if (!_polytope.getPlaneList().empty())
|
||||
{
|
||||
@@ -442,7 +442,7 @@ PolytopeIntersector::PolytopeIntersector(CoordinateFrame cf, const osg::Polytope
|
||||
PolytopeIntersector::PolytopeIntersector(CoordinateFrame cf, double xMin, double yMin, double xMax, double yMax):
|
||||
Intersector(cf),
|
||||
_parent(0),
|
||||
_dimensionMask( AllDims )
|
||||
_primitiveMask( ALL_PRIMITIVES )
|
||||
{
|
||||
double zNear = 0.0;
|
||||
switch(cf)
|
||||
@@ -469,7 +469,7 @@ Intersector* PolytopeIntersector::clone(osgUtil::IntersectionVisitor& iv)
|
||||
osg::ref_ptr<PolytopeIntersector> pi = new PolytopeIntersector(_polytope);
|
||||
pi->_parent = this;
|
||||
pi->_intersectionLimit = this->_intersectionLimit;
|
||||
pi->_dimensionMask = this->_dimensionMask;
|
||||
pi->_primitiveMask = this->_primitiveMask;
|
||||
pi->_referencePlane = this->_referencePlane;
|
||||
pi->setPrecisionHint(getPrecisionHint());
|
||||
return pi.release();
|
||||
@@ -506,7 +506,7 @@ Intersector* PolytopeIntersector::clone(osgUtil::IntersectionVisitor& iv)
|
||||
osg::ref_ptr<PolytopeIntersector> pi = new PolytopeIntersector(transformedPolytope);
|
||||
pi->_parent = this;
|
||||
pi->_intersectionLimit = this->_intersectionLimit;
|
||||
pi->_dimensionMask = this->_dimensionMask;
|
||||
pi->_primitiveMask = this->_primitiveMask;
|
||||
pi->_referencePlane = this->_referencePlane;
|
||||
pi->_referencePlane.transformProvidingInverse(matrix);
|
||||
pi->setPrecisionHint(getPrecisionHint());
|
||||
@@ -538,7 +538,7 @@ void PolytopeIntersector::intersect(osgUtil::IntersectionVisitor& iv, osg::Drawa
|
||||
settings->_iv = &iv;
|
||||
settings->_drawable = drawable;
|
||||
settings->_limitOneIntersection = (_intersectionLimit == LIMIT_ONE_PER_DRAWABLE || _intersectionLimit == LIMIT_ONE);
|
||||
settings->_dimensionMask = _dimensionMask;
|
||||
settings->_primitiveMask = _primitiveMask;
|
||||
|
||||
osg::KdTree* kdTree = iv.getUseKdTreeWhenAvailable() ? dynamic_cast<osg::KdTree*>(drawable->getShape()) : 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user