Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
OpenSceneGraph
Commits
27f400bb
Unverified
Commit
27f400bb
authored
Jun 04, 2020
by
OpenSceneGraph git repository
Committed by
GitHub
Jun 04, 2020
Browse files
Merge pull request #957 from dan-t/camera_callback_fixes
Fix camera callbacks of OcclusionQueryNode
parents
ba2a6f73
3fc3dcbb
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/osg/Callback
View file @
27f400bb
...
...
@@ -121,8 +121,33 @@ class OSG_EXPORT Callback : public virtual Object {
}
}
protected:
/** Convenience method to find a nested callback by type. */
template
<
typename
T
>
static
T
*
findNestedCallback
(
osg
::
Callback
*
callback
)
{
if
(
!
callback
)
return
nullptr
;
if
(
T
*
cb
=
dynamic_cast
<
T
*>
(
callback
))
return
cb
;
return
findNestedCallback
<
T
>
(
callback
->
getNestedCallback
());
}
/** Convenience method to find a nested callback by type. */
template
<
typename
T
>
static
const
T
*
findNestedCallback
(
const
osg
::
Callback
*
callback
)
{
if
(
!
callback
)
return
nullptr
;
if
(
const
T
*
cb
=
dynamic_cast
<
const
T
*>
(
callback
))
return
cb
;
return
findNestedCallback
<
T
>
(
callback
->
getNestedCallback
());
}
protected:
virtual
~
Callback
()
{}
ref_ptr
<
Callback
>
_nestedCallback
;
};
...
...
include/osg/Camera
View file @
27f400bb
...
...
@@ -642,6 +642,14 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Get the const initial draw callback.*/
const
DrawCallback
*
getInitialDrawCallback
()
const
{
return
_initialDrawCallback
.
get
();
}
/** Convenience method to find a nested initial draw callback by type. */
template
<
typename
T
>
T
*
findInitialDrawCallback
()
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_initialDrawCallback
.
get
());
}
/** Convenience method to find a nested initial draw callback by type. */
template
<
typename
T
>
const
T
*
findInitialDrawCallback
()
const
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_initialDrawCallback
.
get
());
}
/** Convenience method that sets DrawCallback Initial callback of the node if it doesn't exist, or nest it into the existing one. */
inline
void
addInitialDrawCallback
(
DrawCallback
*
nc
)
{
...
...
@@ -680,6 +688,14 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Get the const pre draw callback.*/
const
DrawCallback
*
getPreDrawCallback
()
const
{
return
_preDrawCallback
.
get
();
}
/** Convenience method to find a nested pre draw callback by type. */
template
<
typename
T
>
T
*
findPreDrawCallback
()
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_preDrawCallback
.
get
());
}
/** Convenience method to find a nested pre draw callback by type. */
template
<
typename
T
>
const
T
*
findPreDrawCallback
()
const
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_preDrawCallback
.
get
());
}
/** Convenience method that sets DrawCallback Initial callback of the node if it doesn't exist, or nest it into the existing one. */
inline
void
addPreDrawCallback
(
DrawCallback
*
nc
)
{
...
...
@@ -718,6 +734,14 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Get the const post draw callback.*/
const
DrawCallback
*
getPostDrawCallback
()
const
{
return
_postDrawCallback
.
get
();
}
/** Convenience method to find a nested post draw callback by type. */
template
<
typename
T
>
T
*
findPostDrawCallback
()
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_postDrawCallback
.
get
());
}
/** Convenience method to find a nested post draw callback by type. */
template
<
typename
T
>
const
T
*
findPostDrawCallback
()
const
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_postDrawCallback
.
get
());
}
/** Convenience method that sets DrawCallback Initial callback of the node if it doesn't exist, or nest it into the existing one. */
inline
void
addPostDrawCallback
(
DrawCallback
*
nc
)
{
...
...
@@ -756,6 +780,14 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Get the const final draw callback.*/
const
DrawCallback
*
getFinalDrawCallback
()
const
{
return
_finalDrawCallback
.
get
();
}
/** Convenience method to find a nested final draw callback by type. */
template
<
typename
T
>
T
*
findFinalDrawCallback
()
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_finalDrawCallback
.
get
());
}
/** Convenience method to find a nested final draw callback by type. */
template
<
typename
T
>
const
T
*
findFinalDrawCallback
()
const
{
return
osg
::
Callback
::
findNestedCallback
<
T
>
(
_finalDrawCallback
.
get
());
}
/** Convenience method that sets DrawCallback Initial callback of the node if it doesn't exist, or nest it into the existing one. */
inline
void
addFinalDrawCallback
(
DrawCallback
*
nc
)
{
...
...
src/osg/OcclusionQueryNode.cpp
View file @
27f400bb
...
...
@@ -320,15 +320,20 @@ QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const
osg
::
Camera
*
cam
=
renderInfo
.
getCurrentCamera
();
// Add callbacks if necessary.
if
(
!
cam
->
getPostDrawCallback
()
)
RetrieveQueriesCallback
*
rqcb
=
cam
->
findPostDrawCallback
<
RetrieveQueriesCallback
>
();
if
(
!
rqcb
)
{
RetrieveQueriesCallback
*
rqcb
=
new
RetrieveQueriesCallback
(
ext
);
cam
->
setPostDrawCallback
(
rqcb
);
rqcb
=
new
RetrieveQueriesCallback
(
ext
);
cam
->
addPostDrawCallback
(
rqcb
);
ClearQueriesCallback
*
cqcb
=
cam
->
findPreDrawCallback
<
ClearQueriesCallback
>
();
if
(
!
cqcb
)
{
cqcb
=
new
ClearQueriesCallback
;
cam
->
addPreDrawCallback
(
cqcb
);
}
ClearQueriesCallback
*
cqcb
=
new
ClearQueriesCallback
;
cqcb
->
_rqcb
=
rqcb
;
cam
->
setPreDrawCallback
(
cqcb
);
}
// Get TestResult from Camera map
...
...
@@ -343,7 +348,6 @@ QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const
}
}
// Issue query
if
(
!
tr
->
_init
)
{
...
...
@@ -358,9 +362,6 @@ QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const
return
;
}
// Add TestResult to RQCB.
RetrieveQueriesCallback
*
rqcb
=
dynamic_cast
<
RetrieveQueriesCallback
*
>
(
cam
->
getPostDrawCallback
()
);
if
(
!
rqcb
)
{
OSG_FATAL
<<
"osgOQ: QG: Invalid RQCB."
<<
std
::
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment