OSG::RenderPartition Class Reference

RenderPartition is the core class for keeping track of the actions necessary to draw a scene.

#include <OSGRenderPartition.h>

Inheritance diagram for OSG::RenderPartition:

OSG::RenderPartitionBase List of all members.

Public Types

typedef std::pair< UInt32,
Matrix
MatrixStore
typedef Material::DrawFunctor DrawFunctor
typedef boost::function< void(DrawEnv *)> SimpleDrawCallback
typedef std::map< Int32, TreeBuilderBase * > BuildKeyMap
typedef std::map< Int32, TreeBuilderBase
* >::iterator 
BuildKeyMapIt
typedef std::map< Int32, TreeBuilderBase
* >::const_iterator 
BuildKeyMapConstIt
typedef std::vector< FrustumVolume::PlaneSetVisibilityStack
typedef std::stack< StateOverride * > OverrideStack
typedef std::vector< MatrixStoreMatrixStack
typedef std::vector< RenderPartition * > GroupStore
enum  CopyOnPush {
  CopyNothing = 0x0000, CopyStateOverride = 0x0001, CopyViewing = 0x0002, CopyProjection = 0x0004,
  CopyVisibility = 0x0008, CopyViewport = 0x0010, CopyWindow = 0x0020, CopyViewportSize = 0x0040,
  CopyFrustum = 0x0080, CopyNearFar = 0x0100, CopyVPCamera = 0x0200, CopyAll = 0xFFFF
}
enum  Mode { StateSorting = 0x0001, TransformSorting = 0x0002, SimpleCallback = 0x0003, OcclusionCulling = 0x0004 }
enum  SetupMode {
  EmptySetup = 0x0000, ProjectionSetup = 0x0001, ViewportSetup = 0x0002, BackgroundSetup = 0x0004,
  FullSetup = 0x0007
}

Public Member Functions

void setAction (RenderTraversalAction *pAction)
void setNodePool (RenderTreeNodePool *pNodePool)
void setStatePool (StateOverridePool *pStatePool)
void setTreeBuilderPool (TreeBuilderPool *pTreeBuilderPool)
void setStatCollector (StatCollectorP pStatCollector)
StatCollectorP getStatCollector (void)
void setViewport (Viewport *pViewport)
ViewportgetViewport (void)
void setWindow (Window *pWindow)
WindowgetWindow (void)
void setBackground (Background *pBackground)
void setupProjection (const Matrix4f &projection, const Matrix4f &translation)
const Matrix4fgetFullProjection (void)
const Matrix4fgetProjection (void)
const Matrix4fgetProjectionTrans (void)
const Matrix4fgetVPFullProjection (void)
const Matrix4fgetVPProjection (void)
const Matrix4fgetVPProjectionTrans (void)
void setupViewing (const Matrix4f &matrix)
const Matrix4fgetViewing (void)
const Matrix4fgetCameraToWorld (void)
const Matrix4fgetVPViewing (void)
const Matrix4fgetVPCameraToWorld (void)
void addPartition (RenderPartition *pPart)
void setNear (Real32 camNear)
void setFar (Real32 camFar)
Real32 getNear (void)
Real32 getFar (void)
void calcFrustum (void)
void setViewportDimension (Int32 iPixelLeft, Int32 iPixelBottom, Int32 iPixelRight, Int32 iPixelTop, bool bFull)
void calcViewportDimension (Real32 rLeft, Real32 rBottom, Real32 rRight, Real32 rTop, UInt16 iTargetWidth, UInt16 iTargetHeight)
Int32 getViewportWidth (void)
Int32 getViewportHeight (void)
void setSetupMode (SetupMode eSetupMode)
void initFrom (RenderPartition *pSource, RenderPartition *pInitial, Int32 uiCopyOnPush)
void initVPMatricesFromCamera (void)
void execute (void)
void disable (void)
void pushMatrix (const Matrix &matrix)
void popMatrix (void)
const MatrixtopMatrix (void)
void dropFunctor (DrawFunctor &func, State *pState, Int32 uiBuildKey)
void dropFunctor (SimpleDrawCallback &oFunc)
void pushState (void)
void popState (void)
void addOverride (UInt32 uiSlot, StateChunk *pChunk)
Int32 allocateLightIndex (void)
void releaseLightIndex (void)
void setKeyGen (UInt32 uiKeyGen)
void overrideMaterial (Material *pMaterial, NodePtrConstArg pNode)
MaterialgetMaterial (void)
void setRenderTarget (FrameBufferObject *pTarget)
FrameBufferObjectgetRenderTarget (void)
bool isVisible (Node *pNode)
bool pushVisibility (NodePtrConstArg pNode)
void popVisibility (void)
bool getFrustumCulling (void) const
void setFrustumCulling (bool val=true)
bool getVolumeDrawing (void) const
void setVolumeDrawing (bool val=false)
const FrustumVolumegetFrustum (void) const
void setFrustum (FrustumVolume &frust)
UInt32 getNumMatrixChanges (void)
UInt32 getNumStateChanges (void)
UInt32 getNumShaderChanges (void)
UInt32 getNumShaderParamChanges (void)
UInt32 getNumTriangles (void)
void init (void)
void exit (void)

