Panda3D
Loading...
Searching...
No Matches
cullBinManager.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 cullBinManager.h
10 * @author drose
11 * @date 2002-02-27
12 */
13
14#ifndef CULLBINMANAGER_H
15#define CULLBINMANAGER_H
16
17#include "pandabase.h"
18#include "cullBin.h"
19#include "cullBinEnums.h"
20#include "pointerTo.h"
21#include "pvector.h"
22#include "epvector.h"
23#include "pmap.h"
24#include "vector_int.h"
25#include "pStatCollector.h"
26
27class CullResult;
29
30/**
31 * This is a global object that maintains the collection of named CullBins in
32 * the world.
33 */
34class EXPCL_PANDA_PGRAPH CullBinManager : public CullBinEnums {
35protected:
38
39PUBLISHED:
40 typedef CullBin::BinType BinType;
41
42 int add_bin(const std::string &name, BinType type, int sort);
43 void remove_bin(int bin_index);
44
45 INLINE int get_num_bins() const;
46 INLINE int get_bin(int n) const;
47 MAKE_SEQ(get_bins, get_num_bins, get_bin);
48 int find_bin(const std::string &name) const;
49
50 INLINE std::string get_bin_name(int bin_index) const;
51
52 INLINE BinType get_bin_type(int bin_index) const;
53 INLINE BinType get_bin_type(const std::string &name) const;
54 INLINE void set_bin_type(int bin_index, BinType type);
55 INLINE void set_bin_type(const std::string &name, BinType type);
56
57 INLINE int get_bin_sort(int bin_index) const;
58 INLINE int get_bin_sort(const std::string &name) const;
59 INLINE void set_bin_sort(int bin_index, int sort);
60 INLINE void set_bin_sort(const std::string &name, int sort);
61
62 INLINE bool get_bin_active(int bin_index) const;
63 INLINE bool get_bin_active(const std::string &name) const;
64 INLINE void set_bin_active(int bin_index, bool active);
65 INLINE void set_bin_active(const std::string &name, bool active);
66
67#ifndef NDEBUG
68 INLINE bool get_bin_flash_active(int bin_index) const;
69 INLINE const LColor &get_bin_flash_color(int bin_index) const;
70 INLINE void set_bin_flash_active(int bin_index, bool active);
71 INLINE void set_bin_flash_color(int bin_index, const LColor &color);
72#endif
73
74 void write(std::ostream &out) const;
75
76 INLINE static CullBinManager *get_global_ptr();
77
78public:
79 // This interface is only intended to be used by CullResult.
80 PT(CullBin) make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg,
81 const PStatCollector &draw_region_pcollector);
82
83 // This defines the factory interface for defining constructors to bin types
84 // (the implementations are in the cull directory, not here in pgraph, so we
85 // can't call the constructors directly).
86 typedef CullBin *BinConstructor(const std::string &name,
88 const PStatCollector &draw_region_pcollector);
89
90 void register_bin_type(BinType type, BinConstructor *constructor);
91
92private:
93 void do_sort_bins();
94 void setup_initial_bins();
95 static BinType parse_bin_type(const std::string &bin_type);
96
97 class EXPCL_PANDA_PGRAPH BinDefinition {
98 public:
99#ifndef NDEBUG
100 LColor _flash_color;
101 bool _flash_active;
102#endif
103 bool _in_use;
104 std::string _name;
105 BinType _type;
106 int _sort;
107 bool _active;
108 };
109 typedef epvector<BinDefinition> BinDefinitions;
110 BinDefinitions _bin_definitions;
111
112 class SortBins {
113 public:
114 INLINE SortBins(CullBinManager *manager);
115 INLINE bool operator () (int a, int b) const;
116 CullBinManager *_manager;
117 };
118
119 typedef pmap<std::string, int> BinsByName;
120 BinsByName _bins_by_name;
121
122 typedef vector_int SortedBins;
123 SortedBins _sorted_bins;
124 bool _bins_are_sorted;
125 bool _unused_bin_index;
126
127 typedef pmap<BinType, BinConstructor *> BinConstructors;
128 BinConstructors _bin_constructors;
129
130 static CullBinManager *_global_ptr;
131 friend class SortBins;
132};
133
134EXPCL_PANDA_PGRAPH std::ostream &
135operator << (std::ostream &out, CullBinManager::BinType bin_type);
136
137#include "cullBinManager.I"
138
139#endif
Provides scoping for the enumerated type shared by CullBin and CullBinManager.
This is a global object that maintains the collection of named CullBins in the world.
A collection of Geoms and their associated state, for a particular scene.
Definition cullBin.h:40
This stores the result of a BinCullHandler traversal: an ordered collection of CullBins,...
Definition cullResult.h:44
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A lightweight class that represents a single element that may be timed and/or counted via stats.
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.