Panda3D
 All Classes Functions Variables Enumerations
cullBin.h
1 // Filename: cullBin.h
2 // Created by: drose (27Feb02)
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 CULLBIN_H
16 #define CULLBIN_H
17 
18 #include "pandabase.h"
19 #include "cullBinEnums.h"
20 #include "typedReferenceCount.h"
21 #include "pStatCollector.h"
22 #include "pointerTo.h"
23 #include "luse.h"
24 
25 class CullableObject;
27 class SceneSetup;
28 class TransformState;
29 class RenderState;
30 class PandaNode;
31 class GeomNode;
32 
33 ////////////////////////////////////////////////////////////////////
34 // Class : CullBin
35 // Description : A collection of Geoms and their associated state, for
36 // a particular scene. The cull traversal (and the
37 // BinCullHandler) assigns Geoms to bins as it comes
38 // across them.
39 //
40 // This is an abstract base class; derived classes like
41 // CullBinStateSorted and CullBinBackToFront provide the
42 // actual implementation.
43 ////////////////////////////////////////////////////////////////////
44 class EXPCL_PANDA_PGRAPH CullBin : public TypedReferenceCount, public CullBinEnums {
45 protected:
46  INLINE CullBin(const CullBin &copy);
47 public:
48  INLINE CullBin(const string &name, BinType bin_type,
50  const PStatCollector &draw_region_pcollector);
51  virtual ~CullBin();
52 
53  INLINE const string &get_name() const;
54  INLINE BinType get_bin_type() const;
55 
56  virtual PT(CullBin) make_next() const;
57 
58  virtual void add_object(CullableObject *object, Thread *current_thread)=0;
59  virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
60 
61  virtual void draw(bool force, Thread *current_thread)=0;
62 
63  PT(PandaNode) make_result_graph();
64 
65  INLINE bool has_flash_color() const;
66  INLINE const LColor &get_flash_color() const;
67 
68 protected:
69  class ResultGraphBuilder;
70  virtual void fill_result_graph(ResultGraphBuilder &builder)=0;
71 
72 private:
73  void check_flash_color();
74 
75 protected:
76  string _name;
77  BinType _bin_type;
79 
80  // Used in make_result_graph() and fill_result_graph().
81  class ResultGraphBuilder {
82  public:
83  ResultGraphBuilder(PandaNode *root_node);
84  void add_object(CullableObject *object);
85 
86  private:
87  void record_one_object(GeomNode *node, CullableObject *object);
88 
89  private:
90  int _object_index;
91  CPT(TransformState) _current_transform;
92  CPT(RenderState) _current_state;
93  PT(PandaNode) _root_node;
94  PT(GeomNode) _current_node;
95  };
96 
97  static PStatCollector _cull_bin_pcollector;
98  PStatCollector _cull_this_pcollector;
99  PStatCollector _draw_this_pcollector;
100 
101 public:
102  static TypeHandle get_class_type() {
103  return _type_handle;
104  }
105  static void init_type() {
106  TypedReferenceCount::init_type();
107  register_type(_type_handle, "CullBin",
108  TypedReferenceCount::get_class_type());
109  }
110  virtual TypeHandle get_type() const {
111  return get_class_type();
112  }
113  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
114 
115 private:
116  static TypeHandle _type_handle;
117 };
118 
119 #include "cullBin.I"
120 
121 #endif
122 
123 
124 
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:44
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
Provides scoping for the enumerated type shared by CullBin and CullBinManager.
Definition: cullBinEnums.h:25
A lightweight class that represents a single element that may be timed and/or counted via stats...
The smallest atom of cull.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:53
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
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
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
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37