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