[Bf-blender-cvs] [fd19069999e] master: Cleanup: remove last G.main's from Collada code.
Bastien Montagne
noreply at git.blender.org
Thu Jun 14 15:16:15 CEST 2018
Commit: fd19069999e3655206ccf21dc851801a325dea5d
Author: Bastien Montagne
Date: Thu Jun 14 15:15:51 2018 +0200
Branches: master
https://developer.blender.org/rBfd19069999e3655206ccf21dc851801a325dea5d
Cleanup: remove last G.main's from Collada code.
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
M source/blender/collada/ArmatureImporter.cpp
M source/blender/collada/ArmatureImporter.h
M source/blender/collada/ControllerExporter.cpp
M source/blender/collada/ControllerExporter.h
M source/blender/collada/DocumentExporter.cpp
M source/blender/collada/DocumentImporter.cpp
M source/blender/collada/GeometryExporter.cpp
M source/blender/collada/GeometryExporter.h
M source/blender/collada/MeshImporter.cpp
M source/blender/collada/MeshImporter.h
M source/blender/collada/SkinInfo.cpp
M source/blender/collada/SkinInfo.h
M source/blender/collada/collada_utils.cpp
M source/blender/collada/collada_utils.h
===================================================================
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<float>::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<float> &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
// <library_geometries>
if (bc_has_object_type(export_set, OB_MESH)) {
GeometryExporter ge(writer, this->export_settings);
- ge.exportGeom(sce);
+ ge.exportGeom(bmain, sce);
}
// <library_controllers>
@@ -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);
}
// <library_visual_scenes>
@@ -305,7 +306,7 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e
if (this->export_settings->include_animations) {
// <library_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
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list