Panda3D
cullBin.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 cullBin.h
10  * @author drose
11  * @date 2002-02-27
12  */
13 
14 #ifndef CULLBIN_H
15 #define CULLBIN_H
16 
17 #include "pandabase.h"
18 #include "cullBinEnums.h"
19 #include "typedReferenceCount.h"
20 #include "pStatCollector.h"
21 #include "pointerTo.h"
22 #include "luse.h"
23 #include "geomNode.h"
24 
25 class CullableObject;
27 class SceneSetup;
28 class TransformState;
29 class RenderState;
30 class PandaNode;
31 
32 /**
33  * A collection of Geoms and their associated state, for a particular scene.
34  * The cull traversal (and the BinCullHandler) assigns Geoms to bins as it
35  * comes across them.
36  *
37  * This is an abstract base class; derived classes like CullBinStateSorted and
38  * CullBinBackToFront provide the actual implementation.
39  */
40 class EXPCL_PANDA_PGRAPH CullBin : public TypedReferenceCount, public CullBinEnums {
41 protected:
42  INLINE CullBin(const CullBin &copy);
43 public:
44  INLINE CullBin(const std::string &name, BinType bin_type,
46  const PStatCollector &draw_region_pcollector);
47  virtual ~CullBin();
48 
49  INLINE const std::string &get_name() const;
50  INLINE BinType get_bin_type() const;
51 
52  virtual PT(CullBin) make_next() const;
53 
54  virtual void add_object(CullableObject *object, Thread *current_thread)=0;
55  virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread);
56 
57  virtual void draw(bool force, Thread *current_thread)=0;
58 
59  PT(PandaNode) make_result_graph();
60 
61  INLINE bool has_flash_color() const;
62  INLINE const LColor &get_flash_color() const;
63 
64 protected:
65  class ResultGraphBuilder;
66  virtual void fill_result_graph(ResultGraphBuilder &builder)=0;
67 
68 private:
69  void check_flash_color();
70 
71 protected:
72  std::string _name;
73  BinType _bin_type;
75 
76  // Used in make_result_graph() and fill_result_graph().
77  class EXPCL_PANDA_PGRAPH ResultGraphBuilder {
78  public:
79  ResultGraphBuilder(PandaNode *root_node);
80  void add_object(CullableObject *object);
81 
82  private:
83  void record_one_object(GeomNode *node, CullableObject *object);
84 
85  private:
86  int _object_index;
87  CPT(TransformState) _current_transform;
88  CPT(RenderState) _current_state;
89  PT(PandaNode) _root_node;
90  PT(GeomNode) _current_node;
91  };
92 
93  static PStatCollector _cull_bin_pcollector;
94  PStatCollector _cull_this_pcollector;
95  PStatCollector _draw_this_pcollector;
96 
97 public:
98  static TypeHandle get_class_type() {
99  return _type_handle;
100  }
101  static void init_type() {
102  TypedReferenceCount::init_type();
103  register_type(_type_handle, "CullBin",
104  TypedReferenceCount::get_class_type());
105  }
106  virtual TypeHandle get_type() const {
107  return get_class_type();
108  }
109  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
110 
111 private:
112  static TypeHandle _type_handle;
113 };
114 
115 #include "cullBin.I"
116 
117 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
Indicates a coordinate-system transform on vertices.
A collection of Geoms and their associated state, for a particular scene.
Definition: cullBin.h:40
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
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:23
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:34