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
048ece35
Commit
048ece35
authored
May 26, 2020
by
Daniel Trstenjak
Browse files
Camera: convenience methods to find nested callback by type
parent
3547b985
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/osg/Callback
View file @
048ece35
...
...
@@ -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 @
048ece35
...
...
@@ -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
)
{
...
...
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