Revision: 20894
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20894
Author:   campbellbarton
Date:     2009-06-15 12:11:08 +0200 (Mon, 15 Jun 2009)

Log Message:
-----------
Game Engine working with the new animation system for Ipos (IpoActuator)
FCurves are used for animation evaluation so FCurve modifiers work :).

Tested with object location and object color animation.
Armature and Shape Keys next.

Modified Paths:
--------------
    
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
    
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
    
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
    
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.h
    branches/blender2.5/blender/source/gameengine/Converter/KX_IpoConvert.cpp

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
    2009-06-15 09:54:37 UTC (rev 20893)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
    2009-06-15 10:11:08 UTC (rev 20894)
@@ -27,33 +27,28 @@
  */
 
 #include "KX_BlenderScalarInterpolator.h"
+#include "stdio.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) {
+       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 +59,13 @@
        }
 }
 
-
-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(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;
 }      
 

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
      2009-06-15 09:54:37 UTC (rev 20893)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.h
      2009-06-15 10:11:08 UTC (rev 20894)
@@ -38,29 +38,26 @@
 class BL_ScalarInterpolator : public KX_IScalarInterpolator {
 public:
        BL_ScalarInterpolator() {} // required for use in STL list
-       BL_ScalarInterpolator(struct Ipo *ipo, BL_IpoChannel channel) :
-               m_blender_ipo(ipo),
-               m_channel(channel)
+       BL_ScalarInterpolator(struct FCurve* fcu) :
+               m_fcu(fcu)
                {}
 
        virtual ~BL_ScalarInterpolator() {}
        
        virtual float GetValue(float currentTime) const;
+       struct FCurve *GetFCurve() { return m_fcu;};
 
-       BL_IpoChannel GetChannel() const { return m_channel; }
-
 private:
-       struct Ipo    *m_blender_ipo;
-       BL_IpoChannel  m_channel;
+       struct FCurve *m_fcu;
 };
 
 
 class BL_InterpolatorList : public std::vector<KX_IScalarInterpolator *> {
 public:
-       BL_InterpolatorList(struct Ipo *ipo);
+       BL_InterpolatorList(struct AnimData *adt);
        ~BL_InterpolatorList();
 
-       KX_IScalarInterpolator *GetScalarInterpolator(BL_IpoChannel channel);   
+       KX_IScalarInterpolator *GetScalarInterpolator(char *rna_path, int 
array_index); 
 };
 
 #endif //__KX_SCALARINTERPOLATOR_H

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
        2009-06-15 09:54:37 UTC (rev 20893)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
        2009-06-15 10:11:08 UTC (rev 20894)
@@ -113,11 +113,11 @@
        // delete sumoshapes
        
 
-       int numipolists = m_map_blender_to_gameipolist.size();
-       for (i=0; i<numipolists; i++) {
-               BL_InterpolatorList *ipoList= 
*m_map_blender_to_gameipolist.at(i);
+       int numAdtLists = m_map_blender_to_gameAdtList.size();
+       for (i=0; i<numAdtLists; i++) {
+               BL_InterpolatorList *adtList= 
*m_map_blender_to_gameAdtList.at(i);
 
-               delete (ipoList);
+               delete (adtList);
        }
 
        vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator itw = 
m_worldinfos.begin();
@@ -573,18 +573,18 @@
 
 
 void KX_BlenderSceneConverter::RegisterInterpolatorList(
-                                                                       
BL_InterpolatorList *ipoList,
-                                                                       struct 
Ipo *for_ipo)
+                                                                       
BL_InterpolatorList *adtList,
+                                                                       struct 
AnimData *for_adt)
 {
-       m_map_blender_to_gameipolist.insert(CHashedPtr(for_ipo), ipoList);
+       m_map_blender_to_gameAdtList.insert(CHashedPtr(for_adt), adtList);
 }
 
 
 
 BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList(
-                                                                       struct 
Ipo *for_ipo)
+                                                                       struct 
AnimData *for_adt)
 {
-       BL_InterpolatorList **listp = 
m_map_blender_to_gameipolist[CHashedPtr(for_ipo)];
+       BL_InterpolatorList **listp = 
m_map_blender_to_gameAdtList[CHashedPtr(for_adt)];
                
        return listp?*listp:NULL;
 }

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.h
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.h
  2009-06-15 09:54:37 UTC (rev 20893)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderSceneConverter.h
  2009-06-15 10:11:08 UTC (rev 20894)
@@ -65,7 +65,7 @@
        GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator;
        GEN_Map<CHashedPtr,SCA_IController*> m_map_blender_to_gamecontroller;
        
-       GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist;
+       GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameAdtList;
        
        Main*                                   m_maggie;
 
@@ -121,8 +121,8 @@
 
        void RegisterBlenderMaterial(BL_Material *mat);
        
