From fd19069999e3655206ccf21dc851801a325dea5d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 14 Jun 2018 15:15:51 +0200 Subject: Cleanup: remove last G.main's from Collada code. --- source/blender/collada/AnimationExporter.cpp | 9 +++--- source/blender/collada/AnimationExporter.h | 3 +- source/blender/collada/ArmatureImporter.cpp | 7 +++-- source/blender/collada/ArmatureImporter.h | 3 +- source/blender/collada/ControllerExporter.cpp | 15 ++++++--- source/blender/collada/ControllerExporter.h | 3 +- source/blender/collada/DocumentExporter.cpp | 7 +++-- source/blender/collada/DocumentImporter.cpp | 44 ++++++++++++++++----------- source/blender/collada/GeometryExporter.cpp | 9 ++++-- source/blender/collada/GeometryExporter.h | 3 +- source/blender/collada/MeshImporter.cpp | 16 ++++++---- source/blender/collada/MeshImporter.h | 3 +- source/blender/collada/SkinInfo.cpp | 4 +-- source/blender/collada/SkinInfo.h | 2 +- source/blender/collada/collada_utils.cpp | 24 ++++++--------- source/blender/collada/collada_utils.h | 10 +++--- 16 files changed, 92 insertions(+), 70 deletions(-) diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index bf371332fd0..48656d15769 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -34,9 +34,10 @@ void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set) } } -bool AnimationExporter::exportAnimations(Scene *sce) +bool AnimationExporter::exportAnimations(Main *bmain, Scene *sce) { bool has_animations = hasAnimations(sce); + m_bmain = bmain; if (has_animations) { this->scene = sce; @@ -214,7 +215,7 @@ void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector< for (std::vector::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime) { float fmat[4][4]; - bc_update_scene(scene, *ctime); + bc_update_scene(m_bmain, scene, *ctime); BKE_object_matrix_local_get(ob, fmat); if (this->export_settings->limit_precision) bc_sanitize_mat(fmat, 6); @@ -246,7 +247,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve float fsize[3]; float feul[3]; - bc_update_scene(scene, *ctime); + bc_update_scene(m_bmain, scene, *ctime); BKE_object_matrix_local_get(ob, fmat); mat4_decompose(floc, fquat, fsize, fmat); quat_to_eul(feul, fquat); @@ -1315,7 +1316,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj float frame = *it; float ctime = BKE_scene_frame_get_from_ctime(scene, frame); - bc_update_scene(scene, ctime); + bc_update_scene(m_bmain, scene, ctime); if (is_bone_animation) { if (pchan->flag & POSE_CHAIN) { enable_fcurves(ob->adt->action, NULL); diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 36968d3edef..b6b67847f4e 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -84,6 +84,7 @@ extern "C" class AnimationExporter: COLLADASW::LibraryAnimations { private: + Main *m_bmain; Scene *scene; COLLADASW::StreamWriter *sw; @@ -96,7 +97,7 @@ public: this->sw = sw; } - bool exportAnimations(Scene *sce); + bool exportAnimations(Main *bmain, Scene *sce); // called for each exported object void operator() (Object *ob); diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 344a73cfa6f..28e962d62c0 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -54,8 +54,9 @@ static const char *bc_get_joint_name(T *node) } -ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Scene *sce, const ImportSettings *import_settings) : +ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Main *bmain, Scene *sce, const ImportSettings *import_settings) : TransformReader(conv), + m_bmain(bmain), scene(sce), unit_converter(conv), import_settings(import_settings), @@ -409,7 +410,7 @@ Object *ArmatureImporter::get_empty_for_leaves() { if (empty) return empty; - empty = bc_add_object(scene, OB_EMPTY, NULL); + empty = bc_add_object(m_bmain, scene, OB_EMPTY, NULL); empty->empty_drawtype = OB_EMPTY_SPHERE; return empty; @@ -584,7 +585,7 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo& skin) ob_arm = skin.set_armature(shared); } else { - ob_arm = skin.create_armature(scene); //once for every armature + ob_arm = skin.create_armature(m_bmain, scene); //once for every armature } // enter armature edit mode diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index b637ec89f8b..a215b186f75 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -62,6 +62,7 @@ extern "C" { class ArmatureImporter : private TransformReader { private: + Main *m_bmain; Scene *scene; UnitConverter *unit_converter; const ImportSettings *import_settings; @@ -137,7 +138,7 @@ private: TagsMap uid_tags_map; public: - ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Scene *sce, const ImportSettings *import_settings); + ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, Main *bmain, Scene *sce, const ImportSettings *import_settings); ~ArmatureImporter(); void add_root_joint(COLLADAFW::Node *node, Object *parent); diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index c89e0f1ec62..5673d33fcbf 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -107,8 +107,9 @@ bool ControllerExporter::add_instance_controller(Object *ob) return true; } -void ControllerExporter::export_controllers(Scene *sce) +void ControllerExporter::export_controllers(Main *bmain, Scene *sce) { + m_bmain = bmain; scene = sce; openLibrary(); @@ -200,7 +201,9 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) bool use_instantiation = this->export_settings->use_object_instantiation; Mesh *me; - me = bc_get_mesh_copy(scene, + me = bc_get_mesh_copy( + m_bmain, + scene, ob, this->export_settings->export_mesh_type, this->export_settings->apply_modifiers, @@ -291,7 +294,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm) add_joints_element(&ob->defbase, joints_source_id, inv_bind_mat_source_id); add_vertex_weights_element(weights_source_id, joints_source_id, vcounts, joints); - BKE_libblock_free_us(G.main, me); + BKE_libblock_free_us(m_bmain, me); closeSkin(); closeController(); @@ -302,7 +305,9 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key) bool use_instantiation = this->export_settings->use_object_instantiation; Mesh *me; - me = bc_get_mesh_copy(scene, + me = bc_get_mesh_copy( + m_bmain, + scene, ob, this->export_settings->export_mesh_type, this->export_settings->apply_modifiers, @@ -327,7 +332,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key) COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, morph_weights_id))); targets.add(); - BKE_libblock_free_us(G.main, me); + BKE_libblock_free_us(m_bmain, me); //support for animations diff --git a/source/blender/collada/ControllerExporter.h b/source/blender/collada/ControllerExporter.h index 80b858ca6dd..2e258c63b6f 100644 --- a/source/blender/collada/ControllerExporter.h +++ b/source/blender/collada/ControllerExporter.h @@ -65,11 +65,12 @@ public: bool add_instance_controller(Object *ob); - void export_controllers(Scene *sce); + void export_controllers(Main *bmain, Scene *sce); void operator()(Object *ob); private: + Main *m_bmain; Scene *scene; UnitConverter converter; const ExportSettings *export_settings; diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index f1838b9dbb6..669faa8358b 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -183,6 +183,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char * int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *eval_ctx, Scene *sce) { + Main *bmain = CTX_data_main(C); PointerRNA sceneptr, unit_settings; PropertyRNA *system; /* unused , *scale; */ @@ -287,7 +288,7 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e // if (bc_has_object_type(export_set, OB_MESH)) { GeometryExporter ge(writer, this->export_settings); - ge.exportGeom(sce); + ge.exportGeom(bmain, sce); } // @@ -295,7 +296,7 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e ControllerExporter controller_exporter(writer, this->export_settings); if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys) { - controller_exporter.export_controllers(sce); + controller_exporter.export_controllers(bmain, sce); } // @@ -305,7 +306,7 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e if (this->export_settings->include_animations) { // AnimationExporter ae(writer, this->export_settings); - ae.exportAnimations(sce); + ae.exportAnimations(bmain, sce); } se.exportScene(C, sce); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 5cbffbe4526..f84cd069778 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -104,8 +104,8 @@ DocumentImporter::DocumentImporter(bContext *C, const ImportSettings *import_set import_settings(import_settings), mImportStage(General), mContext(C), - armature_importer(&unit_converter, &mesh_importer, CTX_data_scene(C), import_settings), - mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)), + armature_importer(&unit_converter, &mesh_importer, CTX_data_main(C), CTX_data_scene(C), import_settings), + mesh_importer(&unit_converter, &armature_importer, CTX_data_main(C), CTX_data_scene(C)), anim_importer(&unit_converter, &armature_importer, CTX_data_scene(C)) { } @@ -266,7 +266,7 @@ void DocumentImporter::finish() Base *base = BKE_scene_base_find(sce, ob); if (base) { BLI_remlink(&sce->base, base); - BKE_libblock_free_us(G.main, base->object); + BKE_libblock_free_us(bmain, base->object); if (sce->basact == base) sce->basact = NULL; MEM_freeN(base); @@ -383,11 +383,12 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera return NULL; } - Object *ob = bc_add_object(sce, OB_CAMERA, NULL); + Main *bmain = CTX_data_main(mContext); + Object *ob = bc_add_object(bmain, sce, OB_CAMERA, NULL); Camera *cam = uid_camera_map[cam_uid]; Camera *old_cam = (Camera *)ob->data; ob->data = cam; - BKE_libblock_free_us(G.main, old_cam); + BKE_libblock_free_us(bmain, old_cam); return ob; } @@ -399,11 +400,12 @@ Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce return NULL; } - Object *ob = bc_add_object(sce, OB_LAMP, NULL); + Main *bmain = CTX_data_main(mContext); + Object *ob = bc_add_object(bmain, sce, OB_LAMP, NULL); Lamp *la = uid_lamp_map[lamp_uid]; Lamp *old_lamp = (Lamp *)ob->data; ob->data = la; - BKE_libblock_free_us(G.main, old_lamp); + BKE_libblock_free_us(bmain, old_lamp); return ob; } @@ -411,7 +413,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod { fprintf(stderr, "create under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL); - Object *obn = BKE_object_copy(G.main, source_ob); + Main *bmain = CTX_data_main(mContext); + Object *obn = BKE_object_copy(bmain, source_ob); DAG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); BKE_scene_base_add(sce, obn); @@ -494,6 +497,7 @@ void DocumentImporter::report_unknown_reference(const COLLADAFW::Node &node, con std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node) { + Main *bmain = CTX_data_main(mContext); Object *ob = NULL; bool is_joint = node->getType() == COLLADAFW::Node::JOINT; bool read_transform = true; @@ -515,7 +519,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA if (parent_node == NULL && !is_library_node) { // A Joint on root level is a skeleton without root node. // Here we add the armature "on the fly": - par = bc_add_object(sce, OB_ARMATURE, std::string("Armature").c_str()); + par = bc_add_object(bmain, sce, OB_ARMATURE, std::string("Armature").c_str()); objects_done->push_back(par); root_objects->push_back(par); object_map.insert(std::pair(node->getUniqueId(), par)); @@ -629,10 +633,10 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) { //Check if Object is armature, by checking if immediate child is a JOINT node. if (is_armature(node)) { - ob = bc_add_object(sce, OB_ARMATURE, name.c_str()); + ob = bc_add_object(bmain, sce, OB_ARMATURE, name.c_str()); } else { - ob = bc_add_object(sce, OB_EMPTY, NULL); + ob = bc_add_object(bmain, sce, OB_EMPTY, NULL); } objects_done->push_back(ob); if (parent_node == NULL) { @@ -649,7 +653,7 @@ std::vector *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA for (std::vector::iterator it = objects_done->begin(); it != objects_done->end(); ++it) { ob = *it; std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId(); - BKE_libblock_rename(G.main, &ob->id, (char *)nodename.c_str()); + BKE_libblock_rename(bmain, &ob->id, (char *)nodename.c_str()); object_map.insert(std::pair(node->getUniqueId(), ob)); node_map[node->getUniqueId()] = node; @@ -759,8 +763,9 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat) if (mImportStage != General) return true; + Main *bmain = CTX_data_main(mContext); const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); - Material *ma = BKE_material_add(G.main, (char *)str_mat_id.c_str()); + Material *ma = BKE_material_add(bmain, (char *)str_mat_id.c_str()); this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; this->uid_material_map[cmat->getUniqueId()] = ma; @@ -782,9 +787,10 @@ MTex *DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::T return NULL; } + Main *bmain = CTX_data_main(mContext); ma->mtex[i] = BKE_texture_mtex_add(); ma->mtex[i]->texco = TEXCO_UV; - ma->mtex[i]->tex = BKE_texture_add(G.main, "Texture"); + ma->mtex[i]->tex = BKE_texture_add(bmain, "Texture"); ma->mtex[i]->tex->type = TEX_IMAGE; ma->mtex[i]->tex->ima = uid_image_map[ima_uid]; @@ -989,14 +995,15 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera) if (mImportStage != General) return true; + Main *bmain = CTX_data_main(mContext); Camera *cam = NULL; std::string cam_id, cam_name; ExtraTags *et=getExtraTags(camera->getUniqueId()); cam_id = camera->getOriginalId(); cam_name = camera->getName(); - if (cam_name.size()) cam = (Camera *)BKE_camera_add(G.main, (char *)cam_name.c_str()); - else cam = (Camera *)BKE_camera_add(G.main, (char *)cam_id.c_str()); + if (cam_name.size()) cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str()); + else cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str()); if (!cam) { fprintf(stderr, "Cannot create camera.\n"); @@ -1151,6 +1158,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) if (mImportStage != General) return true; + Main *bmain = CTX_data_main(mContext); Lamp *lamp = NULL; std::string la_id, la_name; @@ -1163,8 +1171,8 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light) la_id = light->getOriginalId(); la_name = light->getName(); - if (la_name.size()) lamp = (Lamp *)BKE_lamp_add(G.main, (char *)la_name.c_str()); - else lamp = (Lamp *)BKE_lamp_add(G.main, (char *)la_id.c_str()); + if (la_name.size()) lamp = (Lamp *)BKE_lamp_add(bmain, (char *)la_name.c_str()); + else lamp = (Lamp *)BKE_lamp_add(bmain, (char *)la_id.c_str()); if (!lamp) { fprintf(stderr, "Cannot create lamp.\n"); diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 4b693332715..0be3f8cdd2b 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -58,10 +58,11 @@ GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSett { } -void GeometryExporter::exportGeom(Scene *sce) +void GeometryExporter::exportGeom(Main *bmain, Scene *sce) { openLibrary(); + m_bmain = bmain; mScene = sce; GeometryFunctor gf; gf.forEachMeshObjectInExportSet(sce, *this, this->export_settings->export_set); @@ -77,7 +78,9 @@ void GeometryExporter::operator()(Object *ob) #endif bool use_instantiation = this->export_settings->use_object_instantiation; - Mesh *me = bc_get_mesh_copy( mScene, + Mesh *me = bc_get_mesh_copy( + m_bmain, + mScene, ob, this->export_settings->export_mesh_type, this->export_settings->apply_modifiers, @@ -175,7 +178,7 @@ void GeometryExporter::operator()(Object *ob) } } - BKE_libblock_free_us(G.main, me); + BKE_libblock_free_us(m_bmain, me); } diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 8c536721e4b..dea97fc1286 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -72,12 +72,13 @@ class GeometryExporter : COLLADASW::LibraryGeometries Normal n; + Main *m_bmain; Scene *mScene; public: GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings); - void exportGeom(Scene *sce); + void exportGeom(Main *bmain, Scene *sce); void operator()(Object *ob); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 604db646419..d121268d8d9 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -207,7 +207,11 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol) } -MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) { +MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Main *bmain, Scene *sce) : + unitconverter(unitconv), + m_bmain(bmain), + scene(sce), + armature_importer(arm) { } bool MeshImporter::set_poly_indices(MPoly *mpoly, MLoop *mloop, int loop_index, unsigned int *indices, int loop_count) @@ -1077,7 +1081,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri // Attention! This temporaly assigns material to object on purpose! // See note above. ob->actcol=0; - assign_material(G.main, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT); + assign_material(m_bmain, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT); COLLADAFW::TextureCoordinateBindingArray& tex_array = cmaterial.getTextureCoordinateBindingArray(); @@ -1160,7 +1164,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta const char *name = (id.length()) ? id.c_str() : NULL; // add object - Object *ob = bc_add_object(scene, OB_MESH, name); + Object *ob = bc_add_object(m_bmain, scene, OB_MESH, name); bc_set_mark(ob); // used later for material assignement optimization @@ -1172,11 +1176,11 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta Mesh *old_mesh = (Mesh *)ob->data; Mesh *new_mesh = uid_mesh_map[*geom_uid]; - BKE_mesh_assign_object(G.main, ob, new_mesh); + BKE_mesh_assign_object(m_bmain, ob, new_mesh); BKE_mesh_calc_normals(new_mesh); id_us_plus(&old_mesh->id); /* Because BKE_mesh_assign_object would have already decreased it... */ - BKE_libblock_free_us(G.main, old_mesh); + BKE_libblock_free_us(m_bmain, old_mesh); char layername[100]; layername[0] = '\0'; @@ -1219,7 +1223,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom) } const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId(); - Mesh *me = BKE_mesh_add(G.main, (char *)str_geom_id.c_str()); + Mesh *me = BKE_mesh_add(m_bmain, (char *)str_geom_id.c_str()); id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object // store the Mesh pointer to link it later with an Object diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index f0da3cc21cf..23926bf1ce5 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -91,6 +91,7 @@ private: UnitConverter *unitconverter; + Main *m_bmain; Scene *scene; ArmatureImporter *armature_importer; @@ -159,7 +160,7 @@ private: public: - MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce); + MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Main *bmain, Scene *sce); virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid); diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 72d5c656920..b270ac87976 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -159,9 +159,9 @@ void SkinInfo::set_controller(const COLLADAFW::SkinController *co) } // called from write_controller -Object *SkinInfo::create_armature(Scene *scene) +Object *SkinInfo::create_armature(Main *bmain, Scene *scene) { - ob_arm = bc_add_object(scene, OB_ARMATURE, NULL); + ob_arm = bc_add_object(bmain, scene, OB_ARMATURE, NULL); return ob_arm; } diff --git a/source/blender/collada/SkinInfo.h b/source/blender/collada/SkinInfo.h index de88bf32fcf..500ae3878a6 100644 --- a/source/blender/collada/SkinInfo.h +++ b/source/blender/collada/SkinInfo.h @@ -99,7 +99,7 @@ public: void set_controller(const COLLADAFW::SkinController* co); // called from write_controller - Object *create_armature(Scene *scene); + Object *create_armature(Main *bmain, Scene *scene); Object* set_armature(Object *ob_arm); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 8a4e21a5434..b9af19777db 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -133,30 +133,23 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) return true; } -Main *bc_get_main() +EvaluationContext *bc_get_evaluation_context(Main *bmain) { - return G.main; -} - -EvaluationContext *bc_get_evaluation_context() -{ - Main *bmain = G.main; return bmain->eval_ctx; } -void bc_update_scene(Scene *scene, float ctime) +void bc_update_scene(Main *bmain, Scene *scene, float ctime) { BKE_scene_frame_set(scene, ctime); - Main *bmain = bc_get_main(); - EvaluationContext *ev_context = bc_get_evaluation_context(); + EvaluationContext *ev_context = bc_get_evaluation_context(bmain); BKE_scene_update_for_newframe(ev_context, bmain, scene, scene->lay); } -Object *bc_add_object(Scene *scene, int type, const char *name) +Object *bc_add_object(Main *bmain, Scene *scene, int type, const char *name) { - Object *ob = BKE_object_add_only_object(G.main, type, name); + Object *ob = BKE_object_add_only_object(bmain, type, name); - ob->data = BKE_object_obdata_add_from_type(G.main, type, name); + ob->data = BKE_object_obdata_add_from_type(bmain, type, name); ob->lay = scene->lay; DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); @@ -165,7 +158,8 @@ Object *bc_add_object(Scene *scene, int type, const char *name) return ob; } -Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate) +Mesh *bc_get_mesh_copy( + Main *bmain, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate) { Mesh *tmpmesh; CustomDataMask mask = CD_MASK_MESH; @@ -189,7 +183,7 @@ Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh dm = mesh_create_derived((Mesh *)ob->data, NULL); } - tmpmesh = BKE_mesh_add(G.main, "ColladaMesh"); // name is not important here + tmpmesh = BKE_mesh_add(bmain, "ColladaMesh"); // name is not important here DM_to_mesh(dm, tmpmesh, ob, CD_MASK_MESH, true); tmpmesh->flag = mesh->flag; diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h index cbce74485b7..438bb4a0f98 100644 --- a/source/blender/collada/collada_utils.h +++ b/source/blender/collada/collada_utils.h @@ -63,15 +63,15 @@ extern "C" { typedef std::map > TexIndexTextureArrayMap; -extern Main *bc_get_main(); -extern EvaluationContext *bc_get_evaluation_context(); -extern void bc_update_scene(Scene *scene, float ctime); +extern EvaluationContext *bc_get_evaluation_context(Main *bmain); +extern void bc_update_scene(Main *bmain, Scene *scene, float ctime); extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index); extern int bc_test_parent_loop(Object *par, Object *ob); extern int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space = true); -extern Object *bc_add_object(Scene *scene, int type, const char *name); -extern Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate); +extern Object *bc_add_object(Main *bmain, Scene *scene, int type, const char *name); +extern Mesh *bc_get_mesh_copy( + Main *bmain, Scene *scene, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate); extern Object *bc_get_assigned_armature(Object *ob); extern Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob); -- cgit v1.2.3