Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OcclusionQueryNode: fix use case of user defined query geometry #813

Merged
merged 2 commits into from
Aug 22, 2019

Conversation

dan-t
Copy link
Contributor

@dan-t dan-t commented Aug 14, 2019

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.

@openscenegraph
Copy link
Owner

@mp3butcher Julian, could you review this PR and see if it's addresses the issues you were up against?

@mp3butcher
Copy link
Contributor

mp3butcher commented Aug 20, 2019

a pr against 3.6 would be better in order to review

@mp3butcher
Copy link
Contributor

mp3butcher commented Aug 20, 2019

@robertosfield ...master lacks a PR i've done to take into acount _enable

cfd190a
and
5311d6f
may be merge in master
before this one

@@ -158,8 +158,11 @@ public:
osg::StateSet* getQueryStateSet();
const osg::StateSet* getQueryStateSet() const;

// Get the QueryGeometry object used for occlusion query. Returns 0 if no QueryGeometry is created.
osg::QueryGeometry* getQueryGeometry();
Copy link
Contributor

@mp3butcher mp3butcher Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dan-t removing not const getQuerYGeometry breaks backward client usage:
client code may use this method to do custom geometry...further as getNumpixels is not const it mandates to use nonconst getQueryGeometry to retrieve visible pixels for custom decision based on num visible pixels

Copy link
Contributor Author

@dan-t dan-t Aug 21, 2019 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robertosfield Can you please decide if breaking backward compatibility is acceptable if it fixes a broken version.

Copy link
Contributor

@mp3butcher mp3butcher Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dan-t a simple way to circumvent the issue would be to control query geometry validity in getPassed itself
something like

 if ( !_validQueryGeometry )
    {
        if(qg->getBoundingBox().valid())
            _validQueryGeometry = true;
        else
        {
            // There're cases that the occlusion test result has been retrieved
            // after the query geometry has been changed, it's the result of the
            // geometry before the change.
            qg->reset();
    
            // The box of the query geometry is invalid, return false to not traverse
            // the subgraphs.
            _passed = false;
            return _passed;
        }
    }

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.
@openscenegraph
Copy link
Owner

openscenegraph commented Aug 21, 2019 via email

@mp3butcher
Copy link
Contributor

1a9fcfc
solve the backward compat issue

@dan-t
Copy link
Contributor Author

dan-t commented Aug 21, 2019 via email

@mp3butcher
Copy link
Contributor

oups u're right (validgeometry is not muted properly)...
I'm pretty ok with your changes but as long as your pr is not against 3.6 branch or(@robertosfield don't merge #772 with master) i won't be happy with it

@dan-t
Copy link
Contributor Author

dan-t commented Aug 21, 2019 via email

@mp3butcher
Copy link
Contributor

mp3butcher commented Aug 21, 2019

as i already said cherry-pick this commit into 3.6 branch involve conflicts so for proper reviewing something should be done by you (pr against 3.6) or Robert (merging #772 in master)

@openscenegraph
Copy link
Owner

I've merged the || !_enabled change in 3.6 into master:

void OcclusionQueryNode::traverseQuery( const Camera* camera, NodeVisitor& nv )
{
if (!_validQueryGeometry || ! _enabled)
return;

I don't know how it ended up diverged from 3.6, one missing commit me thinks. I will now merge this PR as it look generally OK, but I'm @dan-t lots here as I don't have too much knowledge about this particular class and it's usage.

@openscenegraph openscenegraph merged commit 88a6868 into openscenegraph:master Aug 22, 2019
@openscenegraph
Copy link
Owner

Ack, now got a compile error with master, the above tweak of mine wasn't appropriate... now looking into how to resolve it.

@openscenegraph
Copy link
Owner

Hang my head in shame, I broke the build be inappropriate trying to match the 3.6 and master on this PR without spotting all the changes. Now fixed:

3a17fd3

@mp3butcher
Copy link
Contributor

@openscenegraph please merge with 3.6 branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants