Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/cullBinManager.h

Go to the documentation of this file.
00001 // Filename: cullBinManager.h
00002 // Created by:  drose (27Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
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 //       Class : CullBinManager
00034 // Description : This is a global object that maintains the collection
00035 //               of named CullBins in the world.
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   // This interface is only intended to be used by CullResult.
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

Generated on Fri May 2 00:41:26 2003 for Panda by doxygen1.3