svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22625:22668
authorCampbell Barton <ideasman42@gmail.com>
Fri, 21 Aug 2009 03:09:27 +0000 (03:09 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 21 Aug 2009 03:09:27 +0000 (03:09 +0000)
needed this for 2.5 testing

1  2 
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.cpp

index 3d38759d9516f074a8be18835e34d87e48cd6585,d2e6bbb43f7d4b86ade1c6bd0602392c09bbdf47..6cb4e980a3de05c0692ca86b1036ebfacb0e48ae
  #include "KX_KetsjiEngine.h"
  #include "KX_BlenderSceneConverter.h"
  
 -#include"SND_Scene.h"
 -#include "SND_SoundListener.h"
 -
  /* This little block needed for linking to Blender... */
  #ifdef WIN32
  #include "BLI_winstuff.h"
@@@ -160,6 -163,7 +160,6 @@@ extern "C" 
  #include "SG_BBox.h"
  #include "SG_Tree.h"
  
 -// defines USE_ODE to choose physics engine
  #include "KX_ConvertPhysicsObject.h"
  #ifdef USE_BULLET
  #include "CcdPhysicsEnvironment.h"
  #ifdef __cplusplus
  extern "C" {
  #endif
 -#include "BSE_headerbuttons.h"
 -void update_for_newframe();
 +//XXX #include "BSE_headerbuttons.h"
 +//XXX void update_for_newframe();
  //void scene_update_for_newframe(struct Scene *sce, unsigned int lay);
  //#include "BKE_ipo.h"
  //void do_all_data_ipos(void);
@@@ -554,7 -558,7 +554,7 @@@ bool ConvertMaterial
                material->ref                   = mat->ref;
                material->amb                   = mat->amb;
  
 -              material->ras_mode |= (mat->mode & MA_WIRE)? WIRE: 0;
 +              material->ras_mode |= (mat->material_type == MA_TYPE_WIRE)? WIRE: 0;
        }
        else {
                int valid = 0;
        }
  
        // with ztransp enabled, enforce alpha blending mode
 -      if(validmat && (mat->mode & MA_ZTRA) && (material->transp == TF_SOLID))
 +      if(validmat && (mat->mode & MA_TRANSP) && (mat->mode & MA_ZTRANSP) && (material->transp == TF_SOLID))
                material->transp = TF_ALPHA;
  
        // always zsort alpha + add
@@@ -1603,6 -1607,18 +1603,6 @@@ void BL_CreatePhysicsObjectNew(KX_GameO
                        break;
  
  #endif
 -#ifdef USE_SUMO_SOLID
 -              case UseSumo:
 -                      KX_ConvertSumoObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
 -                      break;
 -#endif
 -                      
 -#ifdef USE_ODE
 -              case UseODE:
 -                      KX_ConvertODEEngineObject(gameobj, meshobj, kxscene, shapeprops, smmaterial, &objprop);
 -                      break;
 -#endif //USE_ODE
 -
                case UseDynamo:
                        //KX_ConvertDynamoObject(gameobj,meshobj,kxscene,shapeprops,    smmaterial,     &objprop);
                        break;
@@@ -1737,7 -1753,7 +1737,7 @@@ static KX_GameObject *gameobject_from_b
  
                if (bHasModifier) {
                        BL_ModifierDeformer *dcont = new BL_ModifierDeformer((BL_DeformableGameObject *)gameobj,
 -                                                                                                                              ob,     (BL_SkinMeshObject *)meshobj);
 +                                                                                                                              kxscene->GetBlenderScene(), ob, (BL_SkinMeshObject *)meshobj);
                        ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
                        if (bHasShapeKey && bHasArmature)
                                dcont->LoadShapeDrivers(ob->parent);
                gameobj = new BL_ArmatureObject(
                        kxscene,
                        KX_Scene::m_callbacks,
 -                      ob // handle
 +                      ob,
 +                      kxscene->GetBlenderScene() // handle
                );
                /* Get the current pose from the armature object and apply it as the rest pose */
                break;
@@@ -1805,7 -1820,7 +1805,7 @@@ struct parentChildLink 
  };
  
  #include "DNA_constraint_types.h"
 -#include "BIF_editconstraint.h"
 +//XXX #include "BIF_editconstraint.h"
  
  bPoseChannel *get_active_posechannel2 (Object *ob)
  {
@@@ -1826,8 -1841,7 +1826,8 @@@ ListBase *get_active_constraints2(Objec
        if (!ob)
                return NULL;
  
 -      if (ob->flag & OB_POSEMODE) {
 +  // XXX - shouldnt we care about the pose data and not the mode???
 +      if (ob->mode & OB_MODE_POSE) { 
                bPoseChannel *pchan;
  
                pchan = get_active_posechannel2(ob);
@@@ -1922,35 -1936,39 +1922,35 @@@ void BL_ConvertBlenderObjects(struct Ma
                aspect_width = canvas->GetWidth();
                aspect_height = canvas->GetHeight();
        } else {
 -              if (blenderscene->framing.type == SCE_GAMEFRAMING_BARS) {
 +              if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_BARS) {
                        frame_type = RAS_FrameSettings::e_frame_bars;
 -              } else if (blenderscene->framing.type == SCE_GAMEFRAMING_EXTEND) {
 +              } else if (blenderscene->gm.framing.type == SCE_GAMEFRAMING_EXTEND) {
                        frame_type = RAS_FrameSettings::e_frame_extend;
                } else {
                        frame_type = RAS_FrameSettings::e_frame_scale;
                }
                
 -              aspect_width = blenderscene->r.xsch;
 -              aspect_height = blenderscene->r.ysch;
 +              aspect_width = blenderscene->gm.xsch;
 +              aspect_height = blenderscene->gm.ysch;
        }
        
        RAS_FrameSettings frame_settings(
                frame_type,
 -              blenderscene->framing.col[0],
 -              blenderscene->framing.col[1],
 -              blenderscene->framing.col[2],
 +              blenderscene->gm.framing.col[0],
 +              blenderscene->gm.framing.col[1],
 +              blenderscene->gm.framing.col[2],
                aspect_width,
                aspect_height
        );
        kxscene->SetFramingType(frame_settings);
  
 -      kxscene->SetGravity(MT_Vector3(0,0,(blenderscene->world != NULL) ? -blenderscene->world->gravity : -9.8));
 +      kxscene->SetGravity(MT_Vector3(0,0, -blenderscene->gm.gravity));
        
        /* set activity culling parameters */
 -      if (blenderscene->world) {
 -              kxscene->SetActivityCulling( (blenderscene->world->mode & WO_ACTIVITY_CULLING) != 0);
 -              kxscene->SetActivityCullingRadius(blenderscene->world->activityBoxRadius);
 -              kxscene->SetDbvtCulling((blenderscene->world->mode & WO_DBVT_CULLING) != 0);
 -      } else {
 -              kxscene->SetActivityCulling(false);
 -              kxscene->SetDbvtCulling(false);
 -      }
 +      kxscene->SetActivityCulling( (blenderscene->gm.mode & WO_ACTIVITY_CULLING) != 0);
 +      kxscene->SetActivityCullingRadius(blenderscene->gm.activityBoxRadius);
 +      kxscene->SetDbvtCulling((blenderscene->gm.mode & WO_DBVT_CULLING) != 0);
 +      
        // no occlusion culling by default
        kxscene->SetDbvtOcclusionRes(0);
  
                        if (converter->addInitFromFrame){//rcruiz
                                float eulxyzPrev[3];
                                blenderscene->r.cfra=blenderscene->r.sfra-1;
 -                              update_for_newframe();
 +                              //XXX update_for_newframe();
                                MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
                                                                                        blenderobject->loc[1]+blenderobject->dloc[1],
                                                                                        blenderobject->loc[2]+blenderobject->dloc[2]
                                tmp.scale(fps, fps, fps);
                                iniang.push_back(tmp);
                                blenderscene->r.cfra=blenderscene->r.sfra;
 -                              update_for_newframe();
 +                              //XXX update_for_newframe();
                        }               
                                                
                        gameobj->NodeSetLocalPosition(pos);
                                                        if (converter->addInitFromFrame){//rcruiz
                                                                float eulxyzPrev[3];
                                                                blenderscene->r.cfra=blenderscene->r.sfra-1;
 -                                                              update_for_newframe();
 +                                                              //XXX update_for_newframe();
                                                                MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
                                                                                                                        blenderobject->loc[1]+blenderobject->dloc[1],
                                                                                                                        blenderobject->loc[2]+blenderobject->dloc[2]
                                                                tmp.scale(fps, fps, fps);
                                                                iniang.push_back(tmp);
                                                                blenderscene->r.cfra=blenderscene->r.sfra;
 -                                                              update_for_newframe();
 +                                                              //XXX update_for_newframe();
                                                        }               
                                                                                
                                                        gameobj->NodeSetLocalPosition(pos);
                                        obj->Release();
                        }
                        childrenlist->Release();
+                       
                        // now destroy recursively
+                       converter->UnregisterGameObject(childobj); // removing objects during conversion make sure this runs too
                        kxscene->RemoveObject(childobj);
+                       
                        continue;
                }
  
                        case PARBONE:
                        {
                                // parent this to a bone
 -                              Bone *parent_bone = get_named_bone(get_armature(blenderchild->parent), blenderchild->parsubstr);
 +                              Bone *parent_bone = get_named_bone( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr);
  
                                if(parent_bone) {
                                        KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone);
                }
        }
  
 -      sumolist->Release();    
 -
 -      // convert global sound stuff
 -
 -      /* XXX, glob is the very very wrong place for this
 -       * to be, re-enable once the listener has been moved into
 -       * the scene. */
 -#if 1
 -      SND_Scene* soundscene = kxscene->GetSoundScene();
 -      SND_SoundListener* listener = soundscene->GetListener();
 -      if (listener && G.listener)
 -      {
 -              listener->SetDopplerFactor(G.listener->dopplerfactor);
 -              listener->SetDopplerVelocity(G.listener->dopplervelocity);
 -              listener->SetGain(G.listener->gain);
 -      }
 -#endif
 +      sumolist->Release();
  
        // convert world
        KX_WorldInfo* worldinfo = new BlenderWorldInfo(blenderscene->world);
index 3220672c392bc4774ef2747fa8f662f0dc2f3276,4f47ce7a0368a93400a61e8c5a71cbbef3a220ad..151564391f307a3efd6bd609be51af3f39dd794a
  
  #include "DummyPhysicsEnvironment.h"
  
 -//to decide to use sumo/ode or dummy physics - defines USE_ODE
  #include "KX_ConvertPhysicsObject.h"
  
  #ifdef USE_BULLET
  #include "CcdPhysicsEnvironment.h"
  #endif
  
 -#ifdef USE_ODE
 -#include "OdePhysicsEnvironment.h"
 -#endif //USE_ODE
 -
 -#ifdef USE_SUMO_SOLID
 -#include "SumoPhysicsEnvironment.h"
 -#endif
 -
  #include "KX_BlenderSceneConverter.h"
  #include "KX_BlenderScalarInterpolator.h"
  #include "BL_BlenderDataConversion.h"
@@@ -74,8 -83,8 +74,8 @@@ extern "C
  #include "DNA_curve_types.h"
  #include "BLI_blenlib.h"
  #include "MEM_guardedalloc.h"
 -#include "BSE_editipo.h"
 -#include "BSE_editipo_types.h"
 +//XXX #include "BSE_editipo.h"
 +//XXX #include "BSE_editipo_types.h"
  #include "DNA_ipo_types.h"
  #include "BKE_global.h"
  #include "BKE_ipo.h" // eval_icu
@@@ -104,11 -113,11 +104,11 @@@ KX_BlenderSceneConverter::~KX_BlenderSc
        // 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();
                delete (*itm).second;
                itm++;
        }
 -      
 -#ifdef USE_SUMO_SOLID
 -      KX_ClearSumoSharedShapes();
 -#endif
  
  #ifdef USE_BULLET
        KX_ClearBulletSharedShapes();
@@@ -260,34 -273,38 +260,34 @@@ void KX_BlenderSceneConverter::ConvertS
        if (blenderscene)
        {
        
 -              if (blenderscene->world)
 +              switch (blenderscene->gm.physicsEngine)
                {
 -                      switch (blenderscene->world->physicsEngine)
 +              case WOPHY_BULLET:
                        {
 -                      case WOPHY_BULLET:
 -                              {
 -                                      physics_engine = UseBullet;
 -                                      useDbvtCulling = (blenderscene->world->mode & WO_DBVT_CULLING) != 0;
 -                                      break;
 -                              }
 -                                
 -                              case WOPHY_ODE:
 -                              {
 -                                      physics_engine = UseODE;
 -                                      break;
 -                              }
 -                              case WOPHY_DYNAMO:
 -                              {
 -                                      physics_engine = UseDynamo;
 -                                      break;
 -                              }
 -                              case WOPHY_SUMO:
 -                              {
 -                                      physics_engine = UseSumo; 
 -                                      break;
 -                              }
 -                              case WOPHY_NONE:
 -                              {
 -                                      physics_engine = UseNone;
 -                              }
 +                              physics_engine = UseBullet;
 +                              useDbvtCulling = (blenderscene->gm.mode & WO_DBVT_CULLING) != 0;
 +                              break;
 +                      }
 +                                                      
 +                      case WOPHY_ODE:
 +                      {
 +                              physics_engine = UseODE;
 +                              break;
 +                      }
 +                      case WOPHY_DYNAMO:
 +                      {
 +                              physics_engine = UseDynamo;
 +                              break;
 +                      }
 +                      case WOPHY_SUMO:
 +                      {
 +                              physics_engine = UseSumo; 
 +                              break;
 +                      }
 +                      case WOPHY_NONE:
 +                      {
 +                              physics_engine = UseNone;
                        }
 -                
                }
        }
  
                                destinationscene->SetPhysicsEnvironment(ccdPhysEnv);
                                break;
                        }
 -#endif
 -
 -#ifdef USE_SUMO_SOLID
 -              case UseSumo:
 -                      destinationscene ->SetPhysicsEnvironment(new SumoPhysicsEnvironment());
 -                      break;
 -#endif
 -#ifdef USE_ODE
 -
 -              case UseODE:
 -                      destinationscene ->SetPhysicsEnvironment(new ODEPhysicsEnvironment());
 -                      break;
 -#endif //USE_ODE
 -      
 +#endif        
                case UseDynamo:
                {
                }
