public override void FindVisibleNodes( PCZCamera camera,
ref List<PCZSceneNode> visibleNodeList,
RenderQueue queue,
VisibleObjectsBoundsInfo visibleBounds,
bool onlyShadowCasters,
bool displayNodes,
bool showBoundingBoxes )
{
//return immediately if nothing is in the zone.
if ( mHomeNodeList.Count == 0 &&
mVisitorNodeList.Count == 0 &&
mPortals.Count == 0 )
return;
// Else, the zone is automatically assumed to be visible since either
// it is the camera the zone is in, or it was reached because
// a connecting portal was deemed visible to the camera.
// enable sky if called to do so for this zone
if ( HasSky )
{
// enable sky
mPCZSM.EnableSky( true );
}
// find visible nodes at home in the zone
bool vis;
foreach ( PCZSceneNode pczsn in mHomeNodeList )
{
//PCZSceneNode pczsn = *it;
// if the scene node is already visible, then we can skip it
if ( pczsn.LastVisibleFrame != mLastVisibleFrame ||
pczsn.LastVisibleFromCamera != camera )
{
FrustumPlane fPlane;
// for a scene node, check visibility using AABB
vis = camera.IsObjectVisible( pczsn.WorldAABB, out fPlane );
if ( vis )
{
// add it to the list of visible nodes
visibleNodeList.Add( pczsn );
// add the node to the render queue
pczsn.AddToRenderQueue( camera, queue, onlyShadowCasters, visibleBounds );
// if we are displaying nodes, add the node renderable to the queue
if ( displayNodes )
{
queue.AddRenderable( pczsn.GetDebugRenderable() );
}
// if the scene manager or the node wants the bounding box shown, add it to the queue
if ( pczsn.ShowBoundingBox || showBoundingBoxes )
{
pczsn.AddBoundingBoxToQueue( queue );
}
// flag the node as being visible this frame
pczsn.LastVisibleFrame = mLastVisibleFrame;
pczsn.LastVisibleFromCamera = camera;
}
}
}
// find visible visitor nodes
foreach ( PCZSceneNode pczsn in mVisitorNodeList )
{
// if the scene node is already visible, then we can skip it
if ( pczsn.LastVisibleFrame != mLastVisibleFrame ||
pczsn.LastVisibleFromCamera != camera )
{
FrustumPlane fPlane;
// for a scene node, check visibility using AABB
vis = camera.IsObjectVisible( pczsn.WorldAABB, out fPlane );
if ( vis )
{
// add it to the list of visible nodes
visibleNodeList.Add( pczsn );
// add the node to the render queue
pczsn.AddToRenderQueue( camera, queue, onlyShadowCasters, visibleBounds );
// if we are displaying nodes, add the node renderable to the queue
if ( displayNodes )
{
queue.AddRenderable( pczsn.GetDebugRenderable() );
}
// if the scene manager or the node wants the bounding box shown, add it to the queue
if ( pczsn.ShowBoundingBox || showBoundingBoxes )
{
pczsn.AddBoundingBoxToQueue( queue );
}
// flag the node as being visible this frame
pczsn.LastVisibleFrame = mLastVisibleFrame;
pczsn.LastVisibleFromCamera = camera;
}
}
}
// find visible portals in the zone and recurse into them
foreach ( Portal portal in mPortals )
{
FrustumPlane fPlane;
// for portal, check visibility using world bounding sphere & direction
vis = camera.IsObjectVisible( portal, out fPlane );
if ( vis )
{
// portal is visible. Add the portal as extra culling planes to camera
int planes_added = camera.AddPortalCullingPlanes( portal );
// tell target zone it's visible this frame
portal.getTargetZone().LastVisibleFrame = mLastVisibleFrame;
portal.getTargetZone().LastVisibleFromCamera = camera;
// recurse into the connected zone
portal.getTargetZone().FindVisibleNodes( camera,
ref visibleNodeList,
queue,
visibleBounds,
onlyShadowCasters,
displayNodes,
showBoundingBoxes );
if ( planes_added > 0 )
{
// Then remove the extra culling planes added before going to the next portal in this zone.
camera.RemovePortalCullingPlanes( portal );
}
}
}
}
// --- find nodes which intersect various types of BV's ---