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;
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:
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 
83  PStatCollector _draw_region_pcollector;
84 
85  typedef pvector< PT(CullBin) > Bins;
86  Bins _bins;
87 
88 #ifndef NDEBUG
89  bool _show_transparency;
90 #endif
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  ReferenceCount::init_type();
98  register_type(_type_handle, "CullResult",
99  ReferenceCount::get_class_type());
100  }
101 
102 private:
103  static TypeHandle _type_handle;
104 };
105 
106 #include "cullResult.I"
107 
108 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Indicates a coordinate-system transform on vertices.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:40
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(),...
Definition: register_type.I:22
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.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight class that represents a single element that may be timed and/or counted via stats.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The smallest atom of cull.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
Definition: cullResult.h:44
A base class for all things that want to be reference-counted.
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:46
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Specifies how polygons are to be drawn.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:32
This is a global object that maintains the collection of named CullBins in the world.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition: cullTraverser.h:45