UPDATE:

Let me start by saying Paul was right 8) . It is the AutoTransform! The 'x' did 
not show when I turned off AutoTransform because it may have been obscured by 
another object, so I falsely thought it was not the AutoTransform.

I spent the day debugging the bound speheres for culling and I found the 
problem. Here is what happens:

1) I add the new 'x' to my scene with an AutoTransform and 
AutoScaleToScreen=true
2) frame() is called
3) OSG prepares for culling and calls scene->getSceneData()->getBound() to 
calculate the bounding sphere of the scene (ViewerBase.cpp line #760)
4) The graph gets traversed in a depth-first manner, recursevly computing the 
spheres
5) At some point our AutoTransform is reached, and computeBound() is called 
(Node line #366)
6) But allas, AutoTransform::computeBound() returns an invalid bound since the 
_firstTimeToInitEyePoint flag is true! (AutoTransform.cpp line #389)
7) The  _firstTimeToInitEyePoint flag gets a false value only after the first 
CullVisitor has visited the AutoTransform, which happens only AFTER the 
computation of the bound returns (AutoTransform.cpp lines 199 - 229).
8 ) But at that time it is too late since the value of _boundingSphereComputed 
is set to true (Node line #370) so the invalid AutoTransform sphere does not 
get recalculated until later.

What I did is set a breakpoint in AutoTransform::computeBound(), and set 
_firstTimeToInitEyePoint to false inside the debugger, and then the 'x' showed.

So to summarize the problem - the implementation of 
AutoTransform::computeBound()will return a valid spehere only if the 
AutoTransform node was visited by the CullVisitor at least once, but since it 
is called before the culling, it caches an invalid transform. 
I am not sure if this is a bug or because I may not be seeing the whole picture.

Our plan to solve this is writing our own BoundCallback and set it on the 
AutoTransform of our 'x'.
The new BoundCallback will return a small sphere (let's say radius 2, center 
000) becuse our 'x' only represents a point in the space, and we want it to 
behave like a HUD element. This will also make the calculation of the bounding 
spheres of parent nodes of the 'x''s more accurate since it will take into 
account only the point in space with the small sphere around it.

If it works for us, it might be worth thinking about adding this solution to 
the osg code. But I need more guidance on that, so thank you again! :).


Cheers,
Ron

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48922#48922





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to