Panda3D
nodeCullCallbackData.cxx
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 nodeCullCallbackData.cxx
10  * @author drose
11  * @date 2009-03-13
12  */
13 
14 #include "nodeCullCallbackData.h"
15 #include "callbackNode.h"
16 #include "cullTraverser.h"
17 #include "cullTraverserData.h"
18 #include "cullableObject.h"
19 #include "cullHandler.h"
20 
21 TypeHandle NodeCullCallbackData::_type_handle;
22 
23 /**
24  *
25  */
26 void NodeCullCallbackData::
27 output(std::ostream &out) const {
28  out << get_type() << "(" << (void *)_trav << ", " << (void *)&_data << ")";
29 }
30 
31 /**
32  * You should make this call during the callback if you want to continue the
33  * normal rendering function that would have been done in the absence of a
34  * callback.
35  *
36  * Specifically, this method will add this node to the draw queue, and
37  * continue the cull traversal for all the nodes below. If you omit this
38  * call, this node and its children will be pruned from the render result.
39  */
41 upcall() {
42  PandaNode *node = _data.node();
43  if (node->is_of_type(CallbackNode::get_class_type())) {
44  CallbackNode *cbnode = (CallbackNode *)node;
45 
46  // OK, render this node. Rendering a CallbackNode means creating a
47  // CullableObject for the draw_callback, if any. We don't need to pass
48  // any Geoms, however.
49  CallbackObject *cbobj = cbnode->get_draw_callback();
50  if (cbobj != nullptr) {
51  CullableObject *object =
52  new CullableObject(nullptr, _data._state,
53  _data.get_internal_transform(_trav));
54  object->set_draw_callback(cbobj);
55  _trav->get_cull_handler()->record_object(object, _trav);
56  }
57  }
58 
59  // Now traverse below.
60  _trav->traverse_below(_data);
61 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_draw_callback
Returns the CallbackObject set by set_draw_callback().
Definition: callbackNode.h:38
virtual void traverse_below(CullTraverserData &data)
Traverses all the children of the indicated node, with the given data, which has been converted into ...
A special node that can issue arbitrary callbacks to user code, either during the cull or draw traver...
Definition: callbackNode.h:26
PandaNode * node() const
Returns the node traversed to so far.
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:43
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition: typedObject.I:28
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81