Panda3D
 All Classes Functions Variables Enumerations
nodeCullCallbackData.cxx
00001 // Filename: nodeCullCallbackData.cxx
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 #include "nodeCullCallbackData.h"
00016 #include "callbackNode.h"
00017 #include "cullTraverser.h"
00018 #include "cullTraverserData.h"
00019 #include "cullableObject.h"
00020 #include "cullHandler.h"
00021 
00022 TypeHandle NodeCullCallbackData::_type_handle;
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: NodeCullCallbackData::output
00026 //       Access: Published, Virtual
00027 //  Description:
00028 ////////////////////////////////////////////////////////////////////
00029 void NodeCullCallbackData::
00030 output(ostream &out) const {
00031   out << get_type() << "(" << (void *)_trav << ", " << (void *)&_data << ")";
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: NodeCullCallbackData::upcall
00036 //       Access: Published, Virtual
00037 //  Description: You should make this call during the callback if you
00038 //               want to continue the normal rendering function that
00039 //               would have been done in the absence of a callback.
00040 //
00041 //               Specifically, this method will add this node to the
00042 //               draw queue, and continue the cull traversal for all
00043 //               the nodes below.  If you omit this call, this node
00044 //               and its children will be pruned from the render
00045 //               result.
00046 ////////////////////////////////////////////////////////////////////
00047 void NodeCullCallbackData::
00048 upcall() {
00049   PandaNode *node = _data.node();
00050   if (node->is_of_type(CallbackNode::get_class_type())) {
00051     CallbackNode *cbnode = DCAST(CallbackNode, _data.node());
00052 
00053     // OK, render this node.  Rendering a CallbackNode means creating
00054     // a CullableObject for the draw_callback, if any.  We don't need
00055     // to pass any Geoms, however.
00056     CallbackObject *cbobj = cbnode->get_draw_callback();
00057     if (cbobj != (CallbackObject *)NULL) {
00058       CullableObject *object = 
00059         new CullableObject(NULL, _data._state,
00060                            _data.get_net_transform(_trav),
00061                            _data.get_modelview_transform(_trav),
00062                            _trav->get_gsg());
00063       object->set_draw_callback(cbobj);
00064       _trav->get_cull_handler()->record_object(object, _trav);
00065     }
00066   }
00067 
00068   // Now traverse below.
00069   _trav->traverse_below(_data);
00070 }
 All Classes Functions Variables Enumerations