Panda3D
callbackNode.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file callbackNode.I
10  * @author drose
11  * @date 2009-03-13
12  */
13 
14 /**
15  * Sets the CallbackObject that will be notified when this node is visited
16  * during the cull traversal. This callback will be made during the cull
17  * thread.
18  *
19  * The cull traversal is responsible for determining which nodes are visible
20  * and within the view frustum, and for accumulating state and transform, and
21  * generally building up the list of CullableObjects that are to be eventually
22  * passed to the draw traversal for rendering.
23  *
24  * At the time the cull traversal callback is made, the node has been
25  * determined to be visible and it has passed the bounding-volume test, so it
26  * lies within the view frustum.
27  *
28  * The callback is passed an instance of a NodeCullCallbackData, which
29  * contains pointers to the CullTraverser and CullTraverserData--enough data
30  * to examine the current node and its place within the scene graph. The
31  * callback *replaces* the normal cull behavior, so if your callback does
32  * nothing, the cull traversal will not continue below this node. If you wish
33  * the cull traversal to continue to visit this node and below, you must call
34  * cbdata->upcall() from your callback.
35  */
36 INLINE void CallbackNode::
37 set_cull_callback(CallbackObject *object) {
38  CDWriter cdata(_cycler);
39  cdata->_cull_callback = object;
40 }
41 
42 /**
43  * Removes the callback set by an earlier call to set_cull_callback().
44  */
45 INLINE void CallbackNode::
47  set_cull_callback(nullptr);
48 }
49 
50 /**
51  * Returns the CallbackObject set by set_cull_callback().
52  */
53 INLINE CallbackObject *CallbackNode::
54 get_cull_callback() const {
55  CDReader cdata(_cycler);
56  return cdata->_cull_callback;
57 }
58 
59 /**
60  * Sets the CallbackObject that will be notified when this node is visited
61  * during the draw traversal. This callback will be made during the draw
62  * thread.
63  *
64  * The draw traversal is responsible for actually issuing the commands to the
65  * graphics engine to draw primitives. Its job is to walk through the list of
66  * CullableObjects build up by the cull traversal, as quickly as possible,
67  * issuing the appropriate commands to draw each one.
68  *
69  * At the time the draw traversal callback is made, the graphics state has
70  * been loaded with the correct modelview transform and render state, and the
71  * primitives (if any) in this node are ready to be drawn.
72  *
73  * The callback is passed an instance of a GeomDrawCallbackData, which
74  * contains pointers to the current state and transform, as well as the
75  * current GSG. There is a Geom pointer as well, but it will always be NULL
76  * to this callback, since the CallbackNode does not itself contain any Geoms.
77  */
78 INLINE void CallbackNode::
80  CDWriter cdata(_cycler);
81  cdata->_draw_callback = object;
82 }
83 
84 /**
85  * Removes the callback set by an earlier call to set_draw_callback().
86  */
87 INLINE void CallbackNode::
89  set_draw_callback(nullptr);
90 }
91 
92 /**
93  * Returns the CallbackObject set by set_draw_callback().
94  */
95 INLINE CallbackObject *CallbackNode::
96 get_draw_callback() const {
97  CDReader cdata(_cycler);
98  return cdata->_draw_callback;
99 }
100 
101 /**
102  *
103  */
104 INLINE CallbackNode::CData::
105 CData() {
106 }
107 
108 /**
109  *
110  */
111 INLINE CallbackNode::CData::
112 CData(const CallbackNode::CData &copy) :
113  _cull_callback(copy._cull_callback),
114  _draw_callback(copy._draw_callback)
115 {
116 }
set_cull_callback
Sets the CallbackObject that will be notified when this node is visited during the cull traversal.
Definition: callbackNode.h:33
set_draw_callback
Sets the CallbackObject that will be notified when this node is visited during the draw traversal.
Definition: callbackNode.h:38
void clear_cull_callback()
Removes the callback set by an earlier call to set_cull_callback().
Definition: callbackNode.I:46
void clear_draw_callback()
Removes the callback set by an earlier call to set_draw_callback().
Definition: callbackNode.I:88
This is a generic object that can be assigned to a callback at various points in the rendering proces...