Get rid of c++ in blenkernel and modifiers
[blender.git] / source / gameengine / Converter / KX_BlenderScalarInterpolator.cpp
index 4d79febb7b4bab23fe250438726c9b8bb7c3299b..75c0e012226b2da765df059a91a1de257aa4e493 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  * All rights reserved.
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file gameengine/Converter/KX_BlenderScalarInterpolator.cpp
+ *  \ingroup bgeconv
+ */
+
+
 #include "KX_BlenderScalarInterpolator.h"
 
+#include <cstring>
+
 extern "C" {
 #include "DNA_ipo_types.h"
-#include "BKE_ipo.h"
+#include "DNA_action_types.h"
+#include "DNA_anim_types.h"
+#include "BKE_fcurve.h"
 }
 
-static const int BL_MAX_CHANNELS = 32;
-
 float BL_ScalarInterpolator::GetValue(float currentTime) const {
-       return IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime);
+       // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime);
+       return evaluate_fcurve(m_fcu, currentTime);
 }
 
-
-BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) {
-       IPO_Channel channels[BL_MAX_CHANNELS];
-
-       int num_channels = IPO_GetChannels(ipo, channels);
-
-       int i;
-
-       for (i = 0; i != num_channels; ++i) {
-               BL_ScalarInterpolator *new_ipo =
-                       new BL_ScalarInterpolator(ipo, channels[i]); 
-
-               //assert(new_ipo);
-               push_back(new_ipo);
+BL_InterpolatorList::BL_InterpolatorList(bAction *action) {
+       if(action==NULL)
+               return;
+       
+       for(FCurve *fcu= (FCurve *)action->curves.first; fcu; fcu= (FCurve *)fcu->next) {
+               if(fcu->rna_path) {
+                       BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); 
+                       //assert(new_ipo);
+                       push_back(new_ipo);
+               }
        }
 }
 
@@ -64,15 +67,13 @@ BL_InterpolatorList::~BL_InterpolatorList() {
        }
 }
 
-
-KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(BL_IpoChannel channel) {
-       BL_InterpolatorList::iterator i = begin();
-       while (!(i == end()) && 
-                  (static_cast<BL_ScalarInterpolator *>(*i))->GetChannel() != 
-                  channel) {
-               ++i;
+KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index) {
+       for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ )
+       {
+               FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve();
+               if(array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0)
+                       return *i;
        }
-       
-       return (i == end()) ? 0 : *i;
+       return NULL;
 }