Panda3D
cullBinBackToFront.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 cullBinBackToFront.h
10  * @author drose
11  * @date 2002-02-28
12  */
13 
14 #ifndef CULLBINBACKTOFRONT_H
15 #define CULLBINBACKTOFRONT_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 furthest to
27  * nearest based on the center of its bounding volume. This is primarily
28  * intended for rendering transparent and semi-transparent geometry that must
29  * be sorted from back to front.
30  */
31 class EXPCL_PANDA_CULL CullBinBackToFront : public CullBin {
32 public:
33  INLINE CullBinBackToFront(const std::string &name,
35  const PStatCollector &draw_region_pcollector);
36  virtual ~CullBinBackToFront();
37 
38  static CullBin *make_bin(const std::string &name,
40  const PStatCollector &draw_region_pcollector);
41 
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, "CullBinBackToFront",
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 "cullBinBackToFront.I"
82 
83 #endif
cullBinBackToFront.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector< ObjectData >
CullableObject
The smallest atom of cull.
Definition: cullableObject.h:41
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
renderState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
SceneSetup
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:32
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
transformState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PStatCollector
A lightweight class that represents a single element that may be timed and/or counted via stats.
Definition: pStatCollector.h:43
geom.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CullBin
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:40
cullBin.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
CullBinBackToFront
A specific kind of CullBin that sorts geometry in order from furthest to nearest based on the center ...
Definition: cullBinBackToFront.h:31
GraphicsStateGuardianBase
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Definition: graphicsStateGuardianBase.h:110
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.