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