Panda3D

cullResult.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 cullResult.h
10 * @author drose
11 * @date 2002-02-27
12 */
13
14 #ifndef CULLRESULT_H
15 #define CULLRESULT_H
16
17 #include "pandabase.h"
18 #include "cullBin.h"
19 #include "cullBinManager.h"
20 #include "renderState.h"
21 #include "cullableObject.h"
22 #include "geomMunger.h"
23 #include "referenceCount.h"
24 #include "pointerTo.h"
25 #include "pvector.h"
26 #include "pset.h"
27 #include "pmap.h"
28 #include "rescaleNormalAttrib.h"
29
30 class CullTraverser;
31 class GraphicsStateGuardianBase;
32 class RenderState;
33 class SceneSetup;
34 class TransformState;
35
36 /**
37 * This stores the result of a BinCullHandler traversal: an ordered collection
38 * of CullBins, each of which holds a number of Geoms and RenderStates to be
39 * rendered in some defined order.
40 *
41 * This is also used to keep the results of last frame's cull traversal around
42 * to make next frame's traversal of the same scene a little easier.
43 */
44 class EXPCL_PANDA_PGRAPH CullResult : public ReferenceCount {
45 public:
46 CullResult(GraphicsStateGuardianBase *gsg,
47 const PStatCollector &draw_region_pcollector);
48 INLINE ~CullResult();
49
50 PUBLISHED:
51 PT(CullResult) make_next() const;
52
53 INLINE CullBin *get_bin(int bin_index);
54
55 void add_object(CullableObject *object, const CullTraverser *traverser);
56 void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
57 void draw(Thread *current_thread);
58
59 PT(PandaNode) make_result_graph();
60
61 public:
62 static void bin_removed(int bin_index);
63
64 private:
65 CullBin *make_new_bin(int bin_index);
66
67 INLINE void check_flash_bin(CPT(RenderState) &state, CullBinManager *bin_manager, int bin_index);
68 INLINE void check_flash_transparency(CPT(RenderState) &state, const LColor &color);
69
70 #ifndef NDEBUG
71 void apply_flash_color(CPT(RenderState) &state, const LColor &flash_color);
72 #endif
73
74 static const RenderState *get_rescale_normal_state(RescaleNormalAttrib::Mode mode);
75 static const RenderState *get_alpha_state();
76 static const RenderState *get_binary_state();
77 static const RenderState *get_dual_transparent_state();
78 static const RenderState *get_dual_opaque_state();
79 static const RenderState *get_wireframe_filled_state();
80 static CPT(RenderState) get_wireframe_overlay_state(const RenderModeAttrib *rmode);
81 static CPT(RenderState) get_wireframe_overlay_state(const RenderModeAttrib *rmode, const ShaderAttrib *shader);
82
83 GraphicsStateGuardianBase *_gsg;
84 PStatCollector _draw_region_pcollector;
85
86 typedef pvector< PT(CullBin) > Bins;
87 Bins _bins;
88
89 bool _show_transparency = false;
90
91 public:
92 static TypeHandle get_class_type() {
93 return _type_handle;
94 }
95 static void init_type() {
96 ReferenceCount::init_type();
97 register_type(_type_handle, "CullResult",
98 ReferenceCount::get_class_type());
99 }
100
101 private:
102 static TypeHandle _type_handle;
103 };
104
105 #include "cullResult.I"
106
107 #endif
CullBinManager
This is a global object that maintains the collection of named CullBins in the world.
Definition: cullBinManager.h:34
CullBin
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:40
CullResult
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
Definition: cullResult.h:44
CullTraverser
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition: cullTraverser.h:45
CullableObject
The smallest atom of cull.
Definition: cullableObject.h:41
GraphicsStateGuardianBase
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Definition: graphicsStateGuardianBase.h:110
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition: pStatCollector.h:43
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:65
ReferenceCount
A base class for all things that want to be reference-counted.
Definition: referenceCount.h:38
RenderModeAttrib
Specifies how polygons are to be drawn.
Definition: renderModeAttrib.h:27
RenderState
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
SceneSetup
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:32
ShaderAttrib
Definition: shaderAttrib.h:39
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
TransformState
Indicates a coordinate-system transform on vertices.
Definition: transformState.h:54
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
pvector
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
cullBinManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cullBin.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cullResult.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
cullableObject.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomMunger.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
referenceCount.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
renderState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
rescaleNormalAttrib.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.