Thanks for your answers.


Bradford, Chase a écrit :
> Unfortunately, that's just a limitation of the visitor pattern and
> double dispatch in general.  In order to accomplish what you want, you'd
> have to overload apply(osg::Group) forward the call explicitly.
> Something like:
>
> MyVisitor::apply(osg::Group& grp)
> {
>   if( dynamic_cast<osg::MyGroup*>(&grp) )
>     apply( static_cast<osg::MyGroup&>(grp) );
>   else
>      /* general osg::Group handling */
> }
>
>
> This visitor calls node->accept(*this), which turns around and calls
> visitor->apply(*this).  However, in node::accept, the visitor used of
> type osg::NodeVisitor, the highest abstraction.  Unless osg::NodeVisitor
> has an apply overload that takes the type you want, then it won't get
> called.  Your apply(osg::MyGroup) isn't in NodeVisitor's vtable, which
> is why it's not called.
>
> I hope that helps.
>
>
> Chase
>
>   
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:osg-users-
>> [EMAIL PROTECTED] On Behalf Of Stephane Lamoliatte
>> Sent: Wednesday, December 19, 2007 9:32 AM
>> To: OpenSceneGraph Users
>> Subject: [osg-users] How to visit a custom node ?
>>
>> Hello,
>>
>> I created a new node, MyGroup, which extends osg::Group.
>> I want to visit it in the scene graph with a NodeVisitor. So, I wrote
>> MyNodeVisitor which extends osg::NodeVisitor. MyVisitor contains an
>> apply function which takes MyGroup in parameter :
>> MyVisitor::apply(osg::MyGroup &).
>>
>> The problem is that this function is never called : The application
>>     
> call
>   
>> MyVisitor::apply(osg::Group&) instead.
>>
>> Does somebdy know why ?
>>
>> Thanks in advance.
>> --
>> Stephane.
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>>
>>     
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
> g
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to