optionally use guarded alloc for tiles compositor, also replace allocation functions...
[blender.git] / source / gameengine / Rasterizer / RAS_BucketManager.h
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file RAS_BucketManager.h
29  *  \ingroup bgerast
30  */
31
32 #ifndef __RAS_BUCKETMANAGER_H__
33 #define __RAS_BUCKETMANAGER_H__
34
35 #include "MT_Transform.h"
36 #include "RAS_MaterialBucket.h"
37 #include "CTR_Map.h"
38
39 #include <vector>
40
41 class RAS_BucketManager
42 {
43         typedef std::vector<class RAS_MaterialBucket*> BucketList;
44         BucketList m_SolidBuckets;
45         BucketList m_AlphaBuckets;
46         
47         struct sortedmeshslot;
48         struct backtofront;
49         struct fronttoback;
50
51 public:
52         RAS_BucketManager();
53         virtual ~RAS_BucketManager();
54
55         void Renderbuckets(const MT_Transform & cameratrans,
56                 RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
57
58         RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated);
59         void OptimizeBuckets(MT_Scalar distance);
60         
61         void ReleaseDisplayLists(RAS_IPolyMaterial * material = NULL);
62         void ReleaseMaterials(RAS_IPolyMaterial * material = NULL);
63
64         void RemoveMaterial(RAS_IPolyMaterial * mat); // freeing scenes only
65
66         /* for merging */
67         void MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene);
68         BucketList & GetSolidBuckets() {return m_SolidBuckets;}
69         BucketList & GetAlphaBuckets() {return m_AlphaBuckets;}
70
71         /*void PrintStats(int verbose_level) {
72                 printf("\nMappings...\n");
73                 printf("\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
74                 printf("\t\t m_SolidBuckets: %d\n", m_SolidBuckets.size());
75                 printf("\t m_AlphaBuckets: %d\n", m_AlphaBuckets.size());
76         }*/
77
78
79 private:
80         void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
81
82         void RenderSolidBuckets(const MT_Transform& cameratrans, 
83                 RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
84         void RenderAlphaBuckets(const MT_Transform& cameratrans, 
85                 RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
86
87
88 #ifdef WITH_CXX_GUARDEDALLOC
89         MEM_CXX_CLASS_ALLOC_FUNCS("GE:RAS_BucketManager")
90 #endif
91 };
92
93 #endif //__RAS_BUCKETMANAGER_H__
94