Hi Luc,
On 21 November 2014 16:32, Luc Frauciel <[email protected]> wrote:
> Hi,
>
>
>
> I've dug a little into osg ::clone operator and I think it is broken for
> Geodes since the Geode/Geometry change.
>
> If a cloning is done on a Geode with the flag DEEP_COPY_DRAWABLES,
>
> The clone function of osg::Group will be called, wich is correct to my
> understanding, but for childs (Drawables), the osg::Node cloning operator
> is called instead of Drawable/Geometry one.
>
>
>
>
>
> The offending code :
>
> osg::Geode *pCopiedOsgGeode = static_cast<osg::Geode
> *>(pOsgGeode->clone(osg::CopyOp::DEEP_COPY_DRAWABLES));
>
>
>
> pCopiedOsgGeode is NOT a deep copy of pOsgGeode
>
>
>
> Robert, do you have an idea how it should work or be repaired ?
>
The problem looks to stem from the way that osg::CopyOp uses static typing
to determine which CopyOp::Options mask bit it matches too, rather than
dynamic like the osg::NodeVisitor does.
As things stand the DEEP_COPY_DRAWABLES is now hidden by Geode subclassing
and managing all it's Drawable's via the Group functionality that just
manages osg::Node*. The DEEP_COPY_DRAWABLES is effectively made redundant
for common usage, but unfortunately such a change isn't backwards
compatible - and given this unless we do something to replicate the old
behavior then it may be best to remove this option.
The only way I can see if replicating the old functionality of having a
special case for DEEP_COPY_DRAWABLES would be to have a dynamic cast to
osg::Drawable* in the CopyOp::operator(const Node* node) i.e.
Node* CopyOp::operator() (const Node* node) const
{
if (!node) return 0;
osg::Drawable* drawable = node->asDrawable();
if (drawable) return operation()(drawable);
else if (_flags&DEEP_COPY_NODE) return osg::clone(node, *this);
else const_cast<Node*>(node);
}
Something like this is already done for Texture object, so it's not without
precedent.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org