00001 // Filename: cullTraverser.I 00002 // Created by: drose (23Feb02) 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 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: CullTraverser::get_gsg 00018 // Access: Published 00019 // Description: Returns the GraphicsStateGuardian in effect. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE GraphicsStateGuardianBase *CullTraverser:: 00022 get_gsg() const { 00023 return _gsg; 00024 } 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Function: CullTraverser::get_current_thread 00028 // Access: Published 00029 // Description: Returns the currently-executing thread object, as 00030 // passed to the CullTraverser constructor. 00031 //////////////////////////////////////////////////////////////////// 00032 INLINE Thread *CullTraverser:: 00033 get_current_thread() const { 00034 return _current_thread; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: CullTraverser::get_scene 00039 // Access: Published 00040 // Description: Returns the SceneSetup object. 00041 //////////////////////////////////////////////////////////////////// 00042 INLINE SceneSetup *CullTraverser:: 00043 get_scene() const { 00044 return _scene_setup; 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: CullTraverser::has_tag_state_key 00049 // Access: Published 00050 // Description: Returns true if a nonempty tag state key has been 00051 // specified for the scene's camera, false otherwise. 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE bool CullTraverser:: 00054 has_tag_state_key() const { 00055 return _has_tag_state_key; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: CullTraverser::get_tag_state_key 00060 // Access: Published 00061 // Description: Returns the tag state key that has been specified for 00062 // the scene's camera, if any. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE const string &CullTraverser:: 00065 get_tag_state_key() const { 00066 return _tag_state_key; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: CullTraverser::get_camera_transform 00071 // Access: Published 00072 // Description: Returns the position of the camera relative to the 00073 // starting node. 00074 //////////////////////////////////////////////////////////////////// 00075 INLINE const TransformState *CullTraverser:: 00076 get_camera_transform() const { 00077 return _scene_setup->get_camera_transform(); 00078 } 00079 00080 //////////////////////////////////////////////////////////////////// 00081 // Function: CullTraverser::get_world_transform 00082 // Access: Published 00083 // Description: Returns the position of the starting node relative 00084 // to the camera. This is the inverse of the camera 00085 // transform. 00086 // 00087 // Note that this value is always the position of the 00088 // starting node, not the current node, even if it is 00089 // sampled during a traversal. To get the transform of 00090 // the current node use 00091 // CullTraverserData::get_modelview_transform(). 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE const TransformState *CullTraverser:: 00094 get_world_transform() const { 00095 return _scene_setup->get_world_transform(); 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: CullTraverser::get_initial_state 00100 // Access: Published 00101 // Description: Returns the initial RenderState at the top of the 00102 // scene graph we are traversing, or the empty state if 00103 // the initial state was never set. 00104 //////////////////////////////////////////////////////////////////// 00105 INLINE const RenderState *CullTraverser:: 00106 get_initial_state() const { 00107 return _initial_state; 00108 } 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Function: CullTraverser::get_depth_offset_decals 00112 // Access: Published 00113 // Description: Returns the depth_offset_decals flag. See 00114 // set_depth_offset_decals(). 00115 //////////////////////////////////////////////////////////////////// 00116 INLINE bool CullTraverser:: 00117 get_depth_offset_decals() const { 00118 return _depth_offset_decals; 00119 } 00120 00121 //////////////////////////////////////////////////////////////////// 00122 // Function: CullTraverser::set_camera_mask 00123 // Access: Published 00124 // Description: Changes the visibility mask for the camera viewing 00125 // the scene. This is normally set automatically 00126 // at the time setup_scene() is called; you should 00127 // change this only if you want to render some set of 00128 // objects different from what the camera normally would 00129 // draw. 00130 //////////////////////////////////////////////////////////////////// 00131 INLINE void CullTraverser:: 00132 set_camera_mask(const DrawMask &camera_mask) { 00133 _camera_mask = camera_mask; 00134 } 00135 00136 //////////////////////////////////////////////////////////////////// 00137 // Function: CullTraverser::get_camera_mask 00138 // Access: Published 00139 // Description: Returns the visibility mask from the camera viewing 00140 // the scene. 00141 //////////////////////////////////////////////////////////////////// 00142 INLINE const DrawMask &CullTraverser:: 00143 get_camera_mask() const { 00144 return _camera_mask; 00145 } 00146 00147 //////////////////////////////////////////////////////////////////// 00148 // Function: CullTraverser::set_view_frustum 00149 // Access: Published 00150 // Description: Specifies the bounding volume that corresponds to the 00151 // view frustum. Any primitives that fall entirely 00152 // outside of this volume are not drawn. 00153 //////////////////////////////////////////////////////////////////// 00154 INLINE void CullTraverser:: 00155 set_view_frustum(GeometricBoundingVolume *view_frustum) { 00156 _view_frustum = view_frustum; 00157 } 00158 00159 //////////////////////////////////////////////////////////////////// 00160 // Function: CullTraverser::get_view_frustum 00161 // Access: Published 00162 // Description: Returns the bounding volume that corresponds to the 00163 // view frustum, or NULL if the view frustum is not in 00164 // use or has not been set. 00165 // 00166 // Note that the view frustum returned here is always in 00167 // the coordinate space of the starting node, not the 00168 // current node, even if it is sampled during a 00169 // traversal. To get the view frustum in the current 00170 // node's coordinate space, check in the current 00171 // CullTraverserData. 00172 //////////////////////////////////////////////////////////////////// 00173 INLINE GeometricBoundingVolume *CullTraverser:: 00174 get_view_frustum() const { 00175 return _view_frustum; 00176 } 00177 00178 //////////////////////////////////////////////////////////////////// 00179 // Function: CullTraverser::set_cull_handler 00180 // Access: Published 00181 // Description: Specifies the object that will receive the culled 00182 // Geoms. This must be set before calling traverse(). 00183 //////////////////////////////////////////////////////////////////// 00184 INLINE void CullTraverser:: 00185 set_cull_handler(CullHandler *cull_handler) { 00186 _cull_handler = cull_handler; 00187 } 00188 00189 //////////////////////////////////////////////////////////////////// 00190 // Function: CullTraverser::get_cull_handler 00191 // Access: Published 00192 // Description: Returns the object that will receive the culled 00193 // Geoms. 00194 //////////////////////////////////////////////////////////////////// 00195 INLINE CullHandler *CullTraverser:: 00196 get_cull_handler() const { 00197 return _cull_handler; 00198 } 00199 //////////////////////////////////////////////////////////////////// 00200 // Function: CullTraverser::set_portal_clipper 00201 // Access: Published 00202 // Description: Specifies _portal_clipper object pointer that 00203 // subsequent traverse() or traverse_below may use. 00204 //////////////////////////////////////////////////////////////////// 00205 INLINE void CullTraverser:: 00206 set_portal_clipper(PortalClipper *portal_clipper) { 00207 _portal_clipper = portal_clipper; 00208 } 00209 00210 //////////////////////////////////////////////////////////////////// 00211 // Function: CullTraverser::get_portal_clipper 00212 // Access: Published 00213 // Description: Returns the _portal_clipper pointer 00214 //////////////////////////////////////////////////////////////////// 00215 INLINE PortalClipper *CullTraverser:: 00216 get_portal_clipper() const { 00217 return _portal_clipper; 00218 } 00219 00220 //////////////////////////////////////////////////////////////////// 00221 // Function: CullTraverser::get_effective_incomplete_render 00222 // Access: Published 00223 // Description: Returns true if the cull traversal is effectively in 00224 // incomplete_render state, considering both the GSG's 00225 // incomplete_render and the current DisplayRegion's 00226 // incomplete_render flags. This returns the flag 00227 // during the cull traversal; see 00228 // GSG::get_effective_incomplete_render() for this same 00229 // flag during the draw traversal. 00230 //////////////////////////////////////////////////////////////////// 00231 INLINE bool CullTraverser:: 00232 get_effective_incomplete_render() const { 00233 return _effective_incomplete_render; 00234 } 00235 00236 //////////////////////////////////////////////////////////////////// 00237 // Function: CullTraverser::flush_level 00238 // Access: Published, Static 00239 // Description: Flushes the PStatCollectors used during traversal. 00240 //////////////////////////////////////////////////////////////////// 00241 INLINE void CullTraverser:: 00242 flush_level() { 00243 _nodes_pcollector.flush_level(); 00244 _geom_nodes_pcollector.flush_level(); 00245 _geoms_pcollector.flush_level(); 00246 _geoms_occluded_pcollector.flush_level(); 00247 }