/** * @brief * Draws recursive */ void SRPVolume::DrawRec(Renderer &cRenderer, const SQCull &cCullQuery) { // Set the new scissor rectangle const VisContainer &cVisContainer = cCullQuery.GetVisContainer(); cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle); // Render all visible scene nodes of this scene container Iterator<VisNode*> cIterator = (GetFlags() & DrawOrderFrontToBack) ? cVisContainer.GetVisNodes().GetIterator() : cVisContainer.GetVisNodes().GetEndIterator(); while ((GetFlags() & DrawOrderFrontToBack) ? cIterator.HasNext() : cIterator.HasPrevious()) { // Get visibility node and scene node const VisNode *pVisNode = (GetFlags() & DrawOrderFrontToBack) ? cIterator.Next() : cIterator.Previous(); SceneNode *pSceneNode = pVisNode->GetSceneNode(); if (pSceneNode) { // Is this scene node a portal? if (pVisNode->IsPortal()) { // Get the target cell visibility container const VisContainer *pVisCell = static_cast<const VisPortal*>(pVisNode)->GetTargetVisContainer(); if (pVisCell && pVisCell->GetCullQuery()) { // Draw the target cell DrawRec(cRenderer, *pVisCell->GetCullQuery()); // Set the previous scissor rectangle cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle); } // Is this scene node a container? We do not need to check for cells because we will // NEVER receive cells from SQCull directly, they are ONLY visible through portals! (see above) } else if (pVisNode->IsContainer()) { // Draw this container without special processing if (static_cast<const VisContainer*>(pVisNode)->GetCullQuery()) { DrawRec(cRenderer, *static_cast<const VisContainer*>(pVisNode)->GetCullQuery()); // Set the previous scissor rectangle cRenderer.SetScissorRect(&cVisContainer.GetProjection().cRectangle); } // This must just be a quite boring scene node :) } else { // Do only take "PLVolume::SNVolume"-instances into account in here const static Class *pSNVolumeClass = ClassManager::GetInstance()->GetClass("PLVolume::SNVolume"); if (pSceneNode->GetClass() == pSNVolumeClass) DrawVolumeSceneNode(cRenderer, cCullQuery, *pVisNode); } } } }