00001 // Filename: cullTraverserData.I 00002 // Created by: drose (06Mar02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: CullTraverserData::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE CullTraverserData:: 00026 CullTraverserData(const NodePath &start, 00027 const TransformState *render_transform, 00028 const TransformState *net_transform, 00029 const RenderState *state, 00030 GeometricBoundingVolume *view_frustum, 00031 GeometricBoundingVolume *guard_band) : 00032 _node_path(start), 00033 _render_transform(render_transform), 00034 _net_transform(net_transform), 00035 _state(state), 00036 _view_frustum(view_frustum), 00037 _guard_band(guard_band) 00038 { 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: CullTraverserData::Copy Constructor 00043 // Access: Public 00044 // Description: 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE CullTraverserData:: 00047 CullTraverserData(const CullTraverserData ©) : 00048 _node_path(copy._node_path), 00049 _render_transform(copy._render_transform), 00050 _net_transform(copy._net_transform), 00051 _state(copy._state), 00052 _view_frustum(copy._view_frustum), 00053 _guard_band(copy._guard_band) 00054 { 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: CullTraverserData::Copy Assignment Operator 00059 // Access: Public 00060 // Description: 00061 //////////////////////////////////////////////////////////////////// 00062 INLINE void CullTraverserData:: 00063 operator = (const CullTraverserData ©) { 00064 _node_path = copy._node_path; 00065 _render_transform = copy._render_transform; 00066 _net_transform = copy._net_transform; 00067 _state = copy._state; 00068 _view_frustum = copy._view_frustum; 00069 _guard_band = copy._guard_band; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: CullTraverserData::Constructor 00074 // Access: Public 00075 // Description: This constructor creates a CullTraverserData object 00076 // that reflects the next node down in the traversal. 00077 //////////////////////////////////////////////////////////////////// 00078 INLINE CullTraverserData:: 00079 CullTraverserData(const CullTraverserData &parent, PandaNode *child) : 00080 _node_path(parent._node_path, child), 00081 _render_transform(parent._render_transform), 00082 _net_transform(parent._net_transform), 00083 _state(parent._state), 00084 _view_frustum(parent._view_frustum), 00085 _guard_band(parent._guard_band) 00086 { 00087 } 00088 00089 //////////////////////////////////////////////////////////////////// 00090 // Function: CullTraverserData::Destructor 00091 // Access: Public 00092 // Description: 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE CullTraverserData:: 00095 ~CullTraverserData() { 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: CullTraverserData::node 00100 // Access: Public 00101 // Description: Returns the node traversed to so far. 00102 //////////////////////////////////////////////////////////////////// 00103 INLINE PandaNode *CullTraverserData:: 00104 node() const { 00105 return _node_path.node(); 00106 } 00107 00108 //////////////////////////////////////////////////////////////////// 00109 // Function: CullTraverserData::is_in_view 00110 // Access: Public 00111 // Description: Returns true if the current node is within the view 00112 // frustum, false otherwise. If the node's bounding 00113 // volume falls completely within the view frustum, this 00114 // will also reset the view frustum pointer, saving some 00115 // work for future nodes. 00116 //////////////////////////////////////////////////////////////////// 00117 INLINE bool CullTraverserData:: 00118 is_in_view(const DrawMask &camera_mask) { 00119 if (node()->get_transform()->is_invalid()) { 00120 // If the transform is invalid, forget it. 00121 return false; 00122 } 00123 00124 if ((node()->get_draw_mask() & camera_mask).is_zero()) { 00125 // If there are no draw bits in common with the camera, the node 00126 // is out. 00127 return false; 00128 } 00129 00130 if (_view_frustum == (GeometricBoundingVolume *)NULL) { 00131 // If the transform is valid, but we don't have a frustum, it's 00132 // always in. 00133 return true; 00134 } 00135 00136 // Otherwise, compare the bounding volume to the frustum. 00137 return is_in_view_impl(); 00138 } 00139 00140 //////////////////////////////////////////////////////////////////// 00141 // Function: CullTraverserData::apply_transform_and_state 00142 // Access: Public 00143 // Description: Applies the transform and state from the current 00144 // node onto the current data. This also evaluates 00145 // billboards, etc. 00146 //////////////////////////////////////////////////////////////////// 00147 INLINE void CullTraverserData:: 00148 apply_transform_and_state(CullTraverser *trav) { 00149 apply_transform_and_state(trav, node()->get_transform(), 00150 node()->get_state(), node()->get_effects()); 00151 } 00152