From Domenico Mangieri:
"I've added a Plane constructor which accepts a normal and a point. I also removed calculateUpperLowerBBCorners() from the Plane(const Vec3& v1, const Vec3& v2, const Vec3& v3) since the constructor is using the function set(const Vec3& v1, const Vec3& v2, const Vec3& v3) which already computes the upper and lower bounding box."
This commit is contained in:
parent
c0d6126313
commit
b50ac89b9d
@ -31,12 +31,13 @@ class OSG_EXPORT Plane
|
||||
|
||||
public:
|
||||
|
||||
inline Plane():_fv(0.0f,0.0f,0.0f,0.0f) { _lowerBBCorner = 0; _upperBBCorner = 0; }
|
||||
inline Plane(const Plane& pl):_fv(pl._fv) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(float a,float b,float c,float d):_fv(a,b,c,d) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(const Vec4& vec):_fv(vec) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(const Vec3& norm,float d):_fv(norm[0],norm[1],norm[2],d) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(const Vec3& v1, const Vec3& v2, const Vec3& v3) { set(v1,v2,v3); calculateUpperLowerBBCorners(); }
|
||||
inline Plane():_fv(0.0f,0.0f,0.0f,0.0f) { _lowerBBCorner = 0; _upperBBCorner = 0; }
|
||||
inline Plane(const Plane& pl):_fv(pl._fv) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(float a,float b,float c,float d):_fv(a,b,c,d) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(const Vec4& vec):_fv(vec) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(const Vec3& norm,float d):_fv(norm[0],norm[1],norm[2],d) { calculateUpperLowerBBCorners(); }
|
||||
inline Plane(const Vec3& v1, const Vec3& v2, const Vec3& v3) { set(v1,v2,v3); }
|
||||
inline Plane(const Vec3& norm, const Vec3& point) { set(norm,point); }
|
||||
|
||||
inline Plane& operator = (const Plane& pl)
|
||||
{
|
||||
@ -47,10 +48,10 @@ class OSG_EXPORT Plane
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void set(const Plane& pl) { _fv = pl._fv; calculateUpperLowerBBCorners(); }
|
||||
inline void set(float a,float b,float c,float d) { _fv.set(a,b,c,d); calculateUpperLowerBBCorners(); }
|
||||
inline void set(const Vec4& vec) { _fv = vec; calculateUpperLowerBBCorners(); }
|
||||
inline void set(const Vec3& norm,float d) { _fv.set(norm[0],norm[1],norm[2],d); calculateUpperLowerBBCorners(); }
|
||||
inline void set(const Plane& pl) { _fv = pl._fv; calculateUpperLowerBBCorners(); }
|
||||
inline void set(float a,float b,float c,float d) { _fv.set(a,b,c,d); calculateUpperLowerBBCorners(); }
|
||||
inline void set(const Vec4& vec) { _fv = vec; calculateUpperLowerBBCorners(); }
|
||||
inline void set(const Vec3& norm,float d) { _fv.set(norm[0],norm[1],norm[2],d); calculateUpperLowerBBCorners(); }
|
||||
inline void set(const Vec3& v1, const Vec3& v2, const Vec3& v3)
|
||||
{
|
||||
osg::Vec3 norm = (v2-v1)^(v3-v2);
|
||||
@ -100,12 +101,12 @@ class OSG_EXPORT Plane
|
||||
inline bool operator != (const Plane& plane) const { return _fv!=plane._fv; }
|
||||
inline bool operator < (const Plane& plane) const { return _fv<plane._fv; }
|
||||
|
||||
inline float* ptr() { return _fv.ptr(); }
|
||||
inline const float* ptr() const { return _fv.ptr(); }
|
||||
inline float* ptr() { return _fv.ptr(); }
|
||||
inline const float* ptr() const { return _fv.ptr(); }
|
||||
|
||||
inline Vec4& asVec4() { return _fv; }
|
||||
inline Vec4& asVec4() { return _fv; }
|
||||
|
||||
inline const Vec4& asVec4() const { return _fv; }
|
||||
inline const Vec4& asVec4() const { return _fv; }
|
||||
|
||||
inline float& operator [] (unsigned int i) { return _fv[i]; }
|
||||
inline float operator [] (unsigned int i) const { return _fv[i]; }
|
||||
@ -113,7 +114,7 @@ class OSG_EXPORT Plane
|
||||
|
||||
inline osg::Vec3 getNormal() const { return osg::Vec3(_fv[0],_fv[1],_fv[2]); }
|
||||
|
||||
/** calculate the distance between a point and the plane.*/
|
||||
/** calculate the distance between a point and the plane.*/
|
||||
inline float distance(const osg::Vec3& v) const
|
||||
{
|
||||
return _fv[0]*v.x()+
|
||||
@ -171,7 +172,7 @@ class OSG_EXPORT Plane
|
||||
return -1 if the bs is completely below the plane.*/
|
||||
inline int intersect(const BoundingBox& bb) const
|
||||
{
|
||||
// if lowest point above plane than all above.
|
||||
// if lowest point above plane than all above.
|
||||
if (distance(bb.corner(_lowerBBCorner))>0.0f) return 1;
|
||||
|
||||
// if highest point is below plane then all below.
|
||||
@ -208,7 +209,7 @@ class OSG_EXPORT Plane
|
||||
|
||||
protected:
|
||||
|
||||
Vec4 _fv;
|
||||
Vec4 _fv;
|
||||
|
||||
// variables cached to optimize calcs against bounding boxes.
|
||||
unsigned int _upperBBCorner;
|
||||
@ -217,6 +218,6 @@ class OSG_EXPORT Plane
|
||||
|
||||
};
|
||||
|
||||
} // end of namespace
|
||||
} // end of namespace
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user