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

panda/src/pgraph/cullBinManager.I

Go to the documentation of this file.
00001 // Filename: cullBinManager.I
00002 // Created by:  drose (28Feb02)
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 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: CullBinManager::SortBins::Constructor
00022 //       Access: Public
00023 //  Description: This is a function object whose sole purpose is to
00024 //               put the _sorted_bins vector in the proper order for
00025 //               rendering the bins.
00026 ////////////////////////////////////////////////////////////////////
00027 INLINE CullBinManager::SortBins::
00028 SortBins(CullBinManager *manager) :
00029   _manager(manager)
00030 {
00031 }
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //     Function: CullBinManager::SortBins::operator ()
00035 //       Access: Public
00036 //  Description: The function call method of the function object.
00037 //               Returns true if the two bin indices are already in
00038 //               sorted order with a < b, or false otherwise.
00039 ////////////////////////////////////////////////////////////////////
00040 INLINE bool CullBinManager::SortBins::
00041 operator () (int a, int b) const {
00042   return _manager->_bin_definitions[a]._sort < _manager->_bin_definitions[b]._sort;
00043 }
00044 
00045 
00046 
00047 ////////////////////////////////////////////////////////////////////
00048 //     Function: CullBinManager::get_num_bins
00049 //       Access: Published
00050 //  Description: Returns the number of bins in the world.
00051 ////////////////////////////////////////////////////////////////////
00052 INLINE int CullBinManager::
00053 get_num_bins() const {
00054   // We quietly sort the bins in order if they are not already sorted.
00055   // This is a non-const operation, but we pretend it's const because
00056   // it's intended to be a transparent update.
00057   if (!_bins_are_sorted) {
00058     ((CullBinManager *)this)->do_sort_bins();
00059   }
00060   return _sorted_bins.size();
00061 }
00062 
00063 ////////////////////////////////////////////////////////////////////
00064 //     Function: CullBinManager::get_bin
00065 //       Access: Published
00066 //  Description: Returns the bin_index of the nth bin in the set,
00067 //               where n is a number between 0 and get_num_bins().
00068 //               This returns the list of bin_index numbers, in sorted
00069 //               order (that is, in the order in which the bins should
00070 //               be rendered).
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE int CullBinManager::
00073 get_bin(int n) const {
00074   nassertr(n >= 0 && n < (int)_sorted_bins.size(), -1);
00075   return _sorted_bins[n];
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //     Function: CullBinManager::get_bin_name
00080 //       Access: Published
00081 //  Description: Returns the name of the bin with the indicated
00082 //               bin_index (where bin_index was retrieved by get_bin()
00083 
00084 //               or find_bin()).  The bin's name may not be changed
00085 //               during the life of the bin.
00086 ////////////////////////////////////////////////////////////////////
00087 INLINE string CullBinManager::
00088 get_bin_name(int bin_index) const {
00089   nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), string());
00090   nassertr(_bin_definitions[bin_index]._in_use, string());
00091   return _bin_definitions[bin_index]._name;
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: CullBinManager::get_bin_type
00096 //       Access: Published
00097 //  Description: Returns the type of the bin with the indicated
00098 //               bin_index (where bin_index was retrieved by get_bin()
00099 //               or find_bin()).  The bin's type may not be changed
00100 //               during the life of the bin.
00101 ////////////////////////////////////////////////////////////////////
00102 INLINE CullBinManager::BinType CullBinManager::
00103 get_bin_type(int bin_index) const {
00104   nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), BT_invalid);
00105   nassertr(_bin_definitions[bin_index]._in_use, BT_invalid);
00106   return _bin_definitions[bin_index]._type;
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: CullBinManager::get_bin_sort
00111 //       Access: Published
00112 //  Description: Returns the sort order of the bin with the indicated
00113 //               bin_index (where bin_index was retrieved by get_bin()
00114 //               or find_bin()).
00115 //
00116 //               The bins are rendered in increasing order by their
00117 //               sort order; this number may be changed from time to
00118 //               time to reorder the bins.
00119 ////////////////////////////////////////////////////////////////////
00120 INLINE int CullBinManager::
00121 get_bin_sort(int bin_index) const {
00122   nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), 0);
00123   nassertr(_bin_definitions[bin_index]._in_use, 0);
00124   return _bin_definitions[bin_index]._sort;
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: CullBinManager::set_bin_sort
00129 //       Access: Published
00130 //  Description: Changes the sort order of the bin with the indicated
00131 //               bin_index (where bin_index was retrieved by get_bin()
00132 //               or find_bin()).
00133 //
00134 //               The bins are rendered in increasing order by their
00135 //               sort order; this number may be changed from time to
00136 //               time to reorder the bins.
00137 ////////////////////////////////////////////////////////////////////
00138 INLINE void CullBinManager::
00139 set_bin_sort(int bin_index, int sort) {
00140   nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size());
00141   nassertv(_bin_definitions[bin_index]._in_use);
00142   _bin_definitions[bin_index]._sort = sort;
00143   _bins_are_sorted = false;
00144 }

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