Blender  V2.59
RAS_BucketManager.h
Go to the documentation of this file.
00001 /*
00002  * $Id: RAS_BucketManager.h 36523 2011-05-06 20:18:42Z blendix $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #ifndef __RAS_BUCKETMANAGER
00035 #define __RAS_BUCKETMANAGER
00036 
00037 #include "MT_Transform.h"
00038 #include "RAS_MaterialBucket.h"
00039 #include "CTR_Map.h"
00040 
00041 #include <vector>
00042 
00043 class RAS_BucketManager
00044 {
00045         typedef std::vector<class RAS_MaterialBucket*> BucketList;
00046         BucketList m_SolidBuckets;
00047         BucketList m_AlphaBuckets;
00048         
00049         struct sortedmeshslot;
00050         struct backtofront;
00051         struct fronttoback;
00052 
00053 public:
00054         RAS_BucketManager();
00055         virtual ~RAS_BucketManager();
00056 
00057         void Renderbuckets(const MT_Transform & cameratrans,
00058                 RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
00059 
00060         RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated);
00061         void OptimizeBuckets(MT_Scalar distance);
00062         
00063         void ReleaseDisplayLists(RAS_IPolyMaterial * material = NULL);
00064         void ReleaseMaterials(RAS_IPolyMaterial * material = NULL);
00065 
00066         void RemoveMaterial(RAS_IPolyMaterial * mat); // freeing scenes only
00067 
00068         /* for merging */
00069         void MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene);
00070         BucketList & GetSolidBuckets() {return m_SolidBuckets;};
00071         BucketList & GetAlphaBuckets() {return m_AlphaBuckets;};
00072 
00073         /*void PrintStats(int verbose_level) {
00074                 printf("\nMappings...\n");
00075                 printf("\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
00076                 printf("\t\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
00077                 printf("\t m_AlphaBuckets: %d\n", m_AlphaBuckets.size());
00078         }*/
00079 
00080 
00081 private:
00082         void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
00083 
00084         void RenderSolidBuckets(const MT_Transform& cameratrans, 
00085                 RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
00086         void RenderAlphaBuckets(const MT_Transform& cameratrans, 
00087                 RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
00088 
00089 #ifdef WITH_CXX_GUARDEDALLOC
00090 public:
00091         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_BucketManager"); }
00092         void operator delete( void *mem ) { MEM_freeN(mem); }
00093 #endif
00094 };
00095 
00096 #endif //__RAS_BUCKETMANAGER
00097