Panda3D
 All Classes Functions Variables Enumerations
cullTraverser.h
1 // Filename: cullTraverser.h
2 // Created by: drose (23eb02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CULLTRAVERSER_H
16 #define CULLTRAVERSER_H
17 
18 #include "pandabase.h"
19 
20 #include "geom.h"
21 #include "sceneSetup.h"
22 #include "renderState.h"
23 #include "transformState.h"
24 #include "geometricBoundingVolume.h"
25 #include "pointerTo.h"
26 #include "camera.h"
27 #include "drawMask.h"
28 #include "typedReferenceCount.h"
29 #include "pStatCollector.h"
30 #include "fogAttrib.h"
31 
33 class PandaNode;
34 class CullHandler;
35 class CullableObject;
36 class CullTraverserData;
37 class PortalClipper;
38 class NodePath;
39 
40 ////////////////////////////////////////////////////////////////////
41 // Class : CullTraverser
42 // Description : This object performs a depth-first traversal of the
43 // scene graph, with optional view-frustum culling,
44 // collecting CullState and searching for GeomNodes.
45 // Each renderable Geom encountered is passed along with
46 // its associated RenderState to the CullHandler object.
47 ////////////////////////////////////////////////////////////////////
48 class EXPCL_PANDA_PGRAPH CullTraverser : public TypedReferenceCount {
49 PUBLISHED:
50  CullTraverser();
51  CullTraverser(const CullTraverser &copy);
52 
53  INLINE GraphicsStateGuardianBase *get_gsg() const;
54  INLINE Thread *get_current_thread() const;
55 
56  virtual void set_scene(SceneSetup *scene_setup,
58  bool dr_incomplete_render);
59  INLINE SceneSetup *get_scene() const;
60  INLINE bool has_tag_state_key() const;
61  INLINE const string &get_tag_state_key() const;
62 
63  INLINE void set_camera_mask(const DrawMask &camera_mask);
64  INLINE const DrawMask &get_camera_mask() const;
65 
66  INLINE const TransformState *get_camera_transform() const;
67  INLINE const TransformState *get_world_transform() const;
68 
69  INLINE const RenderState *get_initial_state() const;
70  INLINE bool get_depth_offset_decals() const;
71 
72  INLINE void set_view_frustum(GeometricBoundingVolume *view_frustum);
73  INLINE GeometricBoundingVolume *get_view_frustum() const;
74 
75  INLINE void set_cull_handler(CullHandler *cull_handler);
76  INLINE CullHandler *get_cull_handler() const;
77 
78  INLINE void set_portal_clipper(PortalClipper *portal_clipper);
79  INLINE PortalClipper *get_portal_clipper() const;
80 
81  INLINE bool get_effective_incomplete_render() const;
82 
83  void traverse(const NodePath &root);
84  void traverse(CullTraverserData &data);
85  virtual void traverse_below(CullTraverserData &data);
86 
87  virtual void end_traverse();
88 
89  INLINE static void flush_level();
90 
91  void draw_bounding_volume(const BoundingVolume *vol,
92  const TransformState *internal_transform) const;
93 
94 protected:
95  INLINE void do_traverse(CullTraverserData &data);
96 
97  virtual bool is_in_view(CullTraverserData &data);
98 
99 public:
100  // Statistics
101  static PStatCollector _nodes_pcollector;
102  static PStatCollector _geom_nodes_pcollector;
103  static PStatCollector _geoms_pcollector;
104  static PStatCollector _geoms_occluded_pcollector;
105 
106 private:
107  void show_bounds(CullTraverserData &data, bool tight);
108  static PT(Geom) make_bounds_viz(const BoundingVolume *vol);
109  PT(Geom) make_tight_bounds_viz(PandaNode *node) const;
110  static LVertex compute_point(const BoundingSphere *sphere,
111  PN_stdfloat latitude, PN_stdfloat longitude);
112  static CPT(RenderState) get_bounds_outer_viz_state();
113  static CPT(RenderState) get_bounds_inner_viz_state();
114  static CPT(RenderState) get_depth_offset_state();
115 
117  Thread *_current_thread;
118  PT(SceneSetup) _scene_setup;
119  DrawMask _camera_mask;
120  bool _has_tag_state_key;
121  string _tag_state_key;
122  CPT(RenderState) _initial_state;
123  PT(GeometricBoundingVolume) _view_frustum;
124  CullHandler *_cull_handler;
125  PortalClipper *_portal_clipper;
126  bool _effective_incomplete_render;
127 
128 public:
129  static TypeHandle get_class_type() {
130  return _type_handle;
131  }
132  static void init_type() {
133  TypedReferenceCount::init_type();
134  register_type(_type_handle, "CullTraverser",
135  TypedReferenceCount::get_class_type());
136  }
137  virtual TypeHandle get_type() const {
138  return get_class_type();
139  }
140  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
141 
142 private:
143  static TypeHandle _type_handle;
144 };
145 
146 #include "cullTraverserData.h"
147 
148 #include "cullTraverser.I"
149 
150 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This defines a bounding sphere, consisting of a center and a radius.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
This defines the abstract interface for an object that receives Geoms identified by the CullTraverser...
Definition: cullHandler.h:31
The smallest atom of cull.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: portalClipper.h:52
A container for geometry primitives.
Definition: geom.h:58
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
Definition: thread.h:51
Encapsulates all the communication with a particular instance of a given rendering backend...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:35
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48