00001 // Filename: callbackNode.I 00002 // Created by: drose (13Mar09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: CallbackNode::set_cull_callback 00018 // Access: Published 00019 // Description: Sets the CallbackObject that will be notified when 00020 // this node is visited during the cull traversal. This 00021 // callback will be made during the cull thread. 00022 // 00023 // The cull traversal is responsible for determining 00024 // which nodes are visible and within the view frustum, 00025 // and for accumulating state and transform, and 00026 // generally building up the list of CullableObjects 00027 // that are to be eventually passed to the draw 00028 // traversal for rendering. 00029 // 00030 // At the time the cull traversal callback is made, the 00031 // node has been determined to be visible and it has 00032 // passed the bounding-volume test, so it lies within 00033 // the view frustum. 00034 // 00035 // The callback is passed an instance of a 00036 // NodeCullCallbackData, which contains pointers to the 00037 // CullTraverser and CullTraverserData--enough data to 00038 // examine the current node and its place within the 00039 // scene graph. The callback *replaces* the normal cull 00040 // behavior, so if your callback does nothing, the cull 00041 // traversal will not continue below this node. If you 00042 // wish the cull traversal to continue to visit this 00043 // node and below, you must call cbdata->upcall() 00044 // from your callback. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE void CallbackNode:: 00047 set_cull_callback(CallbackObject *object) { 00048 CDWriter cdata(_cycler); 00049 cdata->_cull_callback = object; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: CallbackNode::clear_cull_callback 00054 // Access: Published 00055 // Description: Removes the callback set by an earlier call to 00056 // set_cull_callback(). 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE void CallbackNode:: 00059 clear_cull_callback() { 00060 set_cull_callback(NULL); 00061 } 00062 00063 //////////////////////////////////////////////////////////////////// 00064 // Function: CallbackNode::get_cull_callback 00065 // Access: Published 00066 // Description: Returns the CallbackObject set by set_cull_callback(). 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE CallbackObject *CallbackNode:: 00069 get_cull_callback() const { 00070 CDReader cdata(_cycler); 00071 return cdata->_cull_callback; 00072 } 00073 00074 //////////////////////////////////////////////////////////////////// 00075 // Function: CallbackNode::set_draw_callback 00076 // Access: Published 00077 // Description: Sets the CallbackObject that will be notified when 00078 // this node is visited during the draw traversal. This 00079 // callback will be made during the draw thread. 00080 // 00081 // The draw traversal is responsible for actually 00082 // issuing the commands to the graphics engine to draw 00083 // primitives. Its job is to walk through the list of 00084 // CullableObjects build up by the cull traversal, as 00085 // quickly as possible, issuing the appropriate commands 00086 // to draw each one. 00087 // 00088 // At the time the draw traversal callback is made, the 00089 // graphics state has been loaded with the correct 00090 // modelview transform and render state, and the 00091 // primitives (if any) in this node are ready to be 00092 // drawn. 00093 // 00094 // The callback is passed an instance of a 00095 // GeomDrawCallbackData, which contains pointers to the 00096 // current state and transform, as well as the current 00097 // GSG. There is a Geom pointer as well, but it will 00098 // always be NULL to this callback, since the 00099 // CallbackNode does not itself contain any Geoms. 00100 //////////////////////////////////////////////////////////////////// 00101 INLINE void CallbackNode:: 00102 set_draw_callback(CallbackObject *object) { 00103 CDWriter cdata(_cycler); 00104 cdata->_draw_callback = object; 00105 } 00106 00107 //////////////////////////////////////////////////////////////////// 00108 // Function: CallbackNode::clear_draw_callback 00109 // Access: Published 00110 // Description: Removes the callback set by an earlier call to 00111 // set_draw_callback(). 00112 //////////////////////////////////////////////////////////////////// 00113 INLINE void CallbackNode:: 00114 clear_draw_callback() { 00115 set_draw_callback(NULL); 00116 } 00117 00118 //////////////////////////////////////////////////////////////////// 00119 // Function: CallbackNode::get_draw_callback 00120 // Access: Published 00121 // Description: Returns the CallbackObject set by set_draw_callback(). 00122 //////////////////////////////////////////////////////////////////// 00123 INLINE CallbackObject *CallbackNode:: 00124 get_draw_callback() const { 00125 CDReader cdata(_cycler); 00126 return cdata->_draw_callback; 00127 } 00128 00129 //////////////////////////////////////////////////////////////////// 00130 // Function: CallbackNode::CData::Constructor 00131 // Access: Public 00132 // Description: 00133 //////////////////////////////////////////////////////////////////// 00134 INLINE CallbackNode::CData:: 00135 CData() { 00136 } 00137 00138 //////////////////////////////////////////////////////////////////// 00139 // Function: CallbackNode::CData::Copy Constructor 00140 // Access: Public 00141 // Description: 00142 //////////////////////////////////////////////////////////////////// 00143 INLINE CallbackNode::CData:: 00144 CData(const CallbackNode::CData ©) : 00145 _cull_callback(copy._cull_callback), 00146 _draw_callback(copy._draw_callback) 00147 { 00148 }