Blender V2.61 - r43446

RAS_BucketManager.h

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