1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version.  The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * OpenSceneGraph Public License for more details.
12 */
13 #include <osg/OccluderNode>
14 
15 using namespace osg;
16 
OccluderNode()17 OccluderNode::OccluderNode()
18 {
19 }
20 
OccluderNode(const OccluderNode & node,const CopyOp & copyop)21 OccluderNode::OccluderNode(const OccluderNode& node,const CopyOp& copyop):
22     Group(node,copyop),
23     _occluder(dynamic_cast<ConvexPlanarOccluder*>(copyop(node._occluder.get())))
24 {
25 }
26 
computeBound() const27 BoundingSphere OccluderNode::computeBound() const
28 {
29     BoundingSphere bsphere(Group::computeBound());
30 
31     if (getOccluder())
32     {
33         BoundingBox bb;
34         const ConvexPlanarPolygon::VertexList& vertexList = getOccluder()->getOccluder().getVertexList();
35         for(ConvexPlanarPolygon::VertexList::const_iterator itr=vertexList.begin();
36             itr!=vertexList.end();
37             ++itr)
38         {
39             bb.expandBy(*itr);
40         }
41         if (bb.valid())
42         {
43             bsphere.expandBy(bb);
44         }
45     }
46     return bsphere;
47 }
48