2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-01-22 00:45:36 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-01-22 00:45:36 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-01-22 00:45:36 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-06-05 17:39:04 +08:00
|
|
|
#include <osg/OccluderNode>
|
|
|
|
|
|
|
|
using namespace osg;
|
|
|
|
|
|
|
|
OccluderNode::OccluderNode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
OccluderNode::OccluderNode(const OccluderNode& node,const CopyOp& copyop):
|
|
|
|
Group(node,copyop),
|
2002-08-29 19:02:01 +08:00
|
|
|
_occluder(dynamic_cast<ConvexPlanarOccluder*>(copyop(node._occluder.get())))
|
2002-06-05 17:39:04 +08:00
|
|
|
{
|
|
|
|
}
|
2002-06-19 23:18:47 +08:00
|
|
|
|
2005-05-12 22:03:22 +08:00
|
|
|
BoundingSphere OccluderNode::computeBound() const
|
2002-06-19 23:18:47 +08:00
|
|
|
{
|
2005-05-12 22:03:22 +08:00
|
|
|
BoundingSphere bsphere(Group::computeBound());
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-19 23:18:47 +08:00
|
|
|
if (getOccluder())
|
|
|
|
{
|
|
|
|
BoundingBox bb;
|
2002-08-29 19:02:01 +08:00
|
|
|
const ConvexPlanarPolygon::VertexList& vertexList = getOccluder()->getOccluder().getVertexList();
|
|
|
|
for(ConvexPlanarPolygon::VertexList::const_iterator itr=vertexList.begin();
|
2002-06-19 23:18:47 +08:00
|
|
|
itr!=vertexList.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
bb.expandBy(*itr);
|
|
|
|
}
|
|
|
|
if (bb.valid())
|
|
|
|
{
|
2005-05-12 22:03:22 +08:00
|
|
|
bsphere.expandBy(bb);
|
2002-06-19 23:18:47 +08:00
|
|
|
}
|
|
|
|
}
|
2005-05-12 22:03:22 +08:00
|
|
|
return bsphere;
|
2002-06-19 23:18:47 +08:00
|
|
|
}
|