A couple of API additions to osg::ClippingVolume, osg::Matrix and osg::Plane
sent in by Mike Connell.
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.*/
|
||||
/** A ClippingVolume class for representing convex clipping volumes made up.
|
||||
* When adding planes, their normals should point inwards (into the volume) */
|
||||
class SG_EXPORT ClippingVolume
|
||||
{
|
||||
|
||||
@@ -166,7 +167,31 @@ class SG_EXPORT ClippingVolume
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether the entire bounding sphere is contained within clipping set.*/
|
||||
inline const bool containsAllOf(const osg::BoundingSphere& bs) const
|
||||
{
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersect(bs)<1) return false; // intersects, or is below plane.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Check whether the entire bounding box is contained within clipping set.*/
|
||||
inline const bool containsAllOf(const osg::BoundingBox& bb) const
|
||||
{
|
||||
for(PlaneList::const_iterator itr=_planeList.begin();
|
||||
itr!=_planeList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->intersect(bb)<1) return false; // intersects, or is below plane.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Transform the clipping set by matrix. Note, this operations carries out
|
||||
* the calculation of the inverse of the matrix since to transforms
|
||||
* planes must be multiplied my the inverse transposed. This
|
||||
|
||||
@@ -178,8 +178,10 @@ class SG_EXPORT Matrix : public Object
|
||||
|
||||
void setTrans( float tx, float ty, float tz );
|
||||
void setTrans( const Vec3& v );
|
||||
Vec3 getTrans() const { return Vec3(_mat[3][0],_mat[3][1],_mat[3][2]); }
|
||||
|
||||
inline Vec3 getTrans() const { return Vec3(_mat[3][0],_mat[3][1],_mat[3][2]); }
|
||||
|
||||
inline Vec3 getScale() const { return Vec3(_mat[0][0],_mat[1][1],_mat[2][2]); }
|
||||
|
||||
/** apply apply an 3x3 transform of v*M[0..2,0..2] */
|
||||
inline static Vec3 transform3x3(const Vec3& v,const Matrix& m);
|
||||
/** apply apply an 3x3 transform of M[0..2,0..2]*v */
|
||||
|
||||
@@ -78,7 +78,9 @@ class SG_EXPORT Plane
|
||||
inline float operator [] (const int i) const { return _fv[i]; }
|
||||
|
||||
|
||||
/** calculate the distance between a point and the plane.*/
|
||||
inline osg::Vec3 getNormal() { return osg::Vec3(_fv[0],_fv[1],_fv[2]); }
|
||||
|
||||
/** calculate the distance between a point and the plane.*/
|
||||
inline const float distance(const osg::Vec3& v) const
|
||||
{
|
||||
return _fv[0]*v.x()+
|
||||
|
||||
Reference in New Issue
Block a user