Panda3D
 All Classes Functions Variables Enumerations
cullBinStateSorted.h
1 // Filename: cullBinStateSorted.h
2 // Created by: drose (22Mar05)
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 CULLBINSTATESORTED_H
16 #define CULLBINSTATESORTED_H
17 
18 #include "pandabase.h"
19 
20 #include "cullBin.h"
21 #include "cullableObject.h"
22 #include "geom.h"
23 #include "transformState.h"
24 #include "renderState.h"
25 #include "pointerTo.h"
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : CullBinStateSorted
29 // Description : A specific kind of CullBin that sorts geometry to
30 // collect items of the same state together, so that
31 // minimal state changes are required on the GSG to
32 // render them.
33 //
34 // This also sorts objects front-to-back within a
35 // particular state, to take advantage of hierarchical
36 // Z-buffer algorithms which can early-out when an
37 // object appears behind another one.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_CULL CullBinStateSorted : public CullBin {
40 public:
41  INLINE CullBinStateSorted(const string &name,
43  const PStatCollector &draw_region_pcollector);
44  virtual ~CullBinStateSorted();
45 
46  static CullBin *make_bin(const string &name,
48  const PStatCollector &draw_region_pcollector);
49 
50  virtual void add_object(CullableObject *object, Thread *current_thread);
51  virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
52  virtual void draw(bool force, Thread *current_thread);
53 
54 protected:
55  virtual void fill_result_graph(ResultGraphBuilder &builder);
56 
57 private:
58  class ObjectData {
59  public:
60  INLINE ObjectData(CullableObject *object);
61  INLINE bool operator < (const ObjectData &other) const;
62 
63  CullableObject *_object;
64  };
65 
67  Objects _objects;
68 
69 public:
70  static TypeHandle get_class_type() {
71  return _type_handle;
72  }
73  static void init_type() {
74  CullBin::init_type();
75  register_type(_type_handle, "CullBinStateSorted",
76  CullBin::get_class_type());
77  }
78  virtual TypeHandle get_type() const {
79  return get_class_type();
80  }
81  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82 
83 private:
84  static TypeHandle _type_handle;
85 };
86 
87 #include "cullBinStateSorted.I"
88 
89 #endif
90 
91 
92 
A specific kind of CullBin that sorts geometry to collect items of the same state together...
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:44
A lightweight class that represents a single element that may be timed and/or counted via stats...
The smallest atom of cull.
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