-       void RegisterInterpolatorList(BL_InterpolatorList *ipoList, struct Ipo 
*for_ipo);
-       BL_InterpolatorList *FindInterpolatorList(struct Ipo *for_ipo);
+       void RegisterInterpolatorList(BL_InterpolatorList *adtList, struct 
AnimData *for_adt);
+       BL_InterpolatorList *FindInterpolatorList(struct AnimData *for_adt);
 
        void RegisterGameActuator(SCA_IActuator *act, struct bActuator 
*for_actuator);
        SCA_IActuator *FindGameActuator(struct bActuator *for_actuator);

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/KX_IpoConvert.cpp
===================================================================
--- branches/blender2.5/blender/source/gameengine/Converter/KX_IpoConvert.cpp   
2009-06-15 09:54:37 UTC (rev 20893)
+++ branches/blender2.5/blender/source/gameengine/Converter/KX_IpoConvert.cpp   
2009-06-15 10:11:08 UTC (rev 20894)
@@ -71,20 +71,20 @@
 
 #include "STR_HashedString.h"
 
-static BL_InterpolatorList *GetIpoList(struct Ipo *for_ipo, 
KX_BlenderSceneConverter *converter) {
-       BL_InterpolatorList *ipoList= converter->FindInterpolatorList(for_ipo);
+static BL_InterpolatorList *GetAdtList(struct AnimData *for_adt, 
KX_BlenderSceneConverter *converter) {
+       BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_adt);
 
-       if (!ipoList) {         
-               ipoList = new BL_InterpolatorList(for_ipo);
-               converter->RegisterInterpolatorList(ipoList, for_ipo);
+       if (!adtList) {         
+               adtList = new BL_InterpolatorList(for_adt);
+               converter->RegisterInterpolatorList(adtList, for_adt);
        }
                        
-       return ipoList; 
+       return adtList; 
 }
 
 void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* 
gameobj,KX_BlenderSceneConverter *converter)
 {
-       if (blenderobject->ipo) {
+       if (blenderobject->adt) {
 
                KX_IpoSGController* ipocontr = new KX_IpoSGController();
                gameobj->GetSGNode()->AddSGController(ipocontr);
@@ -120,271 +120,79 @@
                        )
                );
 
-               BL_InterpolatorList *ipoList= GetIpoList(blenderobject->ipo, 
converter);
+               BL_InterpolatorList *adtList= GetAdtList(blenderobject->adt, 
converter);
                
-               // For each active channel in the ipoList add an
+               // For each active channel in the adtList add an
                // interpolator to the game object.
                
-               KX_IScalarInterpolator *ipo;
+               KX_IInterpolator *interpolator;
+               KX_IScalarInterpolator *interp;
                
-               ipo = ipoList->GetScalarInterpolator(OB_LOC_X);
-               if (ipo) {
-                       KX_IInterpolator *interpolator =
-                               new KX_ScalarInterpolator(
-                                       
&(ipocontr->GetIPOTransform().GetPosition()[0]),
-                                       ipo);
-                       ipocontr->AddInterpolator(interpolator);
-                       ipocontr->SetIPOChannelActive(OB_LOC_X, true);
-       
+               for(int i=0; i<3; i++) {
+                       if ((interp = 
adtList->GetScalarInterpolator("location", i))) {
+                               interpolator= new 
KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetPosition()[i]), interp);
+                               ipocontr->AddInterpolator(interpolator);
+                               ipocontr->SetIPOChannelActive(OB_LOC_X+i, true);
+                       }
                }
-               
-               ipo = ipoList->GetScalarInterpolator(OB_LOC_Y);
-               if (ipo) {
-                       KX_IInterpolator *interpolator =
-                               new KX_ScalarInterpolator(
-                                       
&(ipocontr->GetIPOTransform().GetPosition()[1]),
-                                       ipo);
-                       ipocontr->AddInterpolator(interpolator);
-                       ipocontr->SetIPOChannelActive(OB_LOC_Y, true);
+               for(int i=0; i<3; i++) {
+                       if ((interp = 
adtList->GetScalarInterpolator("delta_location", i))) {
+                               interpolator= new 
KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetDeltaPosition()[i]), 
interp);
+                               ipocontr->AddInterpolator(interpolator);
+                               ipocontr->SetIPOChannelActive(OB_DLOC_X+i, 
true);
+                       }
                }
-               
-               ipo = ipoList->GetScalarInterpolator(OB_LOC_Z);
-               if (ipo) {
-                       KX_IInterpolator *interpolator =
-                               new KX_ScalarInterpolator(
-                                       
&(ipocontr->GetIPOTransform().GetPosition()[2]),
-                                       ipo);
-                       ipocontr->AddInterpolator(interpolator);
-                       ipocontr->SetIPOChannelActive(OB_LOC_Z, true);
+               for(int i=0; i<3; i++) {
+                       if ((interp = 
adtList->GetScalarInterpolator("rotation", i))) {
+                               interpolator= new 
KX_ScalarInterpolator(&(ipocontr->GetIPOTransform().GetEulerAngles()[i]), 
interp);
+                               ipocontr->AddInterpolator(interpolator);
+                               ipocontr->SetIPOChannelActive(OB_ROT_X+i, true);
+                       }
                }
-               
-               // Master the art of cut & paste programming...
-               
-               ipo = ipoList->GetScalarInterpolator(OB_DLOC_X);
-               if (ipo) {

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to