Re: [Fresco-devel] Bogus traversals (and patch)
Stefan Seefeld <[email protected]>
| Newsgroups | gmane.comp.video.fresco.devel |
|---|---|
| Message-ID | <[email protected]> |
Nick Lewycky wrote:
> Stefan Seefeld wrote:
>
>> Nick Lewycky wrote:
>>
>>> I ask the graphic to traverse itself, then its children by calling
>>> A->traverse(t);
>>>
>>> My suggested implementation of A->traverse(t) is {t->visit(_this);
>>> MonoGraphic::traverse(t); }
>>
>>
>> yeah, that would work equally well (beside the fact that you have to care
>> for the cleanup in the Traversal). Why do you think this is better
>> than calling MonoGraphic::traverse inside 'draw' and 'pick' ?
>
>
> Because I'm trying to write a Traversal that visits all the Graphics but
> isn't interested in either picking them nor rendering them. I shouldn't
> need to use GraphicIterators to do this.
fair enough.
> Secondly, I think it's better to care for cleanup in the Traversal
> because I don't trust an arbitrary Graphic to do it for us. (At the
> moment there are still plenty of ways for a client to crash the server,
> but I think this is a step in the right direction.)
agreed. However, I'm a bit reluctant about such a split. We can't really
separate (at least not semantically) the 'draw' from the
'traverse_child', as it is the semantics of a MonoGraphic's 'draw' to
draw its children. This surfaces for example as the problem you are
seeing: 'draw' can really finish (restore the DK's state) before the
traverse_child is done.
>> Do you feel it is more clean to keep the actual visitor stuff separate
>> from the traversal (which reminds a bit of the cursor pattern...) ?
>
>
> Yes.
What about the template pattern then ? Add a method 'traverse_body'
to the MonoGraphic (and 'traverse_children' to the PolyGraphic) which
implements the subgraph traversal. These methods are then to be called
*from inside* draw / pick.
That's not that different from the current scheme, just a bit more
formal. The traverse_body is essentially the same as
MonoGraphic::traverse...
Regards,
Stefan
PS: your thinking may be biased by OpenInventor design (and the like),
where individual scene graph nodes are not decorators, i.e. they don't
wrap subgraph traversals, but they simply set attributes in the order
they are inserted. To automate a cleanup you have to use 'separators'...