Panda3D
 All Classes Functions Variables Enumerations
nodeCullCallbackData.cxx
1 // Filename: nodeCullCallbackData.cxx
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 #include "nodeCullCallbackData.h"
16 #include "callbackNode.h"
17 #include "cullTraverser.h"
18 #include "cullTraverserData.h"
19 #include "cullableObject.h"
20 #include "cullHandler.h"
21 
22 TypeHandle NodeCullCallbackData::_type_handle;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Function: NodeCullCallbackData::output
26 // Access: Published, Virtual
27 // Description:
28 ////////////////////////////////////////////////////////////////////
29 void NodeCullCallbackData::
30 output(ostream &out) const {
31  out << get_type() << "(" << (void *)_trav << ", " << (void *)&_data << ")";
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: NodeCullCallbackData::upcall
36 // Access: Published, Virtual
37 // Description: You should make this call during the callback if you
38 // want to continue the normal rendering function that
39 // would have been done in the absence of a callback.
40 //
41 // Specifically, this method will add this node to the
42 // draw queue, and continue the cull traversal for all
43 // the nodes below. If you omit this call, this node
44 // and its children will be pruned from the render
45 // result.
46 ////////////////////////////////////////////////////////////////////
48 upcall() {
49  PandaNode *node = _data.node();
50  if (node->is_of_type(CallbackNode::get_class_type())) {
51  CallbackNode *cbnode = DCAST(CallbackNode, _data.node());
52 
53  // OK, render this node. Rendering a CallbackNode means creating
54  // a CullableObject for the draw_callback, if any. We don't need
55  // to pass any Geoms, however.
56  CallbackObject *cbobj = cbnode->get_draw_callback();
57  if (cbobj != (CallbackObject *)NULL) {
58  CullableObject *object =
59  new CullableObject(NULL, _data._state,
60  _data.get_internal_transform(_trav));
61  object->set_draw_callback(cbobj);
62  _trav->get_cull_handler()->record_object(object, _trav);
63  }
64  }
65 
66  // Now traverse below.
67  _trav->traverse_below(_data);
68 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
virtual void traverse_below(CullTraverserData &data)
Traverses all the children of the indicated node, with the given data, which has been converted into ...
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:63
PandaNode * node() const
Returns the node traversed to so far.
A special node that can issue arbitrary callbacks to user code, either during the cull or draw traver...
Definition: callbackNode.h:28
CallbackObject * get_draw_callback() const
Returns the CallbackObject set by set_draw_callback().
Definition: callbackNode.I:124
The smallest atom of cull.
virtual void record_object(CullableObject *object, const CullTraverser *traverser)
This callback function is intended to be overridden by a derived class.
Definition: cullHandler.cxx:52
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
This is a generic object that can be assigned to a callback at various points in the rendering proces...
void set_draw_callback(CallbackObject *draw_callback)
Specifies a CallbackObject that will be responsible for drawing this object.
virtual void upcall()
You should make this call during the callback if you want to continue the normal rendering function t...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85