public void DestroyZone( PCZone zone, bool destroySceneNodes )
{
// need to remove this zone from all lights affected zones list,
// otherwise next frame _calcZonesAffectedByLights will call PCZLight::getNeedsUpdate()
// which will try to access the zone pointer and will cause an access violation
//HACK: again...
MovableObjectCollection lightList = GetMovableObjectCollection( LightFactory.TypeName );
lock ( lightList )
{
foreach ( PCZLight l in lightList.Values )
{
if ( l.NeedsUpdate )
{
// no need to check, this function does that anyway. if exists, is erased.
l.RemoveZoneFromAffectedZonesList( zone );
}
}
}
// if not destroying scene nodes, then make sure any nodes who have
foreach ( PCZSceneNode pczsn in sceneNodeList.Values )
{
if ( !destroySceneNodes )
{
if ( pczsn.HomeZone == zone )
{
pczsn.HomeZone = null;
}
}
// reset all node visitor lists
// note, it might be more efficient to only do this to nodes which
// are actually visiting the zone being destroyed, but visitor lists
// get cleared every frame anyway, so it's not THAT big a deal.
pczsn.ClearNodeFromVisitedZones();
}
zones.Remove( zone );
}