Panda3D
Loading...
Searching...
No Matches
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
15#include "callbackNode.h"
16#include "cullTraverser.h"
17#include "cullTraverserData.h"
18#include "cullableObject.h"
19#include "cullHandler.h"
20
21TypeHandle NodeCullCallbackData::_type_handle;
22
23/**
24 *
25 */
26void NodeCullCallbackData::
27output(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 */
41upcall() {
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 visit all the node's children.
60 PandaNodePipelineReader *node_reader = _data.node_reader();
61 PandaNode::Children children = node_reader->get_children();
62 node_reader->release();
63 int num_children = children.get_num_children();
64 for (int i = 0; i < num_children; ++i) {
65 CullTraverserData next_data(_data, children.get_child(i));
66 _trav->traverse(next_data);
67 }
68}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A special node that can issue arbitrary callbacks to user code, either during the cull or draw traver...
get_draw_callback
Returns the CallbackObject set by set_draw_callback().
This is a generic object that can be assigned to a callback at various points in the rendering proces...
virtual void record_object(CullableObject *object, const CullTraverser *traverser)
This callback function is intended to be overridden by a derived class.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
PandaNode * node() const
Returns the node traversed to so far.
PandaNodePipelineReader * node_reader()
Returns the PipelineReader for the node traversed to so far.
CullHandler * get_cull_handler() const
Returns the object that will receive the culled Geoms.
void traverse(const NodePath &root)
Begins the traversal from the indicated node.
The smallest atom of cull.
virtual void upcall()
You should make this call during the callback if you want to continue the normal rendering function t...
Encapsulates the data from a PandaNode, pre-fetched for one stage of the pipeline.
Definition pandaNode.h:840
void release()
Releases the lock on this object.
Definition pandaNode.I:1242
PandaNode::Children get_children() const
Returns an object that can be used to walk through the list of children of the node.
Definition pandaNode.I:1569
PandaNode * get_child(size_t n) const
Returns the nth child of the node.
Definition pandaNode.I:962
size_t get_num_children() const
Returns the number of children of the node.
Definition pandaNode.I:953
A basic node of the scene graph or data graph.
Definition pandaNode.h:65
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
Definition typedObject.I:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.