Commit Graph

16 Commits

Author SHA1 Message Date
Daniel Trstenjak
ddb72691bc OcclusionQueryNode: fix resetting to default query geometry
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.
2020-01-20 16:44:48 +01:00
Daniel Trstenjak
817d92b703 OcclusionQueryNode: fix use case of user defined query geometry
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.
2020-01-20 16:42:38 +01:00
Daniel Trstenjak
5624a22fe4 OcclusionQueryNode: ensure a valid query geometry
If the query geometry is invalid then don't do any occlusion queries and
never traverse the subgraphs.
2019-02-21 17:34:26 +00:00
Robert Osfield
02d7d980a7 Introduced a QueryGeometry::getQueryResult(const osg::Camera*) method as a more informative replacedment for QueryGeometry::getNumPixels(). 2019-01-26 16:33:23 +00:00
Daniel Trstenjak
c8521068a5 OcclusionQueryNode: add resetting of queries
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.
2019-01-26 15:22:08 +00:00
Robert Osfield
5d03bb9a2b From Jannik Heller, "This submission fixes a stuttering issue that may occur when occlusion query nodes are in view. The problem is that OSG retrieves the occlusion query result without first checking if it's available (GL_QUERY_RESULT_AVAILABLE). Thus, the driver has to sync with the GPU i.e. wait for all queued draw calls to complete. This is particularly bad in V-Synced situations where the driver may be using multi frame queueing techniques - coupled with the fact that OSG only runs an occlusion query every 5th frame, results in very unpleasant stuttering in some situations.
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."
2016-03-01 10:37:41 +00:00
Robert Osfield
14a563dc9f Ran script to remove trailing spaces and tabs 2012-03-21 17:36:20 +00:00
Robert Osfield
c1af863f78 From Morten Hauknes, "I have been using the getLastVisiblePixelCount on pre 3.0 osg. I believe maybe this was a private function that we made public in our side. I use(d) this method to make a simple algorithm to tell how much visible an object was in percent.
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."
2011-09-13 13:38:26 +00:00
Robert Osfield
c617ea0163 Fixed virtual method mismtaches between subclasses and parent classes. 2011-06-23 16:36:36 +00:00
Robert Osfield
410b4fd109 Converted FrameStamp::g/setFrameNumber from int to uint 2010-12-22 20:11:05 +00:00
Robert Osfield
df7df0739a From Lukasz Izdebski, "I made some changes in OcclusionQueryNode file.
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."
2010-09-15 11:27:31 +00:00
Robert Osfield
d50eacd07e From Paul Martz, "The changes are very similar to Magne's, except they now take the near plane into account. The changes are:
* 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."
2010-02-26 10:13:28 +00:00
Robert Osfield
3b4af26136 From Paul Martz, fixed get/set methods API 2008-02-27 11:43:58 +00:00
Robert Osfield
9d010e14fe From Paul Martz, "his pretty much wraps up the OcclusionQueryNode work. I might make some additional modifications if testing reveals any issues, otherwise it's ready for 2.4." 2008-01-10 11:02:21 +00:00
Robert Osfield
b222d4201c From Paul Martz, "The osgocclusionquery example contained some duplicate code that was also in the core OSG occlusion query code. This change removes the need for that." 2007-12-26 22:00:28 +00:00
Robert Osfield
4889342c4a From Paul Martz, Introduced osg::OcclusionQueryNode with support for OpenGL occlusion query extension 2007-12-21 14:45:16 +00:00