Panda3D
cullBinFrontToBack.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 cullBinFrontToBack.h
10  * @author drose
11  * @date 2002-05-29
12  */
13 
14 #ifndef CULLBINFRONTTOBACK_H
15 #define CULLBINFRONTTOBACK_H
16 
17 #include "pandabase.h"
18 
19 #include "cullBin.h"
20 #include "geom.h"
21 #include "transformState.h"
22 #include "renderState.h"
23 #include "pointerTo.h"
24 
25 /**
26  * A specific kind of CullBin that sorts geometry in order from nearest to
27  * furthest based on the center of its bounding volume.
28  *
29  * This is useful for rendering opaque geometry, taking optimal advantage of a
30  * hierarchical Z-buffer.
31  */
32 class EXPCL_PANDA_CULL CullBinFrontToBack : public CullBin {
33 public:
34  INLINE CullBinFrontToBack(const std::string &name,
36  const PStatCollector &draw_region_pcollector);
37  virtual ~CullBinFrontToBack();
38 
39  static CullBin *make_bin(const std::string &name,
41  const PStatCollector &draw_region_pcollector);
42 
43  virtual void add_object(CullableObject *object, Thread *current_thread);
44  virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
45  virtual void draw(bool force, Thread *current_thread);
46 
47 protected:
48  virtual void fill_result_graph(ResultGraphBuilder &builder);
49 
50 private:
51  class ObjectData {
52  public:
53  INLINE ObjectData(CullableObject *object, PN_stdfloat dist);
54  INLINE bool operator < (const ObjectData &other) const;
55 
56  CullableObject *_object;
57  PN_stdfloat _dist;
58  };
59 
61  Objects _objects;
62 
63 public:
64  static TypeHandle get_class_type() {
65  return _type_handle;
66  }
67  static void init_type() {
68  CullBin::init_type();
69  register_type(_type_handle, "CullBinFrontToBack",
70  CullBin::get_class_type());
71  }
72  virtual TypeHandle get_type() const {
73  return get_class_type();
74  }
75  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
76 
77 private:
78  static TypeHandle _type_handle;
79 };
80 
81 #include "cullBinFrontToBack.I"
82 
83 #endif
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.
A specific kind of CullBin that sorts geometry in order from nearest to furthest based on the center ...
The smallest atom of cull.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.