Panda3D
cullBinStateSorted.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 cullBinStateSorted.h
10  * @author drose
11  * @date 2005-03-22
12  */
13 
14 #ifndef CULLBINSTATESORTED_H
15 #define CULLBINSTATESORTED_H
16 
17 #include "pandabase.h"
18 
19 #include "cullBin.h"
20 #include "cullableObject.h"
21 #include "geom.h"
22 #include "transformState.h"
23 #include "renderState.h"
24 #include "pointerTo.h"
25 
26 /**
27  * A specific kind of CullBin that sorts geometry to collect items of the same
28  * state together, so that minimal state changes are required on the GSG to
29  * render them.
30  *
31  * This also sorts objects front-to-back within a particular state, to take
32  * advantage of hierarchical Z-buffer algorithms which can early-out when an
33  * object appears behind another one.
34  */
35 class EXPCL_PANDA_CULL CullBinStateSorted : public CullBin {
36 public:
37  INLINE CullBinStateSorted(const std::string &name,
39  const PStatCollector &draw_region_pcollector);
40  virtual ~CullBinStateSorted();
41 
42  static CullBin *make_bin(const std::string &name,
44  const PStatCollector &draw_region_pcollector);
45 
46  virtual void add_object(CullableObject *object, Thread *current_thread);
47  virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
48  virtual void draw(bool force, Thread *current_thread);
49 
50 protected:
51  virtual void fill_result_graph(ResultGraphBuilder &builder);
52 
53 private:
54  class ObjectData {
55  public:
56  INLINE ObjectData(CullableObject *object);
57  INLINE bool operator < (const ObjectData &other) const;
58 
59  CullableObject *_object;
60  const GeomVertexFormat *_format;
61  };
62 
64  Objects _objects;
65 
66 public:
67  static TypeHandle get_class_type() {
68  return _type_handle;
69  }
70  static void init_type() {
71  CullBin::init_type();
72  register_type(_type_handle, "CullBinStateSorted",
73  CullBin::get_class_type());
74  }
75  virtual TypeHandle get_type() const {
76  return get_class_type();
77  }
78  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
79 
80 private:
81  static TypeHandle _type_handle;
82 };
83 
84 #include "cullBinStateSorted.I"
85 
86 #endif
A specific kind of CullBin that sorts geometry to collect items of the same state together,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:40
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.
A lightweight class that represents a single element that may be timed and/or counted via stats.
The smallest atom of cull.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class defines the physical layout of the vertex data stored within a Geom.
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
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