svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22701:22704
[blender.git] / source / gameengine / Converter / KX_BlenderScalarInterpolator.cpp
index 17bb3dedd3649c4d41f2a55a82bde963aba153aa..24910422176cbbbe1a12779caf25c76d9af7e445 100644 (file)
 
 #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 0; // XXX 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 = 0; // XXX 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(struct AnimData *adt) {
+       if(adt->action==NULL)
+               return;
+       
+       for(FCurve *fcu= (FCurve *)adt->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 +62,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;
 }