[osg-users] cullcallback and visitor ?

Ulrich Hertlein u.hertlein at sandbox.de
Thu Sep 25 17:28:37 PDT 2008


Vincent Bourdier wrote:
> _mainChild->getDrawable(0)->setCullCallback(new tileVisibleCallback());
> 
> ***
> tileVisibleCallback::tileVisibleCallback(){
>     _cull = false;
> };
> 
> void tileVisibleCallback::operator()(osg::Node* node, osgUtil::CullVisitor*
> nv){
>     _cull = nv->isCulled(*node);
>     osg::notify(osg::NOTICE)<<"Cull "<<_cull<<"\n";
> 
> };
> 
> bool tileVisibleCallback::isCulled(){
>     return _cull;
> };

You're mixing up osg::Drawable::CullCallback and osg::NodeCallback and consequently
osg::Node::setCullCallback and osg::Drawable::setCullCallback.

osg::Drawable::CullCallback has a virtual cull() function that tells if the Drawable
*should* be culled by returning true or false.

osg::NodeCallback has a virtual operator() that does what you want.

You need to derive your callback from osg::NodeCallback, implement operator() (as you
already do), and call:
	_mainChild->setCullCallback(...)
instead of
	_mainChild->getDrawable(0)->setCullCallback(...)

Hope this helps,
/ulrich

> 2008/9/25 Vincent Bourdier <vincent.bourdier at gmail.com>
>> class tileVisibleCallback : public osg::Drawable::CullCallback{
>> public:
>>     tileVisibleCallback();
>>     virtual void operator()(osg::Node* node, osgUtil::CullVisitor* nv);
>>     bool isCulled();
>>
>> private:
>>     bool _cull;
>>
>> };
>>
>> Does it sound good for you ?
>> (the mix between Cullcallback and osgUtil looks strange for me... but...)




More information about the osg-users mailing list