Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoCullElement Class Reference

The SoCullElement class is used internally for render and pick culling. More...

#include <Inventor/elements/SoCullElement.h>

Inheritance diagram for SoCullElement:
SoElement

Public Member Functions

virtual SoElementcopyMatchInfo (void) const
 
virtual void init (SoState *state)
 
virtual SbBool matches (const SoElement *elt) const
 
virtual void push (SoState *state)
 
- Public Member Functions inherited from SoElement
virtual ~SoElement ()
 
int getDepth (void) const
 
int getStackIndex (void) const
 
const SoType getTypeId (void) const
 
virtual void pop (SoState *state, const SoElement *prevTopElement)
 
virtual void print (FILE *file=stdout) const
 
void setDepth (const int depth)
 

Static Public Member Functions

static void addPlane (SoState *state, const SbPlane &newplane)
 
static SbBool completelyInside (SoState *state)
 
static voidcreateInstance (void)
 
static SbBool cullBox (SoState *state, const SbBox3f &box, const SbBool transform=TRUE)
 
static SbBool cullTest (SoState *state, const SbBox3f &box, const SbBool transform=TRUE)
 
static int getClassStackIndex (void)
 
static SoType getClassTypeId (void)
 
static void initClass (void)
 
static void setViewVolume (SoState *state, const SbViewVolume &vv)
 
- Static Public Member Functions inherited from SoElement
static int getClassStackIndex (void)
 
static SoType getClassTypeId (void)
 
static SoType getIdFromStackIndex (const int stackIndex)
 
static int getNumStackIndices (void)
 
static void initClass (void)
 
static void initElements (void)
 

Protected Member Functions

virtual ~SoCullElement ()
 
- Protected Member Functions inherited from SoElement
 SoElement (void)
 
void capture (SoState *const state) const
 
virtual void captureThis (SoState *state) const
 
SoElementgetNextFree (void) const
 
SoElementgetNextInStack (void) const
 
void setStackIndex (const int index)
 
void setTypeId (const SoType typeId)
 

Additional Inherited Members

- Static Protected Member Functions inherited from SoElement
static int createStackIndex (const SoType id)
 
static const SoElementgetConstElement (SoState *const state, const int stackIndex)
 
static SoElementgetElement (SoState *const state, const int stackIndex)
 
- Protected Attributes inherited from SoElement
int depth
 
int stackIndex
 
SoType typeId
 
- Static Protected Attributes inherited from SoElement
static int classStackIndex
 
static SoTypeListstackToType
 

Detailed Description

The SoCullElement class is used internally for render and pick culling.

The element holds all planes the geometry should be inside, and keeps a bit flag to signal which planes need to be tested.

This element is an extension for Coin, and is not available in the original Open Inventor.

The maximum number of planes in this element is 32, which should be more than enough, since the view frustum is represented by 6 planes, and the maximum number of OpenGL clipping planes is typically 6 or 8.

This element is designed for fast culling, and will not do optimal view frustum culling; a box might not be culled even though it is outside the view frustum. The assumption is that the view frustum is small compared to the world model. The element simply records all planes to be culled against, and the graph is not culled until it is completely outside one of the planes.

SoCullElement is not active for other actions than SoGLRenderAction. It's possible to enable it for SoCallbackAction by updating it in a post camera callback though. Do something like this:

static SoCallbackAction::Response
camera_cb(void * data, SoCallbackAction * action, const SoNode * node)
{
  SoState * state = action->getState();
  SoCullElement::setViewVolume(state, SoViewVolumeElement::get(state));
  return SoCallbackAction::CONTINUE;
}

[...]
SoCallbackAction cba(myviewport);
cba.addPostCallback(SoCamera::getClassTypeId(), camera_cb, NULL);

When the view volume is set in SoCullElement in the post camera callback, SoCallbackAction will perform culling on Separators and other nodes in the same way as SoGLRenderAction.

Constructor & Destructor Documentation

◆ ~SoCullElement()

SoCullElement::~SoCullElement ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ addPlane()

void SoCullElement::addPlane ( SoState * state,
const SbPlane & newplane )
static

Add plane geometry must be inside. The plane must be in the world coordinate system.

◆ completelyInside()

SbBool SoCullElement::completelyInside ( SoState * state)
static

Returns TRUE if the current geometry is completely inside all planes. There is no need to do a cull test if this is the case.

◆ copyMatchInfo()

SoElement * SoCullElement::copyMatchInfo ( void ) const
virtual

This function creates a copy of the element that contains enough information to enable the matches() function to work.

Used to help with scene graph traversal caching operations.

Implements SoElement.

◆ createInstance()

void * SoCullElement::createInstance ( void )
static

This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.

Creates a new instance of the class type corresponding to the SoType object.

◆ cullBox()

SbBool SoCullElement::cullBox ( SoState * state,
const SbBox3f & box,
const SbBool transform = TRUE )
static

Cull against box. If transform is TRUE, the box is assumed to be in object space, and will be transformed into world space using the model matrix. Returns TRUE if box is outside one of the planes, and updates the element to detect when geometry is completely inside all planes.

◆ cullTest()

SbBool SoCullElement::cullTest ( SoState * state,
const SbBox3f & box,
const SbBool transform = TRUE )
static

Cull against box. If transform is TRUE, the box is assumed to be in object space, and will be transformed into world space using the model matrix. Returns TRUE if box is outside one of the planes. This method will not update the element state, just perform a cull test against active planes.

◆ getClassStackIndex()

static int SoCullElement::getClassStackIndex ( void )
static

This static method returns the state stack index for the class.

This static method returns the state stack index for the class.

◆ getClassTypeId()

static SoType SoCullElement::getClassTypeId ( void )
static

This static method returns the SoType object associated with objects of this class.

This static method returns the class type.

◆ init()

void SoCullElement::init ( SoState * state)
virtual

This function initializes the element type in the given SoState. It is called for the first element of each enabled element type in SoState objects.

Reimplemented from SoElement.

◆ initClass()

void SoCullElement::initClass ( void )
static

Initialize relevant common data for all instances, like the type system.

◆ matches()

SbBool SoCullElement::matches ( const SoElement * element) const
virtual

This function returns TRUE is the element matches another element (of the same class), with respect to cache validity.

If the application programmer's extension element has a matches() function, it should also have a copyMatchInfo() function.

Implements SoElement.

◆ push()

void SoCullElement::push ( SoState * state)
virtual

This method is called every time a new element is required in one of the stacks. This happens when a writable element is requested, using SoState::getElement() or indirectly SoElement::getElement(), and the depth of the current element is less than the state depth.

Override this method if your element needs to copy data from the previous top of stack. The push() method is called on the new element, and the previous element can be found using SoElement::getNextInStack().

Reimplemented from SoElement.

◆ setViewVolume()

void SoCullElement::setViewVolume ( SoState * state,
const SbViewVolume & vv )
static

Sets the current view volume. In effect, this adds six planes to the list of culling planes. If a view volume has already been set, the old view volume planes are overwritten by the new ones. The view volume must be in the world coordinate systems.


The documentation for this class was generated from the following files: