"Fossies" - the Fresh Open Source Software Archive

Member "aqsis-1.8.2/libs/core/bucket.cpp" (24 Aug 2012, 3117 Bytes) of package /linux/privat/aqsis-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // Aqsis
    2 // Copyright (C) 1997 - 2001, Paul C. Gregory
    3 //
    4 // Contact: pgregory@aqsis.org
    5 //
    6 // This library is free software; you can redistribute it and/or
    7 // modify it under the terms of the GNU General Public
    8 // License as published by the Free Software Foundation; either
    9 // version 2 of the License, or (at your option) any later version.
   10 //
   11 // This library is distributed in the hope that it will be useful,
   12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14 // General Public License for more details.
   15 //
   16 // You should have received a copy of the GNU General Public
   17 // License along with this library; if not, write to the Free Software
   18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   19 
   20 
   21 /** \file
   22         \brief Implements the CqBucket class responsible for bookkeeping the primitives and storing the results.
   23         \author Paul C. Gregory (pgregory@aqsis.org)
   24 */
   25 
   26 
   27 #include    <aqsis/aqsis.h>
   28 
   29 #ifdef WIN32
   30 #include    <windows.h>
   31 #endif
   32 #include    <cstring>
   33 #include    <algorithm>
   34 #include    <valarray>
   35 
   36 #include    <aqsis/math/math.h>
   37 #include    "surface.h"
   38 #include    "imagepixel.h"
   39 #include    "occlusion.h"
   40 #include    "renderer.h"
   41 #include    "micropolygon.h"
   42 #include    "imagebuffer.h"
   43 
   44 #include    "bucket.h"
   45 #include    "stats.h"
   46 
   47 #include    <algorithm>
   48 #include    <valarray>
   49 #include    <cmath>
   50 
   51 
   52 namespace Aqsis {
   53 
   54 
   55 //----------------------------------------------------------------------
   56 CqBucket::CqBucket()
   57     : m_bProcessed(false),
   58     m_col(0),
   59     m_row(0),
   60     m_xPosition(0),
   61     m_yPosition(0),
   62     m_xSize(0),
   63     m_ySize(0),
   64     m_micropolygons(),
   65     m_gPrims()
   66 { }
   67 
   68 //----------------------------------------------------------------------
   69 TqInt CqBucket::getCol() const
   70 {
   71     return m_col;
   72 }
   73 
   74 //----------------------------------------------------------------------
   75 void CqBucket::setCol(TqInt value)
   76 {
   77     m_col = value;
   78 }
   79 
   80 //----------------------------------------------------------------------
   81 TqInt CqBucket::getRow() const
   82 {
   83     return m_row;
   84 }
   85 
   86 //----------------------------------------------------------------------
   87 void CqBucket::setRow(TqInt value)
   88 {
   89     m_row = value;
   90 }
   91 
   92 //----------------------------------------------------------------------
   93 /** Mark this bucket as processed
   94  */
   95 void CqBucket::SetProcessed( bool bProc )
   96 {
   97     assert( !bProc || (bProc && !hasPendingSurfaces()) );
   98     m_bProcessed = bProc;
   99     if(bProc)
  100     {
  101         // Deallocate memory held implicitly in std containers.  Apart from
  102         // anything else, this seems to help avoid persistent small pieces of
  103         // memory which fragment the heap.
  104         TqPolyStorage().swap(m_micropolygons);
  105         TqSurfaceQueue().swap(m_gPrims);
  106     }
  107 }
  108 
  109 //----------------------------------------------------------------------
  110 /** Check if there are any surfaces in this bucket to be processed.
  111  */
  112 bool CqBucket::hasPendingSurfaces() const
  113 {
  114     return ! m_gPrims.empty();
  115 }
  116 
  117 
  118 //----------------------------------------------------------------------
  119 /** Add an MP to the list of deferred MPs.
  120  */
  121 void CqBucket::AddMP( boost::shared_ptr<CqMicroPolygon>& pMP )
  122 {
  123     m_micropolygons.push_back( pMP );
  124 }
  125 
  126 
  127 } // namespace Aqsis
  128 
  129