use const for readonly strings and set some functions to static
[blender.git] / source / gameengine / Converter / KX_BlenderScalarInterpolator.cpp
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 gameengine/Converter/KX_BlenderScalarInterpolator.cpp
29  *  \ingroup bgeconv
30  */
31
32
33 #include "KX_BlenderScalarInterpolator.h"
34
35 #include <cstring>
36
37 extern "C" {
38 #include "DNA_ipo_types.h"
39 #include "DNA_action_types.h"
40 #include "DNA_anim_types.h"
41 #include "BKE_fcurve.h"
42 }
43
44 float BL_ScalarInterpolator::GetValue(float currentTime) const {
45         // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime);
46         return evaluate_fcurve(m_fcu, currentTime);
47 }
48
49 BL_InterpolatorList::BL_InterpolatorList(bAction *action) {
50         if(action==NULL)
51                 return;
52         
53         for(FCurve *fcu= (FCurve *)action->curves.first; fcu; fcu= (FCurve *)fcu->next) {
54                 if(fcu->rna_path) {
55                         BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); 
56                         //assert(new_ipo);
57                         push_back(new_ipo);
58                 }
59         }
60 }
61
62 BL_InterpolatorList::~BL_InterpolatorList() {
63         BL_InterpolatorList::iterator i;
64         for (i = begin(); !(i == end()); ++i) {
65                 delete *i;
66         }
67 }
68
69 KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index) {
70         for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ )
71         {
72                 FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve();
73                 if(array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0)
74                         return *i;
75         }
76         return NULL;
77 }       
78