Various additions to better support view dependent overlay node, and updated wrappers
This commit is contained in:
@@ -216,6 +216,35 @@ class OSG_EXPORT Plane
|
||||
return -1; // treat points on line as outside...
|
||||
}
|
||||
|
||||
/** intersection test between plane and vertex list
|
||||
return 1 if the bs is completely above plane,
|
||||
return 0 if the bs intersects the plane,
|
||||
return -1 if the bs is completely below the plane.*/
|
||||
inline int intersect(const std::vector<Vec3d>& vertices) const
|
||||
{
|
||||
if (vertices.empty()) return -1;
|
||||
|
||||
int noAbove = 0;
|
||||
int noBelow = 0;
|
||||
int noOn = 0;
|
||||
for(std::vector<Vec3d>::const_iterator itr=vertices.begin();
|
||||
itr != vertices.end();
|
||||
++itr)
|
||||
{
|
||||
float d = distance(*itr);
|
||||
if (d>0.0f) ++noAbove;
|
||||
else if (d<0.0f) ++noBelow;
|
||||
else ++noOn;
|
||||
}
|
||||
|
||||
if (noAbove>0)
|
||||
{
|
||||
if (noBelow>0) return 0;
|
||||
else return 1;
|
||||
}
|
||||
return -1; // treat points on line as outside...
|
||||
}
|
||||
|
||||
/** intersection test between plane and bounding sphere.
|
||||
return 1 if the bs is completely above plane,
|
||||
return 0 if the bs intersects the plane,
|
||||
|
||||
@@ -59,13 +59,26 @@ class OSG_EXPORT Polytope
|
||||
/** Create a Polytope which is a cube, centered at 0,0,0, with sides of 2 units.*/
|
||||
void setToUnitFrustum(bool withNear=true, bool withFar=true)
|
||||
{
|
||||
_planeList.erase(_planeList.begin(),_planeList.end());
|
||||
_planeList.push_back(Plane(1.0f,0.0f,0.0f,1.0f)); // left plane.
|
||||
_planeList.push_back(Plane(-1.0f,0.0f,0.0f,1.0f)); // right plane.
|
||||
_planeList.push_back(Plane(0.0f,1.0f,0.0f,1.0f)); // bottom plane.
|
||||
_planeList.push_back(Plane(0.0f,-1.0f,0.0f,1.0f)); // top plane.
|
||||
if (withNear) _planeList.push_back(Plane(0.0f,0.0f,-1.0f,1.0f)); // near plane
|
||||
if (withFar) _planeList.push_back(Plane(0.0f,0.0f,1.0f,1.0f)); // far plane
|
||||
_planeList.clear();
|
||||
_planeList.push_back(Plane(1.0,0.0,0.0,1.0)); // left plane.
|
||||
_planeList.push_back(Plane(-1.0,0.0,0.0,1.0)); // right plane.
|
||||
_planeList.push_back(Plane(0.0,1.0,0.0,1.0)); // bottom plane.
|
||||
_planeList.push_back(Plane(0.0,-1.0,0.0,1.0)); // top plane.
|
||||
if (withNear) _planeList.push_back(Plane(0.0,0.0,-1.0,1.0)); // near plane
|
||||
if (withFar) _planeList.push_back(Plane(0.0,0.0,1.0,1.0)); // far plane
|
||||
setupMask();
|
||||
}
|
||||
|
||||
/** Create a Polytope which is a equivilant to BoundingBox.*/
|
||||
void setToBoundingBox(const BoundingBox& bb)
|
||||
{
|
||||
_planeList.clear();
|
||||
_planeList.push_back(Plane(1.0,0.0,0.0,-bb.xMin())); // left plane.
|
||||
_planeList.push_back(Plane(-1.0,0.0,0.0,bb.xMax())); // right plane.
|
||||
_planeList.push_back(Plane(0.0,1.0,0.0,-bb.yMin())); // bottom plane.
|
||||
_planeList.push_back(Plane(0.0,-1.0,0.0,bb.yMax())); // top plane.
|
||||
_planeList.push_back(Plane(0.0,0.0,-1.0,bb.zMin())); // near plane
|
||||
_planeList.push_back(Plane(0.0,0.0,1.0,bb.zMax())); // far plane
|
||||
setupMask();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user