~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/gameengine/Converter/KX_BlenderSceneConverter.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-04-28 12:11:12 UTC
  • mto: (14.1.6 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20120428121112-2zi0vp8b6vejda8i
Tags: upstream-2.63
ImportĀ upstreamĀ versionĀ 2.63

Show diffs side-by-side

added added

removed removed

Lines of Context:
214
214
         * Find the specified scene by name, or the first
215
215
         * scene if nothing matches (shouldn't happen).
216
216
         */
217
 
        if((sce= (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
 
217
        if ((sce= (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
218
218
                return sce;
219
219
 
220
220
        for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) {
221
221
                Main *main= *it;
222
222
 
223
 
                if((sce= (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
 
223
                if ((sce= (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
224
224
                        return sce;
225
225
        }
226
226
 
308
308
                                useDbvtCulling = (blenderscene->gm.mode & WO_DBVT_CULLING) != 0;
309
309
                                break;
310
310
                        }
311
 
                                                        
312
 
                        case WOPHY_ODE:
313
 
                        {
314
 
                                physics_engine = UseODE;
315
 
                                break;
316
 
                        }
317
 
                        case WOPHY_DYNAMO:
318
 
                        {
319
 
                                physics_engine = UseDynamo;
320
 
                                break;
321
 
                        }
322
 
                        case WOPHY_SUMO:
323
 
                        {
324
 
                                physics_engine = UseSumo; 
325
 
                                break;
326
 
                        }
 
311
                        default:
327
312
                        case WOPHY_NONE:
328
313
                        {
329
314
                                physics_engine = UseNone;
 
315
                                break;
330
316
                        }
331
317
                }
332
318
        }
352
338
                                destinationscene->SetPhysicsEnvironment(ccdPhysEnv);
353
339
                                break;
354
340
                        }
355
 
#endif  
356
 
                case UseDynamo:
357
 
                {
358
 
                }
359
 
                
 
341
#endif
360
342
                default:
361
343
                case UseNone:
362
344
                        physics_engine = UseNone;
537
519
                                                                        RAS_MeshObject *gamemesh,
538
520
                                                                        struct Mesh *for_blendermesh)
539
521
{
540
 
        if(for_blendermesh) { /* dynamically loaded meshes we dont want to keep lookups for */
 
522
        if (for_blendermesh) { /* dynamically loaded meshes we don't want to keep lookups for */
541
523
                m_map_mesh_to_gamemesh.insert(CHashedPtr(for_blendermesh),gamemesh);
542
524
        }
543
525
        m_meshobjects.push_back(pair<KX_Scene*,RAS_MeshObject*>(m_currentScene,gamemesh));
661
643
                                        Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
662
644
                                        if (ipo)
663
645
                                        {       //clear the curve data
664
 
                                                if (clearIpo){//rcruiz
 
646
                                                if (clearIpo) {//rcruiz
665
647
                                                        IpoCurve *icu1;
666
648
                                                                                                                
667
649
                                                        int numCurves = 0;
668
 
                                                        for( icu1 = (IpoCurve*)ipo->curve.first; icu1;  ) {
 
650
                                                        for ( icu1 = (IpoCurve*)ipo->curve.first; icu1;  ) {
669
651
                                                        
670
652
                                                                IpoCurve* tmpicu = icu1;
671
653
                                                                
672
654
                                                                /*int i;
673
655
                                                                BezTriple *bezt;
674
 
                                                                for( bezt = tmpicu->bezt, i = 0;        i < tmpicu->totvert; i++, bezt++){
 
656
                                                                for ( bezt = tmpicu->bezt, i = 0;       i < tmpicu->totvert; i++, bezt++) {
675
657
                                                                        printf("(%f,%f,%f),(%f,%f,%f),(%f,%f,%f)\n",bezt->vec[0][0],bezt->vec[0][1],bezt->vec[0][2],bezt->vec[1][0],bezt->vec[1][1],bezt->vec[1][2],bezt->vec[2][0],bezt->vec[2][1],bezt->vec[2][2]);
676
658
                                                                }*/
677
659
                                                                
679
661
                                                                numCurves++;
680
662
                        
681
663
                                                                BLI_remlink( &( blenderObject->ipo->curve ), tmpicu );
682
 
                                                                if( tmpicu->bezt )
 
664
                                                                if ( tmpicu->bezt )
683
665
                                                                        MEM_freeN( tmpicu->bezt );
684
666
                                                                MEM_freeN( tmpicu );
685
667
                                                                localDel_ipoCurve( tmpicu );
705
687
 
706
688
void    KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo()
707
689
{
708
 
        if (addInitFromFrame){          
 
690
        if (addInitFromFrame) {         
709
691
                KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes();
710
692
                int numScenes = scenes->size();
711
 
                if (numScenes>=0){
 
693
                if (numScenes>=0) {
712
694
                        KX_Scene* scene = scenes->at(0);
713
695
                        CListValue* parentList = scene->GetRootParentList();
714
 
                        for (int ix=0;ix<parentList->GetCount();ix++){
 
696
                        for (int ix=0;ix<parentList->GetCount();ix++) {
715
697
                                KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix);
716
 
                                if (!gameobj->IsDynamic()){
 
698
                                if (!gameobj->IsDynamic()) {
717
699
                                        Object* blenderobject = gameobj->GetBlenderObject();
718
700
                                        if (!blenderobject)
719
701
                                                continue;
769
751
                        {
770
752
                                //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
771
753
 
772
 
                                if(blenderObject->adt==NULL)
 
754
                                if (blenderObject->adt==NULL)
773
755
                                        BKE_id_add_animdata(&blenderObject->id);
774
756
 
775
757
                                if (blenderObject->adt)
807
789
                                        IpoCurve *icu_lx = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
808
790
                                        if (!icu_lx) {
809
791
                                                icu_lx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
810
 
                                                if(icu_lx) icu_lx->ipo = IPO_LIN;
 
792
                                                if (icu_lx) icu_lx->ipo = IPO_LIN;
811
793
                                        }
812
794
                                        IpoCurve *icu_ly = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
813
795
                                        if (!icu_ly) {
814
796
                                                icu_ly = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
815
 
                                                if(icu_ly) icu_ly->ipo = IPO_LIN;
 
797
                                                if (icu_ly) icu_ly->ipo = IPO_LIN;
816
798
                                        }
817
799
                                        IpoCurve *icu_lz = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
818
800
                                        if (!icu_lz) {
819
801
                                                icu_lz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
820
 
                                                if(icu_lz) icu_lz->ipo = IPO_LIN;
 
802
                                                if (icu_lz) icu_lz->ipo = IPO_LIN;
821
803
                                        }
822
804
                                        IpoCurve *icu_rx = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
823
805
                                        if (!icu_rx) {
824
806
                                                icu_rx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
825
 
                                                if(icu_rx) icu_rx->ipo = IPO_LIN;
 
807
                                                if (icu_rx) icu_rx->ipo = IPO_LIN;
826
808
                                        }
827
809
                                        IpoCurve *icu_ry = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
828
810
                                        if (!icu_ry) {
829
811
                                                icu_ry = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
830
 
                                                if(icu_ry) icu_ry->ipo = IPO_LIN;
 
812
                                                if (icu_ry) icu_ry->ipo = IPO_LIN;
831
813
                                        }
832
814
                                        IpoCurve *icu_rz = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
833
815
                                        if (!icu_rz) {
834
816
                                                icu_rz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
835
 
                                                if(icu_rz) icu_rz->ipo = IPO_LIN;
 
817
                                                if (icu_rz) icu_rz->ipo = IPO_LIN;
836
818
                                        }
837
819
                                        
838
 
                                        if(icu_rx) eulerAnglesOld[0]= eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
839
 
                                        if(icu_ry) eulerAnglesOld[1]= eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
840
 
                                        if(icu_rz) eulerAnglesOld[2]= eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
 
820
                                        if (icu_rx) eulerAnglesOld[0]= eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
 
821
                                        if (icu_ry) eulerAnglesOld[1]= eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
 
822
                                        if (icu_rz) eulerAnglesOld[2]= eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
841
823
                                        
842
824
                                        // orn.getValue((float *)tmat); // uses the wrong ordering, cant use this
843
825
                                        for (int r=0;r<3;r++)
848
830
                                        mat3_to_compatible_eul( eulerAngles, eulerAnglesOld,tmat);
849
831
                                        
850
832
                                        //eval_icu
851
 
                                        for(int x = 0; x < 3; x++)
 
833
                                        for (int x = 0; x < 3; x++)
852
834
                                                eulerAngles[x] *= (float) ((180 / 3.14159265f) / 10.0);
853
835
                                        
854
836
                                        //fill the curves with data
859
841
                                        if (icu_ry) insert_vert_icu(icu_ry, frameNumber, eulerAngles[1], 1);
860
842
                                        if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
861
843
                                        
862
 
                                        // Handles are corrected at the end, testhandles_ipocurve isnt needed yet
 
844
                                        // Handles are corrected at the end, testhandles_ipocurve isn't needed yet
863
845
#endif
864
846
                                }
865
847
                        }
925
907
Main* KX_BlenderSceneConverter::GetMainDynamicPath(const char *path)
926
908
{
927
909
        for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++)
928
 
                if(BLI_path_cmp((*it)->name, path) == 0)
 
910
                if (BLI_path_cmp((*it)->name, path) == 0)
929
911
                        return *it;
930
912
        
931
913
        return NULL;
953
935
        Main *main_tmp= NULL; /* created only for linking, then freed */
954
936
        LinkNode *names = NULL;
955
937
        int idcode= BKE_idcode_from_name(group);
956
 
        short flag= 0; /* dont need any special options */
 
938
        short flag= 0; /* don't need any special options */
957
939
        ReportList reports;
958
940
        static char err_local[255];
959
941
        
960
942
        /* only scene and mesh supported right now */
961
 
        if(idcode!=ID_SCE && idcode!=ID_ME &&idcode!=ID_AC) {
 
943
        if (idcode!=ID_SCE && idcode!=ID_ME &&idcode!=ID_AC) {
962
944
                snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group);
963
945
                *err_str= err_local;
964
946
                BLO_blendhandle_close(bpy_openlib);
965
947
                return false;
966
948
        }
967
949
        
968
 
        if(GetMainDynamicPath(path)) {
 
950
        if (GetMainDynamicPath(path)) {
969
951
                snprintf(err_local, sizeof(err_local), "blend file already open \"%s\"\n", path);
970
952
                *err_str= err_local;
971
953
                BLO_blendhandle_close(bpy_openlib);
972
954
                return false;
973
955
        }
974
956
 
975
 
        if(bpy_openlib==NULL) {
 
957
        if (bpy_openlib==NULL) {
976
958
                snprintf(err_local, sizeof(err_local), "could not open blendfile \"%s\"\n", path);
977
959
                *err_str= err_local;
978
960
                return false;
1027
1009
        strncpy(main_newlib->name, path, sizeof(main_newlib->name));    
1028
1010
        
1029
1011
        
1030
 
        if(idcode==ID_ME) {
 
1012
        if (idcode==ID_ME) {
1031
1013
                /* Convert all new meshes into BGE meshes */
1032
1014
                ID* mesh;
1033
1015
        
1034
 
                for(mesh= (ID *)main_newlib->mesh.first; mesh; mesh= (ID *)mesh->next ) {
 
1016
                for (mesh= (ID *)main_newlib->mesh.first; mesh; mesh= (ID *)mesh->next ) {
1035
1017
                        if (options & LIB_LOAD_VERBOSE)
1036
1018
                                printf("MeshName: %s\n", mesh->name+2);
1037
1019
                        RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this);
1038
1020
                        scene_merge->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
1039
1021
                }
1040
1022
        }
1041
 
        else if(idcode==ID_AC) {
 
1023
        else if (idcode==ID_AC) {
1042
1024
                /* Convert all actions */
1043
1025
                ID *action;
1044
1026
 
1045
 
                for(action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
 
1027
                for (action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
1046
1028
                        if (options & LIB_LOAD_VERBOSE)
1047
1029
                                printf("ActionName: %s\n", action->name+2);
1048
1030
                        scene_merge->GetLogicManager()->RegisterActionName(action->name+2, action);
1049
1031
                }
1050
1032
        }
1051
 
        else if(idcode==ID_SCE) {               
 
1033
        else if (idcode==ID_SCE) {              
1052
1034
                /* Merge all new linked in scene into the existing one */
1053
1035
                ID *scene;
1054
 
                for(scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) {
 
1036
                for (scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) {
1055
1037
                        if (options & LIB_LOAD_VERBOSE)
1056
1038
                                printf("SceneName: %s\n", scene->name+2);
1057
1039
                        
1059
1041
                        KX_Scene* other= m_ketsjiEngine->CreateScene((Scene *)scene);
1060
1042
                        scene_merge->MergeScene(other);
1061
1043
                        
1062
 
                        // RemoveScene(other); // Dont run this, it frees the entire scene converter data, just delete the scene
 
1044
                        // RemoveScene(other); // Don't run this, it frees the entire scene converter data, just delete the scene
1063
1045
                        delete other;
1064
1046
                }
1065
1047
 
1067
1049
                if (options & LIB_LOAD_LOAD_ACTIONS) {
1068
1050
                        ID *action;
1069
1051
 
1070
 
                        for(action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
 
1052
                        for (action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
1071
1053
                                if (options & LIB_LOAD_VERBOSE)
1072
1054
                                        printf("ActionName: %s\n", action->name+2);
1073
1055
                                scene_merge->GetLogicManager()->RegisterActionName(action->name+2, action);
1078
1060
        return true;
1079
1061
}
1080
1062
 
1081
 
/* Note m_map_*** are all ok and dont need to be freed
 
1063
/* Note m_map_*** are all ok and don't need to be freed
1082
1064
 * most are temp and NewRemoveObject frees m_map_gameobject_to_blender */
1083
1065
bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
1084
1066
{
1085
1067
        int maggie_index= -1;
1086
1068
        int i=0;
1087
1069
 
1088
 
        if(maggie==NULL)
 
1070
        if (maggie==NULL)
1089
1071
                return false;
1090
1072
        
1091
1073
        /* tag all false except the one we remove */
1092
1074
        for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) {
1093
1075
                Main *main= *it;
1094
 
                if(main != maggie) {
 
1076
                if (main != maggie) {
1095
1077
                        tag_main(main, 0);
1096
1078
                }
1097
1079
                else {
1101
1083
        }
1102
1084
 
1103
1085
        /* should never happen but just to be safe */
1104
 
        if(maggie_index == -1)
 
1086
        if (maggie_index == -1)
1105
1087
                return false;
1106
1088
 
1107
1089
        m_DynamicMaggie.erase(m_DynamicMaggie.begin() + maggie_index);
1116
1098
        for (int scene_idx=0;scene_idx<numScenes;scene_idx++)
1117
1099
        {
1118
1100
                KX_Scene* scene = scenes->at(scene_idx);
1119
 
                if(IS_TAGGED(scene->GetBlenderScene())) {
 
1101
                if (IS_TAGGED(scene->GetBlenderScene())) {
1120
1102
                        RemoveScene(scene); // XXX - not tested yet
1121
1103
                        scene_idx--;
1122
1104
                        numScenes--;
1123
1105
                }
1124
1106
                else {
1125
1107
                        
1126
 
                        /* incase the mesh might be refered to later */
 
1108
                        /* in case the mesh might be refered to later */
1127
1109
                        {
1128
1110
                                CTR_Map<STR_HashedString,void*> &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap();
1129
1111
                                
1130
 
                                for(int i=0; i<mapStringToMeshes.size(); i++)
 
1112
                                for (int i=0; i<mapStringToMeshes.size(); i++)
1131
1113
                                {
1132
1114
                                        RAS_MeshObject *meshobj= (RAS_MeshObject *) *mapStringToMeshes.at(i);
1133
 
                                        if(meshobj && IS_TAGGED(meshobj->GetMesh()))
 
1115
                                        if (meshobj && IS_TAGGED(meshobj->GetMesh()))
1134
1116
                                        {       
1135
1117
                                                STR_HashedString mn = meshobj->GetName();
1136
1118
                                                mapStringToMeshes.remove(mn);
1144
1126
                        {
1145
1127
                                CTR_Map<STR_HashedString,void*> &mapStringToActions = scene->GetLogicManager()->GetActionMap();
1146
1128
 
1147
 
                                for(int i=0; i<mapStringToActions.size(); i++)
 
1129
                                for (int i=0; i<mapStringToActions.size(); i++)
1148
1130
                                {
1149
1131
                                        ID *action= (ID*) *mapStringToActions.at(i);
1150
1132
 
1151
 
                                        if(IS_TAGGED(action))
 
1133
                                        if (IS_TAGGED(action))
1152
1134
                                        {
1153
1135
                                                STR_HashedString an = action->name+2;
1154
1136
                                                mapStringToActions.remove(an);
1160
1142
                        //scene->FreeTagged(); /* removed tagged objects and meshes*/
1161
1143
                        CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
1162
1144
 
1163
 
                        for(int ob_ls_idx=0; obj_lists[ob_ls_idx]; ob_ls_idx++)
 
1145
                        for (int ob_ls_idx=0; obj_lists[ob_ls_idx]; ob_ls_idx++)
1164
1146
                        {
1165
1147
                                CListValue *obs= obj_lists[ob_ls_idx];
1166
1148
                                RAS_MeshObject* mesh;
1168
1150
                                for (int ob_idx = 0; ob_idx < obs->GetCount(); ob_idx++)
1169
1151
                                {
1170
1152
                                        KX_GameObject* gameobj = (KX_GameObject*)obs->GetValue(ob_idx);
1171
 
                                        if(IS_TAGGED(gameobj->GetBlenderObject())) {
 
1153
                                        if (IS_TAGGED(gameobj->GetBlenderObject())) {
1172
1154
 
1173
1155
                                                int size_before = obs->GetCount();
1174
1156
 
1176
1158
                                                 * frees m_map_gameobject_to_blender from UnregisterGameObject */
1177
1159
                                                scene->RemoveObject(gameobj);
1178
1160
 
1179
 
                                                if(size_before != obs->GetCount())
 
1161
                                                if (size_before != obs->GetCount())
1180
1162
                                                        ob_idx--;
1181
1163
                                                else {
1182
1164
                                                        printf("ERROR COULD NOT REMOVE \"%s\"\n", gameobj->GetName().ReadPtr());
1187
1169
                                                int mesh_index= gameobj->GetMeshCount();
1188
1170
                                                while(mesh_index--) {
1189
1171
                                                        mesh= gameobj->GetMesh(mesh_index);
1190
 
                                                        if(IS_TAGGED(mesh->GetMesh())) {
 
1172
                                                        if (IS_TAGGED(mesh->GetMesh())) {
1191
1173
                                                                gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */
1192
1174
                                                                break;
1193
1175
                                                        }
1199
1181
                                                        if (gameobj->GetActuators()[act_idx]->IsType(SCA_IActuator::KX_ACT_ACTION))
1200
1182
                                                        {
1201
1183
                                                                BL_ActionActuator *act = (BL_ActionActuator*)gameobj->GetActuators()[act_idx];
1202
 
                                                                if(IS_TAGGED(act->GetAction()))
 
1184
                                                                if (IS_TAGGED(act->GetAction()))
1203
1185
                                                                        act->SetAction(NULL);
1204
1186
                                                        }
1205
1187
                                                }
1214
1196
 
1215
1197
        // delete the entities of this scene
1216
1198
        /* TODO - */
1217
 
        /*
 
1199
#if 0
1218
1200
        vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator worldit;
1219
1201
        size = m_worldinfos.size();
1220
1202
        for (i=0, worldit=m_worldinfos.begin(); i<size; ) {
1227
1209
                        i++;
1228
1210
                        worldit++;
1229
1211
                }
1230
 
        }*/
1231
 
 
1232
 
 
1233
 
        /* Worlds dont reference original blender data so we need to make a set from them */
 
1212
        }
 
1213
#endif
 
1214
 
 
1215
 
 
1216
        /* Worlds don't reference original blender data so we need to make a set from them */
1234
1217
        typedef std::set<KX_WorldInfo*> KX_WorldInfoSet;
1235
1218
        KX_WorldInfoSet worldset;
1236
1219
        for (int scene_idx=0;scene_idx<numScenes;scene_idx++)
1237
1220
        {
1238
1221
                KX_Scene* scene = scenes->at(scene_idx);
1239
 
                if(scene->GetWorldInfo())
 
1222
                if (scene->GetWorldInfo())
1240
1223
                        worldset.insert( scene->GetWorldInfo() );
1241
1224
        }
1242
1225
 
1269
1252
                Material *bmat= NULL;
1270
1253
 
1271
1254
                /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject*)? - Campbell */
1272
 
                if(mat->GetFlag() & RAS_BLENDERMAT) {
 
1255
                if (mat->GetFlag() & RAS_BLENDERMAT) {
1273
1256
                        KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
1274
1257
                        bmat= bl_mat->GetBlenderMaterial();
1275
1258
 
1294
1277
                Material *bmat= NULL;
1295
1278
 
1296
1279
                /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject*)? - Campbell */
1297
 
                if(mat->GetFlag() & RAS_BLENDERMAT) {
 
1280
                if (mat->GetFlag() & RAS_BLENDERMAT) {
1298
1281
                        KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(mat);
1299
1282
                        bmat= bl_mat->GetBlenderMaterial();
1300
1283
 
1303
1286
                        bmat= kx_mat->GetBlenderMaterial();
1304
1287
                }
1305
1288
 
1306
 
                if(bmat) {
 
1289
                if (bmat) {
1307
1290
                        //printf("FOUND MAT '%s' !!! ", ((ID*)bmat)->name+2);
1308
1291
                }
1309
1292
                else {
1418
1401
        /* Find a mesh in the current main */
1419
1402
        ID *me= static_cast<ID *>(BLI_findstring(&m_maggie->mesh, name, offsetof(ID, name) + 2));
1420
1403
        
1421
 
        if(me==NULL) {
 
1404
        if (me==NULL) {
1422
1405
                printf("Could not be found \"%s\"\n", name);
1423
1406
                return NULL;
1424
1407
        }
1425
1408
        
1426
1409
        /* Watch this!, if its used in the original scene can cause big troubles */
1427
 
        if(me->us > 0) {
 
1410
        if (me->us > 0) {
1428
1411
                printf("Mesh has a user \"%s\"\n", name);
1429
1412
                me = (ID*)copy_mesh((Mesh*)me);
1430
1413
                me->us--;
1438
1421
                Mesh *mesh= (Mesh *)me;
1439
1422
                
1440
1423
                /* ensure all materials are tagged */
1441
 
                for(int i=0; i<mesh->totcol; i++)
1442
 
                        if(mesh->mat[i])
 
1424
                for (int i=0; i<mesh->totcol; i++)
 
1425
                        if (mesh->mat[i])
1443
1426
                                mesh->mat[i]->id.flag &= ~LIB_DOIT;
1444
1427
                
1445
 
                for(int i=0; i<mesh->totcol; i++)
 
1428
                for (int i=0; i<mesh->totcol; i++)
1446
1429
                {
1447
1430
                        Material *mat_old= mesh->mat[i];
1448
1431
                        
1449
1432
                        /* if its tagged its a replaced material */
1450
 
                        if(mat_old && (mat_old->id.flag & LIB_DOIT)==0)
 
1433
                        if (mat_old && (mat_old->id.flag & LIB_DOIT)==0)
1451
1434
                        {
1452
1435
                                Material *mat_old= mesh->mat[i];
1453
1436
                                Material *mat_new= copy_material( mat_old );
1461
1444
                                mesh->mat[i]= mat_new;
1462
1445
                                
1463
1446
                                /* the same material may be used twice */
1464
 
                                for(int j=i+1; j<mesh->totcol; j++)
 
1447
                                for (int j=i+1; j<mesh->totcol; j++)
1465
1448
                                {
1466
 
                                        if(mesh->mat[j]==mat_old)
 
1449
                                        if (mesh->mat[j]==mat_old)
1467
1450
                                        {
1468
1451
                                                mesh->mat[j]= mat_new;
1469
1452
                                                mat_new->id.us++;