00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CULLBINMANAGER_H
00020 #define CULLBINMANAGER_H
00021
00022 #include "pandabase.h"
00023 #include "cullBin.h"
00024 #include "pointerTo.h"
00025 #include "pvector.h"
00026 #include "pmap.h"
00027 #include "vector_int.h"
00028
00029 class CullResult;
00030 class GraphicsStateGuardianBase;
00031
00032
00033
00034
00035
00036
00037 class EXPCL_PANDA CullBinManager {
00038 protected:
00039 CullBinManager();
00040 ~CullBinManager();
00041
00042 PUBLISHED:
00043 enum BinType {
00044 BT_invalid,
00045 BT_unsorted,
00046 BT_state_sorted,
00047 BT_back_to_front,
00048 BT_front_to_back,
00049 BT_fixed,
00050 };
00051
00052 int add_bin(const string &name, BinType type, int sort);
00053 void remove_bin(int bin_index);
00054
00055 INLINE int get_num_bins() const;
00056 INLINE int get_bin(int n) const;
00057 int find_bin(const string &name) const;
00058
00059 INLINE string get_bin_name(int bin_index) const;
00060 INLINE BinType get_bin_type(int bin_index) const;
00061
00062 INLINE int get_bin_sort(int bin_index) const;
00063 INLINE void set_bin_sort(int bin_index, int sort);
00064
00065 static CullBinManager *get_global_ptr();
00066
00067 public:
00068
00069 PT(CullBin) make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg);
00070
00071 private:
00072 void do_sort_bins();
00073 void setup_initial_bins();
00074 static BinType parse_bin_type(const string &bin_type);
00075
00076 class EXPCL_PANDA BinDefinition {
00077 public:
00078 bool _in_use;
00079 string _name;
00080 BinType _type;
00081 int _sort;
00082 };
00083 typedef pvector<BinDefinition> BinDefinitions;
00084 BinDefinitions _bin_definitions;
00085
00086 class SortBins {
00087 public:
00088 INLINE SortBins(CullBinManager *manager);
00089 INLINE bool operator () (int a, int b) const;
00090 CullBinManager *_manager;
00091 };
00092
00093 typedef pmap<string, int> BinsByName;
00094 BinsByName _bins_by_name;
00095
00096 typedef vector_int SortedBins;
00097 SortedBins _sorted_bins;
00098 bool _bins_are_sorted;
00099 bool _unused_bin_index;
00100
00101 static CullBinManager *_global_ptr;
00102 friend class SortBins;
00103 };
00104
00105 #include "cullBinManager.I"
00106
00107 #endif