svn merge -r 15292:15392 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / gameengine / Converter / BL_ShapeDeformer.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_SHAPEDEFORMER
31 #define BL_SHAPEDEFORMER
32
33 #ifdef WIN32
34 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
35 #endif //WIN32
36
37 #include "BL_SkinDeformer.h"
38 #include "BL_DeformableGameObject.h"
39 #include <vector>
40
41 struct IpoCurve;
42
43 class BL_ShapeDeformer : public BL_SkinDeformer  
44 {
45 public:
46         virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
47         {
48                 void **h_obj = (*map)[m_gameobj];
49                 if (h_obj){
50                         m_gameobj = (BL_DeformableGameObject*)(*h_obj);
51                 }
52                 else
53                         m_gameobj=NULL;
54                 // relink the underlying skin deformer
55                 BL_SkinDeformer::Relink(map);
56         };
57         BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
58                      Object *bmeshobj,
59                      BL_SkinMeshObject *mesh)
60                                         :       
61                                                 BL_SkinDeformer(bmeshobj, mesh),
62                                                 m_lastShapeUpdate(-1),
63                                                 m_gameobj(gameobj)
64         {
65         };
66
67         /* this second constructor is needed for making a mesh deformable on the fly. */
68         BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
69                                         struct Object *bmeshobj_old,
70                                         struct Object *bmeshobj_new,
71                                         class BL_SkinMeshObject *mesh,
72                                         bool release_object,
73                                         BL_ArmatureObject* arma = NULL)
74                                         :
75                                                 BL_SkinDeformer(bmeshobj_old, bmeshobj_new, mesh, release_object, arma),
76                                                 m_lastShapeUpdate(-1),
77                                                 m_gameobj(gameobj)
78         {
79         };
80
81         virtual void ProcessReplica();
82         virtual RAS_Deformer *GetReplica();
83         virtual ~BL_ShapeDeformer();
84
85         bool Update (void);
86         bool LoadShapeDrivers(Object* arma);
87         bool ExecuteShapeDrivers(void);
88
89         void ForceUpdate()
90         {
91                 m_lastShapeUpdate = -1.0;
92         };
93
94 protected:
95         vector<IpoCurve*>                m_shapeDrivers;
96         double                                   m_lastShapeUpdate;
97         BL_DeformableGameObject* m_gameobj;
98
99 };
100
101 #endif
102