Static Public Attributes

static StatElemDesc< StatIntElemstatCullTestedNodes
static StatElemDesc< StatIntElemstatCulledNodes

Protected Types

typedef RenderPartitionBase Inherited

Protected Member Functions

 RenderPartition (Mode eMode=StateSorting)
virtual ~RenderPartition (void)
void reset (Mode eMode=StateSorting)
void updateTopMatrix (void)
void setupExecution (void)
void doExecution (void)

Protected Attributes

Mode _eMode
SetupMode _eSetupMode
bool _bDone
GroupStore _vGroupStore
DrawEnv _oDrawEnv
SimpleDrawCallback _oSimpleDrawCallback
Background_pBackground
UInt32 _uiMatrixId
MatrixStore _currMatrix
Matrix _accMatrix
MatrixStack _vMatrixStack
RenderTreeNodePool_pNodePool
BuildKeyMap _mMatRoots
BuildKeyMap _mTransMatRoots
bool _bSortTrans
bool _bZWriteTrans
bool _bCorrectTwoSidedLighting
UInt32 _uiActiveMatrix
StateOverridePool_pStatePool
OverrideStack _sStateOverrides
TreeBuilderPool_pTreeBuilderPool
Int32 _iNextLightIndex
UInt32 _uiKeyGen
Material_pMaterial
NodePtr _pMaterialNode
FrameBufferObject_pRenderTarget
Int32 _iPixelLeft
Int32 _iPixelRight
Int32 _iPixelBottom
Int32 _iPixelTop
bool _bFull
UInt32 _uiNumMatrixChanges
UInt32 _uiNumTriangles
VisibilityStack _visibilityStack
bool _bFrustumCulling
bool _bVolumeDrawing
bool _bAutoFrustum
FrustumVolume _oFrustum

Private Member Functions

 RenderPartition (const RenderPartition &source)
 prohibit default function (move to 'public' if needed)
void operator= (const RenderPartition &source)

Friends

class SimplePool< RenderPartition, PoolDefaultTag, NoLockPolicy >
class RenderTraversalAction
class TreeBuilderBase
class OcclusionCullingTreeBuilder

Detailed Description

Definition at line 87 of file OSGRenderPartition.h.


Member Typedef Documentation

typedef std::pair<UInt32, Matrix> OSG::RenderPartition::MatrixStore

MatrixStore is stored internally to keep track of the current matrix. The UInt32 is used to quickly identify the same matrix without having to compare actual matrix elements.

Definition at line 113 of file OSGRenderPartition.h.

DrawFunctor is the signature for the methods that are called from within the draw tree

Definition at line 118 of file OSGRenderPartition.h.

typedef boost::function<void (DrawEnv *)> OSG::RenderPartition::SimpleDrawCallback

