When the query geometry gets reset to its default then its
vertices have to be updated by the bounding box dimensions of
the current children of the OcclusionQueryNode.
The user defined query geometry handling has been broken in several ways.
The previous way of defining a query geometry was using the non const
`getQueryGeometry` method and overriding its members. But then
`OcclusionQueryNode` wasn't aware of the geometry change and couldn't
internally handle it correctly.
The `computeBound` method never considered a user defined query geometry and
always just overrode the vertices of the geometry.
The member `_validQueryGeometry` wasn't correctly set.
This change should fix all this issues by introducing a small backward
compatibility break. The non const `getQueryGeometry` method is removed
forcing the user to use the `setQueryGeometry` method. But then `OcclusionQueryNode`
is aware of the user defined query geometry and can handle it correctly.
If there's a big view change then it might not be appropriate to wait
for '_queryFrameCount' till the next query is issued, because then
geometry might pop into the view after '_queryFrameCount'.
This is especially important for applications not having a constant
frame rate, but just issue a new frame on demand.
The change I made is to check GL_QUERY_RESULT_AVAILABLE before retrieving the query, to ensure that there won't be a stall. If the query result is not available yet, we'll leave it alone and try again in the next frame.
Had to make a few more changes than I'd liked, mostly because the TestResult mechanism wasn't designed for holding on to query objects for more than one frame. As well, I'm thinking that RetrieveQueriesCallback and ClearQueriesCallback could be merged together, if we wanted to go for more refactoring. For though now my strategy is to make as little changes as possible. Let me know what you think of the patch."
So with the 3.0 api change we propose the following change:
- put OSG_EXPORT on the QueryGeometry class so that we get access to the getNumPixels method.
- Create a function called getQueryGeometry that returns a casted _queryGeode->getDrawable(). Or a function called getQueryGeode that returns _queryGeode."
I move declaration of classes TestResult, QueryGeometry from cpp to header file and made a void createSupportNodes() a virtual method.
Now is possible to inherit from class OcclusionQueryNode."
* Change OcclusionQueryNode::getPassed to take a NodeVisitor rather than the distance from BS center to the eye point. Change where CullVisitor calls this method to use the new parameters.
* getPassed now exits early and returns true to avoid blinking / blink-in of geometry for the first frame or for out-of-range LOD children coming back into view.
* getPassed now considers the distance from the near plane to the bounding sphere (rather than eye point to bounding sphere) when determining if the viewer is "inside" the bounding sphere or not."