From f2b6f8c8733b4bfea2678b3797e449b3a757feea Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 18 Jul 2002 10:55:04 +0000 Subject: [PATCH] Added code into osg::LightSource so it correctly computes its bounding sphere, taking into account any subgraph below, and the light itself if it is not a infinite light. --- src/osg/LightSource.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/osg/LightSource.cpp b/src/osg/LightSource.cpp index e15618e14..5e9aeb8bb 100644 --- a/src/osg/LightSource.cpp +++ b/src/osg/LightSource.cpp @@ -42,9 +42,21 @@ void LightSource::setLocalStateSetModes(const StateAttribute::GLModeValue value) const bool LightSource::computeBound() const { - // note, don't do anything right now as the light itself is not - // visualised, just having an effect on the lighting of geodes. - _bsphere.init(); + Group::computeBound(); + + if (_light.valid()) + { + const Light* light = dynamic_cast(_light.get()); + if (light) + { + const Vec4& pos = light->getPosition(); + if (pos[3]!=0.0f) + { + float div = 1.0f/pos[3]; + _bsphere.expandBy(Vec3(pos[0]*div,pos[1]*div,pos[2]*div)); + } + } + } _bsphere_computed = true;