merge with trunk (15330 -> 15566)
[blender.git] / source / gameengine / Converter / BL_SkinMeshObject.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #ifndef __BL_SKINMESHOBJECT
31 #define __BL_SKINMESHOBJECT
32
33 #ifdef WIN32
34 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
35 #endif //WIN32
36 #include "MEM_guardedalloc.h"
37 #include "RAS_MeshObject.h"
38 #include "RAS_Deformer.h"
39 #include "RAS_IPolygonMaterial.h"
40
41 #include "BL_MeshDeformer.h"
42
43 #include "DNA_mesh_types.h"
44 #include "DNA_key_types.h"
45 #include "DNA_meshdata_types.h"
46
47 class BL_SkinMeshObject : public RAS_MeshObject
48 {
49
50 //      enum    {       BUCKET_MAX_INDICES = 16384};//2048};//8192};
51 //      enum    {       BUCKET_MAX_TRIANGLES = 4096};
52
53 protected:
54         vector<int>                              m_cacheWeightIndex;
55
56 public:
57         void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec);
58 //      void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr);
59
60         BL_SkinMeshObject(Mesh* mesh, int lightlayer) : RAS_MeshObject (mesh, lightlayer)
61         { 
62                 m_class = 1;
63                 if (m_mesh && m_mesh->key)
64                 {
65                         KeyBlock *kb;
66                         int count=0;
67                         // initialize weight cache for shape objects
68                         // count how many keys in this mesh
69                         for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next)
70                                 count++;
71                         m_cacheWeightIndex.resize(count,-1);
72                 }
73         };
74
75         virtual ~BL_SkinMeshObject()
76         {
77                 if (m_mesh && m_mesh->key) 
78                 {
79                         KeyBlock *kb;
80                         // remove the weight cache to avoid memory leak 
81                         for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) {
82                                 if(kb->weights) 
83                                         MEM_freeN(kb->weights);
84                                 kb->weights= NULL;
85                         }
86                 }
87         };
88         
89         // for shape keys, 
90         void CheckWeightCache(struct Object* obj);
91
92 };
93
94 #endif
95