@@@ -462,10 -492,11 +462,11 @@@ void KX_BlenderSceneConverter::Register
        m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject),gameobject);
  }
  
+ /* only need to run this during conversion since
+  * m_map_blender_to_gameobject is freed after conversion */
  void KX_BlenderSceneConverter::UnregisterGameObject(
                                                                        KX_GameObject *gameobject) 
  {
- #if 0
        struct Object *bobp= gameobject->GetBlenderObject();
        if (bobp) {
                CHashedPtr bptr(bobp);
                        m_map_blender_to_gameobject.remove(bptr);
                }
        }
- #endif
  }
  
  KX_GameObject *KX_BlenderSceneConverter::FindGameObject(
@@@ -524,18 -554,18 +524,18 @@@ void KX_BlenderSceneConverter::Register
  
  
  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;
  }
@@@ -590,9 -620,8 +590,9 @@@ void KX_BlenderSceneConverter::Register
   * When deleting an IPO curve from Python, check if the IPO is being
   * edited and if so clear the pointer to the old curve.
   */
 -void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu)
 +void KX_BlenderSceneConverter::localDel_ipoCurve ( IpoCurve * icu )
  {
 +#if 0 //XXX
        if (!G.sipo)
                return;
  
                        return;
                }
        }
 +#endif
  }
  
  //quick hack
  extern "C"
  {
        Ipo *add_ipo( char *name, int idcode );
 -      char *getIpoCurveName( IpoCurve * icu );
 -      struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short);
 -      void testhandles_ipocurve(struct IpoCurve *icu);
 +      //XXX char *getIpoCurveName( IpoCurve * icu );
 +      //XXX struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
 +      //XXX void testhandles_ipocurve(struct IpoCurve *icu);
        void insert_vert_icu(struct IpoCurve *, float, float, short);
        float eval_icu(struct IpoCurve *icu, float ipotime);
        //void Mat3ToEul(float tmat[][3], float *eul);
