00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef HAVE_CONFIG_H
00023 # include <simgear_config.h>
00024 #endif
00025
00026 #include "SGEnlargeBoundingBox.hxx"
00027 #include <osg/Drawable>
00028
00029 SGEnlargeBoundingBox::SGEnlargeBoundingBox(float offset) :
00030 _offset(offset)
00031 {
00032 }
00033
00034 SGEnlargeBoundingBox::SGEnlargeBoundingBox(const SGEnlargeBoundingBox& cb,
00035 const osg::CopyOp& copyOp) :
00036 osg::Drawable::ComputeBoundingBoxCallback(cb, copyOp),
00037 _offset(cb._offset)
00038 {
00039 }
00040
00041 osg::BoundingBox
00042 SGEnlargeBoundingBox::computeBound(const osg::Drawable& drawable) const
00043 {
00044 osg::BoundingBox bound = drawable.computeBound();
00045 if (!bound.valid())
00046 return bound;
00047 return osg::BoundingBox(bound._min - osg::Vec3(_offset, _offset, _offset),
00048 bound._max + osg::Vec3(_offset, _offset, _offset));
00049 }