SimpleDrawCallback is the type of functions that are used for simple partitions (i.e. the ones that only call one function and do not draw Nodes

Definition at line 124 of file OSGRenderPartition.h.

BuildKeyMap is used to index from the material's sortKey to the StateSorter that keeps the tree for that sort key

Definition at line 130 of file OSGRenderPartition.h.

typedef std::map<Int32, TreeBuilderBase *>::iterator OSG::RenderPartition::BuildKeyMapIt

Definition at line 132 of file OSGRenderPartition.h.

typedef std::map<Int32, TreeBuilderBase *>::const_iterator OSG::RenderPartition::BuildKeyMapConstIt

Definition at line 134 of file OSGRenderPartition.h.

VisibilityStack keeps track of the planes of the current frustum that need to be tested. If a bounding volume is inside all planes, none need to be tested for its children.

Definition at line 140 of file OSGRenderPartition.h.

OverrideStack keeps track of active StateOverrides during traversal

Definition at line 143 of file OSGRenderPartition.h.

MatrixStack keeps track of matrices during traversal

Definition at line 146 of file OSGRenderPartition.h.

Definition at line 148 of file OSGRenderPartition.h.

Definition at line 351 of file OSGRenderPartition.h.


Member Enumeration Documentation

Enumerator:
CopyNothing 
CopyStateOverride 
CopyViewing 
CopyProjection 
CopyVisibility 
CopyViewport 
CopyWindow 
CopyViewportSize 
CopyFrustum 
CopyNearFar 
CopyVPCamera 
CopyAll 

Definition at line 81 of file OSGRenderPartitionBase.h.

00082     {
00083         CopyNothing       = 0x0000,
00084 
00085         CopyStateOverride = 0x0001,
00086 
00087         CopyViewing       = 0x0002,
00088         CopyProjection    = 0x0004,
00089         CopyVisibility    = 0x0008,
00090 
00091         CopyViewport      = 0x0010,
00092         CopyWindow        = 0x0020,
00093 
00094         CopyViewportSize  = 0x0040,
00095         CopyFrustum       = 0x0080,
00096 
00097         CopyNearFar       = 0x0100,
00098 
00099         CopyVPCamera      = 0x0200,
00100 
00101         CopyAll           = 0xFFFF
00102     };

Enumerator:
StateSorting 
TransformSorting 
SimpleCallback 
OcclusionCulling 

Definition at line 104 of file OSGRenderPartitionBase.h.

00105     {
00106         StateSorting     = 0x0001,
00107         TransformSorting = 0x0002,
00108         SimpleCallback   = 0x0003,
00109         OcclusionCulling = 0x0004
00110     };

Enumerator:
EmptySetup 
ProjectionSetup 
ViewportSetup 
BackgroundSetup 
FullSetup 

Definition at line 112 of file OSGRenderPartitionBase.h.

00113     {
00114         EmptySetup      = 0x0000,
00115         ProjectionSetup = 0x0001,
00116         ViewportSetup   = 0x0002,
00117         BackgroundSetup = 0x0004,
00118         FullSetup       = 0x0007
00119     };


Constructor & Destructor Documentation

OSG::RenderPartition::RenderPartition ( Mode  eMode = StateSorting  )  [protected]

virtual OSG::RenderPartition::~RenderPartition ( void   )  [protected, virtual]

OSG::RenderPartition::RenderPartition ( const RenderPartition source  )  [private]


Member Function Documentation

void OSG::RenderPartition::setAction ( RenderTraversalAction pAction  ) 

void OSG::RenderPartition::setNodePool ( RenderTreeNodePool pNodePool  )  [inline]

Definition at line 121 of file OSGRenderPartition.inl.

References _pNodePool.

00122 {
00123     _pNodePool = pNodePool;
00124 }

void OSG::RenderPartition::setStatePool ( StateOverridePool pStatePool  )  [inline]

Definition at line 127 of file OSGRenderPartition.inl.

References _pStatePool.

00128 {
00129     _pStatePool = pStatePool;
00130 }

void OSG::RenderPartition::setTreeBuilderPool ( TreeBuilderPool pTreeBuilderPool  )  [inline]

Definition at line 133 of file OSGRenderPartition.inl.

References _pTreeBuilderPool.

00134 {
00135     _pTreeBuilderPool = pTreeBuilderPool;
00136 }

void OSG::RenderPartition::setStatCollector ( StatCollectorP  pStatCollector  )  [inline]

Definition at line 139 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::setStatCollector().

00140 {
00141     _oDrawEnv.setStatCollector(pStatCollector);
00142 }

StatCollectorP OSG::RenderPartition::getStatCollector ( void   )  [inline]

Definition at line 145 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getStatCollector().

00146 {
00147     return _oDrawEnv.getStatCollector();
00148 }

void OSG::RenderPartition::setViewport ( Viewport pViewport  )  [inline]

Definition at line 151 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::setViewport().

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00152 {
00153     _oDrawEnv.setViewport(pViewport);
00154 }

Viewport * OSG::RenderPartition::getViewport ( void   )  [inline]

Definition at line 157 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getViewport().

00158 {
00159     return _oDrawEnv.getViewport();
00160 }

void OSG::RenderPartition::setWindow ( Window pWindow  )  [inline]

Definition at line 164 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::setWindow().

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00165 {
00166     _oDrawEnv.setWindow(pWindow);
00167 }

Window * OSG::RenderPartition::getWindow ( void   )  [inline]

Definition at line 170 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getWindow().

00171 {
00172     return _oDrawEnv.getWindow();
00173 }

void OSG::RenderPartition::setBackground ( Background pBackground  )  [inline]

Definition at line 176 of file OSGRenderPartition.inl.

References _pBackground.

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00177 {
00178     _pBackground = pBackground;
00179 }

void OSG::RenderPartition::setupProjection ( const Matrix4f projection,
const Matrix4f translation 
) [inline]

Definition at line 182 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::setupProjection().

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00184 {
00185     _oDrawEnv.setupProjection(projection, translation);
00186 }

const Matrix4f & OSG::RenderPartition::getFullProjection ( void   )  [inline]

Definition at line 189 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraFullProjection().

00190 {
00191     return _oDrawEnv.getCameraFullProjection();
00192 }

const Matrix4f & OSG::RenderPartition::getProjection ( void   )  [inline]

Definition at line 195 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraProjection().

00196 {
00197     return _oDrawEnv.getCameraProjection();
00198 }

const Matrix4f & OSG::RenderPartition::getProjectionTrans ( void   )  [inline]

Definition at line 201 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraProjectionTrans().

00202 {
00203     return _oDrawEnv.getCameraProjectionTrans();
00204 }

const Matrix4f & OSG::RenderPartition::getVPFullProjection ( void   )  [inline]

Definition at line 207 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getVPCameraFullProjection().

00208 {
00209     return _oDrawEnv.getVPCameraFullProjection();
00210 }

const Matrix4f & OSG::RenderPartition::getVPProjection ( void   )  [inline]

Definition at line 213 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getVPCameraProjection().

00214 {
00215     return _oDrawEnv.getVPCameraProjection();
00216 }

const Matrix4f & OSG::RenderPartition::getVPProjectionTrans ( void   )  [inline]

Definition at line 219 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getVPCameraProjectionTrans().

00220 {
00221     return _oDrawEnv.getVPCameraProjectionTrans();
00222 }

void OSG::RenderPartition::setupViewing ( const Matrix4f matrix  )  [inline]

Definition at line 225 of file OSGRenderPartition.inl.

References _currMatrix, _oDrawEnv, OSG::DrawEnv::setupViewing(), and updateTopMatrix().

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00226 {
00227     _oDrawEnv.setupViewing(matrix);
00228 
00229     _currMatrix.second = matrix;
00230 
00231     updateTopMatrix();
00232 }

const Matrix4f & OSG::RenderPartition::getViewing ( void   )  [inline]

Definition at line 235 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraViewing().

00236 {
00237     return _oDrawEnv.getCameraViewing();
00238 }

const Matrix4f & OSG::RenderPartition::getCameraToWorld ( void   )  [inline]

Definition at line 241 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraToWorld().

00242 {
00243     return _oDrawEnv.getCameraToWorld();
00244 }

const Matrix4f & OSG::RenderPartition::getVPViewing ( void   )  [inline]

Definition at line 247 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getVPCameraViewing().

00248 {
00249     return _oDrawEnv.getVPCameraViewing();
00250 }

const Matrix4f & OSG::RenderPartition::getVPCameraToWorld ( void   )  [inline]

Definition at line 253 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraToWorld().

00254 {
00255     return _oDrawEnv.getCameraToWorld();
00256 }

void OSG::RenderPartition::addPartition ( RenderPartition pPart  )  [inline]

Definition at line 259 of file OSGRenderPartition.inl.

References _vGroupStore.

00260 {
00261     _vGroupStore.push_back(pPart);
00262 }

void OSG::RenderPartition::setNear ( Real32  camNear  )  [inline]

Definition at line 265 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::setCameraNear().

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00266 {
00267     _oDrawEnv.setCameraNear(camNear);
00268 }

void OSG::RenderPartition::setFar ( Real32  camFar  )  [inline]

Definition at line 271 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::setCameraFar().

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00272 {
00273     _oDrawEnv.setCameraFar(camFar);
00274 }

Real32 OSG::RenderPartition::getNear ( void   )  [inline]

Definition at line 277 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraNear().

00278 {
00279     return _oDrawEnv.getCameraNear();
00280 }

Real32 OSG::RenderPartition::getFar ( void   )  [inline]

Definition at line 283 of file OSGRenderPartition.inl.

References _oDrawEnv, and OSG::DrawEnv::getCameraFar().

00284 {
00285     return _oDrawEnv.getCameraFar();
00286 }

void OSG::RenderPartition::calcFrustum ( void   ) 

void OSG::RenderPartition::setViewportDimension ( Int32  iPixelLeft,
Int32  iPixelBottom,
Int32  iPixelRight,
Int32  iPixelTop,
bool  bFull 
) [inline]

Definition at line 89 of file OSGRenderPartition.inl.

References _bFull, _iPixelBottom, _iPixelLeft, _iPixelRight, and _iPixelTop.

00094 {
00095     _iPixelLeft   = iPixelLeft;
00096     _iPixelRight  = iPixelRight;
00097     _iPixelBottom = iPixelBottom;
00098     _iPixelTop    = iPixelTop;
00099     _bFull        = bFull;
00100 }

void OSG::RenderPartition::calcViewportDimension ( Real32  rLeft,
Real32  rBottom,
Real32  rRight,
Real32  rTop,
UInt16  iTargetWidth,
UInt16  iTargetHeight 
)

Int32 OSG::RenderPartition::getViewportWidth ( void   )  [inline]

Definition at line 103 of file OSGRenderPartition.inl.

References _iPixelLeft, and _iPixelRight.

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00104 {
00105     return _iPixelRight - _iPixelLeft + 1;
00106 }

Int32 OSG::RenderPartition::getViewportHeight ( void   )  [inline]

Definition at line 109 of file OSGRenderPartition.inl.

References _iPixelBottom, and _iPixelTop.

Referenced by OSG::SimpleShadowMapEngine::doLightPass().

00110 {
00111     return _iPixelTop - _iPixelBottom + 1;
00112 }

void OSG::RenderPartition::setSetupMode ( SetupMode  eSetupMode  )  [inline]

Definition at line 115 of file OSGRenderPartition.inl.

References _eSetupMode.

00116 {
00117     _eSetupMode = eSetupMode;
00118 }

void OSG::RenderPartition::initFrom ( RenderPartition pSource,
RenderPartition pInitial,
Int32  uiCopyOnPush 
)

void OSG::RenderPartition::initVPMatricesFromCamera ( void   ) 

void OSG::RenderPartition::execute ( void   ) 

void OSG::RenderPartition::disable ( void   )  [inline]

Definition at line 372 of file OSGRenderPartition.inl.

References _bDone.

00373 {
00374     _bDone = true;
00375 }

void OSG::RenderPartition::pushMatrix ( const Matrix matrix  ) 

void OSG::RenderPartition::popMatrix ( void   )