@@@ -628,11 -656,11 +628,11 @@@ IpoCurve* findIpoCurve(IpoCurve* first
        IpoCurve* icu1;
        for( icu1 = first; icu1; icu1 = icu1->next ) 
        {
 -              char* curveName = getIpoCurveName( icu1 );
 +              /*XXX char* curveName = getIpoCurveName( icu1 );
                if( !strcmp( curveName, searchName) )
                {
                        return icu1;
 -              }
 +              }*/
        }
        return 0;
  }
@@@ -706,7 -734,7 +706,7 @@@ void       KX_BlenderSceneConverter::ResetPhy
                                                        }
                                                }
                                        } else
 -                                      {       ipo = add_ipo(blenderObject->id.name+2, ID_OB);
 +                                      {       ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB);
                                                blenderObject->ipo = ipo;
  
                                        }
@@@ -795,7 -823,6 +795,7 @@@ void       KX_BlenderSceneConverter::WritePhy
                                Object* blenderObject = gameObj->GetBlenderObject();
                                if (blenderObject && blenderObject->ipo)
                                {
 +#if 0
                                        const MT_Point3& position = gameObj->NodeGetWorldPosition();
                                        //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
                                        const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
                                        float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f};                                           
                                        float tmat[3][3];
                                        
 +                                      // XXX animato
                                        Ipo* ipo = blenderObject->ipo;
  
                                        //create the curves, if not existing, set linear if new
                                        if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
                                        
                                        // Handles are corrected at the end, testhandles_ipocurve isnt needed yet
 +#endif
                                }
                        }
                }
@@@ -896,8 -921,6 +896,8 @@@ void       KX_BlenderSceneConverter::TestHand
                                Object* blenderObject = gameObj->GetBlenderObject();
                                if (blenderObject && blenderObject->ipo)
                                {
 +                                      // XXX animato
 +#if 0
                                        Ipo* ipo = blenderObject->ipo;
                                        
                                        //create the curves, if not existing
                                        testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotX"));
                                        testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotY"));
                                        testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ"));
 +#endif
                                }
                        }