fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Action / RenderAction / OSGRenderAction.cpp
blob97284905f4880ba84ae59347a6c4afe8df8d282f
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGRenderAction.h"
50 #include "OSGRenderPartitionPool.h"
51 #include "OSGRenderTreeNodePool.h"
52 #include "OSGStateOverride.h"
53 #include "OSGStateSorter.h"
55 #include "OSGWindow.h"
56 #include "OSGRenderOptions.h"
57 #include "OSGCamera.h"
59 #include "OSGTextureBaseChunk.h"
60 #include "OSGMaterialChunk.h"
61 #include "OSGShaderExecutableChunk.h"
62 #include "OSGShaderExecutableVarChunk.h"
63 #include "OSGVolumeDraw.h"
64 #include "OSGTreeBuilderBase.h"
65 #include "OSGPrimeMaterial.h"
67 OSG_USING_NAMESPACE
69 /***************************************************************************\
70 * Description *
71 \***************************************************************************/
73 /***************************************************************************\
74 * Types *
75 \***************************************************************************/
77 /***************************************************************************\
78 * Class variables *
79 \***************************************************************************/
83 /*! \brief the prototype which is copied to create new actions
86 RenderAction *RenderAction::_pPrototype = NULL;
88 /*! \brief Default functors for instantiation
91 Action::FunctorStore *RenderAction::_vDefaultEnterFunctors = NULL;
92 Action::FunctorStore *RenderAction::_vDefaultLeaveFunctors = NULL;
95 StatElemDesc<StatTimeElem> RenderAction::statDrawTime (
96 "RT-DrawTime",
97 "time for draw tree traversal");
99 StatElemDesc<StatIntElem > RenderAction::statNMatrices (
100 "RT-NMatrices",
101 "number of matrix changes");
102 StatElemDesc<StatIntElem > RenderAction::statNStates (
103 "RT-States",
104 "number of material changes");
105 StatElemDesc<StatIntElem > RenderAction::statNChunks (
106 "RT-Chunks",
107 "number of chunk changes");
108 StatElemDesc<StatIntElem > RenderAction::statNShaders (
109 "RT-Shaders",
110 "number of shader changes");
111 StatElemDesc<StatIntElem > RenderAction::statNShaderParams(
112 "RT-ShaderParams",
113 "number of shader params changes");
115 /***************************************************************************\
116 * Class methods *
117 \***************************************************************************/
119 bool RenderAction::terminateEnter(void)
121 FDEBUG_GV(("Terminate RenderAction Enter\n"));
123 delete _vDefaultEnterFunctors;
125 _vDefaultEnterFunctors = NULL;
127 return true;
130 bool RenderAction::terminateLeave(void)
132 FDEBUG_GV(("Terminate RenderAction Leave\n"));
134 delete _vDefaultLeaveFunctors;
136 _vDefaultLeaveFunctors = NULL;
138 return true;
141 /*-------------------------------------------------------------------------*\
142 - public -
143 \*-------------------------------------------------------------------------*/
145 RenderAction::ObjTransitPtr RenderAction::create(void)
147 ObjTransitPtr returnValue(NULL);
149 if(_pPrototype)
151 returnValue = new RenderAction(*_pPrototype);
153 else
155 returnValue = new RenderAction();
158 return returnValue;
161 /*! \brief prototype access
162 * after setting the prototype all new DrawActions are clones of it
165 void RenderAction::setPrototype(RenderAction *pPrototype)
167 _pPrototype = pPrototype;
170 RenderAction *RenderAction::getPrototype(void)
172 return _pPrototype;
175 /*! \brief Default registration. static, so it can be called during static init
178 void RenderAction::registerEnterDefault(
179 const FieldContainerType &type,
180 const Action::Functor &func)
182 if(_vDefaultEnterFunctors == NULL)
184 _vDefaultEnterFunctors = new Action::FunctorStore;
186 addPostFactoryExitFunction(&RenderAction::terminateEnter);
189 while(type.getId() >= _vDefaultEnterFunctors->size())
191 _vDefaultEnterFunctors->push_back(&Action::_defaultEnterFunction);
194 FDEBUG_GV(("Register rendertrav for %s\n", type.getCName()));
196 (*_vDefaultEnterFunctors)[type.getId()] = func;
199 void RenderAction::registerLeaveDefault(
200 const FieldContainerType &type,
201 const Action::Functor &func)
203 if(_vDefaultLeaveFunctors == NULL)
205 _vDefaultLeaveFunctors = new Action::FunctorStore;
207 addPostFactoryExitFunction(&RenderAction::terminateLeave);
210 while(type.getId() >= _vDefaultLeaveFunctors->size())
212 _vDefaultLeaveFunctors->push_back(&Action::_defaultLeaveFunction);
215 FDEBUG_GV(("Register rendertrav leave for %s\n", type.getCName()));
217 (*_vDefaultLeaveFunctors)[type.getId()] = func;
222 /*-------------------------------------------------------------------------*\
223 - protected -
224 \*-------------------------------------------------------------------------*/
227 /*-------------------------------------------------------------------------*\
228 - private -
229 \*-------------------------------------------------------------------------*/
233 /***************************************************************************\
234 * Instance methods *
235 \***************************************************************************/
237 /*-------------------------------------------------------------------------*\
238 - public -
239 \*-------------------------------------------------------------------------*/
241 /*-------------------------- your_category---------------------------------*/
243 Action::ResultE RenderAction::start(void)
245 Inherited::start();
247 #if 0 // Not needed done by the partition setup anyway.
248 if(_pWindow != NULL && !_doCullOnly)
250 _pWindow->resizeGL();
252 #endif
254 if(_pViewarea != NULL && _pViewarea->getRenderOptions() != NULL)
256 _pViewarea->getRenderOptions()->activate(this);
258 else if(_pWindow != NULL && _pWindow->getRenderOptions() != NULL)
260 _pWindow->getRenderOptions()->activate(this);
263 _vRenderPartitions[_currentBuffer].clear ();
265 if(_bDrawPartPar == false)
267 _pPartitionPools [_currentBuffer]->freeAll();
268 _pNodePools [_currentBuffer]->freeAll();
269 _pStatePools [_currentBuffer]->freeAll();
270 _pTreeBuilderPools[_currentBuffer]->freeAll();
273 _pActivePartition = _pPartitionPools[_currentBuffer]->create();
275 _vRenderPartitions[_currentBuffer].push_back(_pActivePartition);
277 _iActivePartitionIdx = 0;
279 _pActivePartition->setKeyGen (_uiKeyGen );
280 _pActivePartition->setAction ( this );
281 _pActivePartition->setNodePool (_pNodePools [_currentBuffer]);
282 _pActivePartition->setStatePool (_pStatePools [_currentBuffer]);
283 _pActivePartition->setTreeBuilderPool(_pTreeBuilderPools[_currentBuffer]);
284 _pActivePartition->setStatCollector (_pStatistics );
286 _pActivePartition->setFrustum (_oFrustum );
288 _pActivePartition->setFrustumCulling (_bFrustumCulling );
289 _pActivePartition->setVolumeDrawing (_bVolumeDrawing );
290 _pActivePartition->setZWriteTrans (_bZWriteTrans );
291 _pActivePartition->setCorrectNegScale(_bCorrectTwoSidedLighting);
293 _pActivePartition->getDrawEnv().setDrawerId (_iDrawerId );
294 _pActivePartition->getDrawEnv().setDrawableId(_iDrawableId);
296 _pActivePartition->init();
298 if(_pGlobalOverride != NULL)
300 _pActivePartition->overrideMaterial(_pGlobalOverride,
301 NULL );
303 #ifdef OSG_DEBUGX
304 _pActivePartition->setDebugString("DefaultPartition");
305 #endif
308 // bool full = true;
310 if(_pViewarea != NULL)
312 // _pActivePartition->setViewport(_pViewport);
313 _pActivePartition->setWindow (_pWindow );
315 #if 0
316 _pActivePartition->setViewportDimension(_pViewport->getPixelLeft (),
317 _pViewport->getPixelBottom(),
318 _pViewport->getPixelRight (),
319 _pViewport->getPixelTop (),
320 _pViewport->isFullWindow ());
321 #endif
323 _pActivePartition->calcViewportDimension(_pViewarea->getLeft (),
324 _pViewarea->getBottom(),
325 _pViewarea->getRight (),
326 _pViewarea->getTop (),
328 _pWindow ->getWidth (),
329 _pWindow ->getHeight());
331 if(_pViewarea->isPassive() == true)
333 _pActivePartition->addSetupModeBit(RenderPartition::PassiveBit);
336 _pActivePartition->setRenderTarget(_pViewarea->getTarget());
338 if(_pCamera != NULL)
340 Matrix m, t;
342 // set the projection
343 #if 0
344 _pCamera->getProjection ( m,
345 _pViewport->getPixelWidth (),
346 _pViewport->getPixelHeight());
348 _pCamera->getProjectionTranslation( t,
349 _pViewport->getPixelWidth (),
350 _pViewport->getPixelHeight());
352 _pActivePartition->setupProjection(m, t);
354 _pCamera->getViewing( m,
355 _pViewport->getPixelWidth (),
356 _pViewport->getPixelHeight());
357 #endif
359 _pCamera->getProjection (
361 _pActivePartition->getViewportWidth (),
362 _pActivePartition->getViewportHeight());
364 _pCamera->getProjectionTranslation(
366 _pActivePartition->getViewportWidth (),
367 _pActivePartition->getViewportHeight());
369 _pActivePartition->setupProjection(m, t);
371 _pCamera->getViewing(
373 _pActivePartition->getViewportWidth (),
374 _pActivePartition->getViewportHeight());
377 _pActivePartition->setupViewing(m);
379 _pActivePartition->setNear(_pCamera->getNear());
380 _pActivePartition->setFar (_pCamera->getFar ());
382 _pActivePartition->getDrawEnv().setTileFullSize(
383 _pCamera->tileGetFullSize());
384 _pActivePartition->getDrawEnv().setTileRegion (
385 _pCamera->tileGetRegion ());
389 _pActivePartition->initVPMatricesFromCamera();
391 _pActivePartition->setBackground(_pBackground);
394 // fprintf(stderr, "Start\n");
396 if(_bDrawPartPar == true)
398 #ifdef OSG_RENPART_DUMP_PAR
399 fprintf(stderr, "start with %p\n", _pActivePartition);
400 fflush(stderr);
401 #endif
402 _bDefaultPartHandled = false;
403 // _pWindow->queueTask(_pActivePartition);
406 return Action::Continue;
409 Action::ResultE RenderAction::stop(ResultE res)
411 #ifdef OSG_RENPART_DUMP_PAR
412 fprintf(stderr, "Stop\n");
413 fflush(stderr);
414 #endif
416 Inherited::stop(res);
418 if(!_doCullOnly)
420 drawBuffer(_currentBuffer);
422 if(getVolumeDrawing())
423 drawVolume(_oFrustum);
426 if(_pViewarea != NULL && _pViewarea->getRenderOptions() != NULL)
428 _pViewarea->getRenderOptions()->deactivate(this);
430 else if(_pWindow != NULL && _pWindow->getRenderOptions() != NULL)
432 _pWindow->getRenderOptions()->deactivate(this);
435 return Action::Continue;
438 void RenderAction::frameInit(void)
440 Inherited::frameInit();
442 if(_bDrawPartPar == true)
444 _pPartitionPools [_currentBuffer]->freeAll();
445 _pNodePools [_currentBuffer]->freeAll();
446 _pStatePools [_currentBuffer]->freeAll();
447 _pTreeBuilderPools[_currentBuffer]->freeAll();
451 /*------------------------------ access -----------------------------------*/
453 void RenderAction::dropFunctor(DrawEnv::DrawFunctor &func,
454 Material *pMat,
455 bool bIgnoreOverrides)
457 if(pMat == NULL)
458 return;
460 PrimeMaterial *pPrimeMat = pMat->finalize(_oCurrentRenderProp,
461 this->getCurrentOverrides(),
462 _pWindow);
464 if(pPrimeMat == NULL)
465 return;
467 UInt32 uiNPasses = pPrimeMat->getNPasses();
469 for(UInt32 uiPass = 0; uiPass < uiNPasses; ++uiPass)
471 State *st = pPrimeMat->getState(uiPass);
473 if(st != NULL)
475 this->dropFunctor(func,
476 st,
477 pPrimeMat->getSortKey() + uiPass,
478 bIgnoreOverrides );
480 else
482 #ifndef WIN32
483 FINFO(("%s: hit material with NULL state!\n", __func__));
484 #else
485 FINFO(("Hit material with NULL state!\n"));
486 #endif
491 // select all visible nodes
492 UInt32 RenderAction::selectVisibles(void)
494 if(getFrustumCulling() == false)
495 return getNNodes();
497 useNodeList();
499 Color3f col;
501 UInt32 count = 0;
503 for(UInt32 i = 0; i < getNNodes(); i++)
505 if(isVisible(getNode(i)))
507 col.setValuesRGB(0,1,0);
509 addNode(getNode(i));
511 ++count;
513 else
515 col.setValuesRGB(1,0,0);
518 if(getVolumeDrawing())
520 dropVolume(this, getNode(i), col);
524 return count;
528 bool RenderAction::pushVisibility(void)
530 if(_pActivePartition->pushVisibility(getActNode()) == false)
532 useNodeList(); // ignore all children
533 return false;
536 return true;
539 void RenderAction::readdPartitionByIndex(UInt32 uiPartIdx)
541 OSG_ASSERT(uiPartIdx < _vRenderPartitions[_currentBuffer].size());
543 _vRenderPartitions[_currentBuffer].push_back(
544 _vRenderPartitions[_currentBuffer][uiPartIdx]);
547 void RenderAction::dumpPartitionList(void)
549 fprintf(stderr, "Dump PartitionList \n");
551 for(UInt32 i = 0; i < _vRenderPartitions[_currentBuffer].size(); ++i)
553 fprintf(stderr, " %p\n",
554 static_cast<void *>(_vRenderPartitions[_currentBuffer][i]));
558 /*------------------------ multi-buffer stuff -----------------------------*/
560 void RenderAction::setNumBuffers(UInt32 n)
562 if(n < 1)
564 FWARNING(("RenderAction::setNumBuffers: need at least one "
565 "buffer!\n"));
566 n = 1;
569 if(n > _numBuffers)
571 for(UInt16 i = _numBuffers; i < n; ++i)
573 _pPartitionPools .push_back(new RenderPartitionPool);
574 _pNodePools .push_back(new RenderTreeNodePool);
575 _pStatePools .push_back(new StateOverridePool);
576 _pTreeBuilderPools.push_back(new TreeBuilderPool);
580 else if(n < _numBuffers)
582 for(UInt16 i = _numBuffers - 1; i >= n; --i)
584 delete _pPartitionPools[i];
585 delete _pNodePools[i];
586 delete _pStatePools[i];
587 delete _pTreeBuilderPools[i];
589 _pPartitionPools .resize(n);
590 _pNodePools .resize(n);
591 _pStatePools .resize(n);
592 _pTreeBuilderPools.resize(n);
594 _numBuffers = n;
595 _vRenderPartitions.resize(n);
599 void RenderAction::drawBuffer(UInt32 buf)
601 if(_pStatistics != NULL)
603 _pStatistics->getElem(statDrawTime)->start();
606 if(_bDrawPartPar == false)
608 _vRenderPartitions[buf][0]->setupExecution(true);
610 for(PtrDiffT i = _vRenderPartitions[buf].size() - 1; i > 0; --i)
612 _vRenderPartitions[buf][i]->execute();
613 // _vRenderPartitions[buf][i]->exit();
616 _vRenderPartitions[buf][0]->doExecution(true);
617 // _vRenderPartitions[buf][0]->exit();
619 if(_bUseGLFinish == true)
621 glFinish();
624 else
626 #if 0
627 if(_bDefaultPartHandled == false)
629 _vRenderPartitions[_currentBuffer][0]->setTaskType(
630 RenderPartition::Full);
632 #endif
634 _pWindow->queueTaskFromDrawer(_vRenderPartitions[buf][0]);
636 if(_bUseGLFinish == true)
638 if(_pGLFinishTask == NULL)
640 _pGLFinishTask =
641 new RenderActionTask(RenderActionTask::HandleGLFinish);
644 _pWindow->queueTaskFromDrawer(_pGLFinishTask);
646 _pGLFinishTask->waitForBarrier();
650 if(_pStatistics != NULL)
652 _pStatistics->getElem(statDrawTime)->stop();
656 /*------------------------ Occlusion Culling -----------------------------*/
659 /*-------------------------- assignment -----------------------------------*/
661 /** \brief assignment
664 /*-------------------------- comparison -----------------------------------*/
667 /*-------------------------------------------------------------------------*\
668 - protected -
669 \*-------------------------------------------------------------------------*/
671 /*------------- constructors & destructors --------------------------------*/
673 RenderAction::RenderAction(void) :
674 Inherited ( ),
675 _doCullOnly ( false),
676 _numBuffers ( 0),
677 _currentBuffer ( 0),
679 _uiKeyGen ( 0),
681 _pPartitionPools ( ),
682 _pNodePools ( ),
683 _pStatePools ( ),
684 _pTreeBuilderPools ( ),
686 _vRenderPartitions ( ),
688 _iActivePartitionIdx (-1 ),
689 _bInPartitionGroup (false ),
690 _bDefaultPartHandled (false ),
691 _pActivePartition (NULL ),
693 _sRenderPartitionStack ( ),
694 _sRenderPartitionIdxStack( ),
695 _sRenderPartitionGrpStack( ),
697 _bvPassMask ( ),
699 _occlusionCulling (false ),
700 _occlusionCullingDebug (false ),
701 _occDMTested (0xffffffff),
702 _occDMCulled (0xffffffff),
703 _occDMVisible (0xffffffff),
704 _occMinFeatureSize ( 0),
705 _occVisibilityThreshold ( 0),
706 _occCoveredThreshold ( 0.7f),
707 _occQueryBufferSize ( 1000),
708 _occMinimumTriangleCount ( 500),
710 _scrlodCoverageThreshold ( 0.01f),
711 _scrlodNumLODsToUse ( 0),
712 _scrlodDegradationFactor ( 1.0f),
714 _pGLFinishTask (NULL )
716 if(_vDefaultEnterFunctors != NULL)
717 _enterFunctors = *_vDefaultEnterFunctors;
719 if(_vDefaultLeaveFunctors != NULL)
720 _leaveFunctors = *_vDefaultLeaveFunctors;
722 setNumBuffers(1);
724 UInt32 uiTId = TextureBaseChunk ::getStaticClassId() & 0x000003FF;
725 UInt32 uiShId = ShaderExecutableChunk ::getStaticClassId() & 0x000003FF;
726 UInt32 uiMId = ShaderExecutableVarChunk::getStaticClassId() & 0x000003FF;
728 _uiKeyGen = ( (uiShId) | (uiTId << 10) | (uiMId << 20) );
730 _travMask &= ~TraversalMasks::FindNamedComponentTraversal;
733 fprintf(stderr, "CreateKeyGen (RT) (%p) from %d %d %d -> %08x\n",
734 this,
735 SHLChunk ::getStaticClassId(),
736 TextureChunk ::getStaticClassId(),
737 MaterialChunk::getStaticClassId(),
738 _uiKeyGen);
743 RenderAction::RenderAction(const RenderAction &source) :
745 Inherited (source ),
746 _doCullOnly (false ),
747 _numBuffers (0 ),
748 _currentBuffer (0 ),
750 _uiKeyGen (source._uiKeyGen ),
752 _pPartitionPools ( ),
753 _pNodePools ( ),
754 _pStatePools ( ),
755 _pTreeBuilderPools ( ),
757 _vRenderPartitions ( ),
759 _iActivePartitionIdx (-1 ),
760 _bInPartitionGroup (false ),
761 _bDefaultPartHandled (false ),
762 _pActivePartition (NULL ),
764 _sRenderPartitionStack ( ),
765 _sRenderPartitionIdxStack( ),
766 _sRenderPartitionGrpStack( ),
768 _bvPassMask (source._bvPassMask ),
770 _occlusionCulling (source._occlusionCulling ),
771 _occlusionCullingDebug (source._occlusionCullingDebug ),
772 _occDMTested (source._occDMTested ),
773 _occDMCulled (source._occDMCulled ),
774 _occDMVisible (source._occDMVisible ),
775 _occMinFeatureSize (source._occMinFeatureSize ),
776 _occVisibilityThreshold (source._occVisibilityThreshold ),
777 _occCoveredThreshold (source._occCoveredThreshold ),
778 _occQueryBufferSize (source._occQueryBufferSize ),
779 _occMinimumTriangleCount (source._occMinimumTriangleCount),
781 _scrlodCoverageThreshold (source._scrlodCoverageThreshold),
782 _scrlodNumLODsToUse (source._scrlodNumLODsToUse ),
783 _scrlodDegradationFactor (source._scrlodDegradationFactor),
785 _pGLFinishTask (NULL )
787 setNumBuffers(source._numBuffers);
792 RenderAction::~RenderAction(void)
794 for(UInt16 i = 0; i < _numBuffers; ++i)
796 delete _pPartitionPools[i];
797 delete _pNodePools[i];
798 delete _pStatePools[i];
799 delete _pTreeBuilderPools[i];
802 _pGLFinishTask = NULL;
806 Action::FunctorStore *RenderAction::getDefaultEnterFunctors(void)
808 return _vDefaultEnterFunctors;
811 Action::FunctorStore *RenderAction::getDefaultLeaveFunctors(void)
813 return _vDefaultLeaveFunctors;
816 void RenderAction::pushPartition(UInt32 uiCopyOnPush,
817 RenderPartition::Mode eMode )
819 _sRenderPartitionIdxStack.push(_iActivePartitionIdx);
820 _sRenderPartitionStack .push(_pActivePartition );
821 _sRenderPartitionGrpStack.push(_bInPartitionGroup );
823 _pActivePartition->setNode(_actNode);
825 if(_bInPartitionGroup == false)
827 _pActivePartition =
828 _pPartitionPools [_currentBuffer]->create(eMode);
829 _iActivePartitionIdx = Int32(_vRenderPartitions[_currentBuffer].size());
831 _vRenderPartitions[_currentBuffer].push_back(_pActivePartition);
833 else
836 RenderPartitionStore::iterator it =
837 _vRenderPartitions[_currentBuffer].begin();
839 it += _iActivePartitionIdx;
841 _pActivePartition =
842 _pPartitionPools [_currentBuffer]->create(eMode);
844 _vRenderPartitions[_currentBuffer].insert(it, _pActivePartition);
846 _pActivePartition =
847 _pPartitionPools [_currentBuffer]->create(eMode);
849 if(static_cast<size_t>(_iActivePartitionIdx) ==
850 _vRenderPartitions[_currentBuffer].size())
852 _vRenderPartitions[_currentBuffer].push_back(_pActivePartition);
854 else
856 _vRenderPartitions[_currentBuffer]
857 [_iActivePartitionIdx]->addPartition(
858 _pActivePartition);
861 _bInPartitionGroup = false;
864 #ifdef OSG_RENPART_DUMP_PAR
865 fprintf(stderr, "Process %p\n", _pActivePartition);
866 fflush(stderr);
867 #endif
869 _pActivePartition->setKeyGen (_uiKeyGen );
870 _pActivePartition->setAction ( this );
871 _pActivePartition->setNodePool (_pNodePools [_currentBuffer]);
872 _pActivePartition->setStatePool (_pStatePools [_currentBuffer]);
873 _pActivePartition->setTreeBuilderPool(_pTreeBuilderPools[_currentBuffer]);
874 _pActivePartition->setStatCollector (_pStatistics );
875 _pActivePartition->setFrustumCulling (_bFrustumCulling );
876 _pActivePartition->setVolumeDrawing (_bVolumeDrawing );
877 _pActivePartition->setZWriteTrans (_bZWriteTrans );
879 _pActivePartition->setCorrectNegScale(_bCorrectTwoSidedLighting );
881 _pActivePartition->getDrawEnv().setDrawerId (_iDrawerId );
882 _pActivePartition->getDrawEnv().setDrawableId(_iDrawableId);
884 _pActivePartition->initFrom(_sRenderPartitionStack.top(),
885 _vRenderPartitions[_currentBuffer][0],
886 uiCopyOnPush );
889 void RenderAction::popPartition(void)
891 RenderPartition *pCurrPart = _pActivePartition;
893 _pActivePartition = _sRenderPartitionStack .top();
894 _iActivePartitionIdx = _sRenderPartitionIdxStack.top();
895 _bInPartitionGroup = _sRenderPartitionGrpStack.top();
897 _actNode = _pActivePartition->getNode();
899 _sRenderPartitionStack .pop();
900 _sRenderPartitionIdxStack.pop();
901 _sRenderPartitionGrpStack.pop();
903 if(_bDrawPartPar == true)
905 if(pCurrPart->getRenderTarget() == NULL &&
906 _bDefaultPartHandled == false )
908 _pActivePartition->setTaskType(RenderPartition::Setup);
909 _pWindow->queueTaskFromDrawer(
910 _vRenderPartitions[_currentBuffer][0]);
912 _bDefaultPartHandled = true;
915 _pWindow->queueTaskFromDrawer(pCurrPart);
917 #ifdef OSG_RENPART_DUMP_PAR
918 fprintf(stderr, "queue %p\n", pCurrPart);
919 fflush(stderr);
920 #endif
924 /*-------------------------------------------------------------------------*\
925 - private -
926 \*-------------------------------------------------------------------------*/