protected override void FindLightsAffectingFrustum( Camera camera )
{
base.FindLightsAffectingFrustum( camera );
return;
// Similar to the basic SceneManager, we iterate through
// lights to see which ones affect the frustum. However,
// since we have camera & lights partitioned by zones,
// we can check only those lights which either affect the
// zone the camera is in, or affect zones which are visible to
// the camera
MovableObjectCollection lights = GetMovableObjectCollection( PCZLightFactory.TypeName );
lock ( lights )
{
foreach ( PCZLight l in lights.Values )
{
if ( l.IsVisible /* && l.AffectsVisibleZone */ )
{
LightInfo lightInfo;
lightInfo.light = l;
lightInfo.type = (int)l.Type;
if ( lightInfo.type == (int)LightType.Directional )
{
// Always visible
lightInfo.position = Vector3.Zero;
lightInfo.range = 0;
mTestLightInfos.Add( lightInfo );
}
else
{
// NB treating spotlight as point for simplicity
// Just see if the lights attenuation range is within the frustum
lightInfo.range = l.AttenuationRange;
lightInfo.position = l.DerivedPosition;
Sphere sphere = new Sphere( lightInfo.position, lightInfo.range );
if ( camera.IsObjectVisible( sphere ) )
{
mTestLightInfos.Add( lightInfo );
}
}
}
}
} // release lock on lights collection
base.FindLightsAffectingFrustum( camera );
// from here on down this function is same as Ogre::SceneManager
// Update lights affecting frustum if changed
if ( mCachedLightInfos != mTestLightInfos )
{
//mLightsAffectingFrustum.resize(mTestLightInfos.size());
//LightInfoList::const_iterator i;
//LightList::iterator j = mLightsAffectingFrustum.begin();
//for (i = mTestLightInfos.begin(); i != mTestLightInfos.end(); ++i, ++j)
//{
// *j = i->light;
// // add cam distance for sorting if texture shadows
// if (isShadowTechniqueTextureBased())
// {
// (*j)->tempSquareDist =
// (camera->getDerivedPosition() - (*j)->getDerivedPosition()).squaredLength();
// }
//}
foreach ( LightInfo i in mTestLightInfos )
{
if ( IsShadowTechniqueTextureBased )
{
i.light.TempSquaredDist = ( camera.DerivedPosition - i.light.DerivedPosition ).LengthSquared;
}
}
if ( IsShadowTechniqueTextureBased )
{
}
// Sort the lights if using texture shadows, since the first 'n' will be
// used to generate shadow textures and we should pick the most appropriate
//if (IsShadowTechniqueTextureBased)
//{
// // Allow a ShadowListener to override light sorting
// // Reverse iterate so last takes precedence
// bool overridden = false;
// foreach(object o in base.)
// for (ListenerList::reverse_iterator ri = mListeners.rbegin();
// ri != mListeners.rend(); ++ri)
// {
// overridden = (*ri)->sortLightsAffectingFrustum(mLightsAffectingFrustum);
// if (overridden)
// break;
// }
// if (!overridden)
// {
// // default sort (stable to preserve directional light ordering
// std::stable_sort(
// mLightsAffectingFrustum.begin(), mLightsAffectingFrustum.end(),
// lightsForShadowTextureLess());
// }
//}
// Use swap instead of copy operator for efficiently
//mCachedLightInfos.swap(mTestLightInfos);
mCachedLightInfos = mTestLightInfos;
// notify light dirty, so all movable objects will re-populate
// their light list next time
//_notifyLightsDirty();
//Check: do we have something like this here?
}
}