[Bf-blender-cvs] [7bd7848374f] collada2.8: refactor: Simplify the Collada module. moved Blender context information into its own class.
Gaia Clary
noreply at git.blender.org
Fri Nov 23 00:29:38 CET 2018
Commit: 7bd7848374f9f5d99a62de6ac323ea6a2f053dca
Author: Gaia Clary
Date: Fri Nov 23 00:28:45 2018 +0100
Branches: collada2.8
https://developer.blender.org/rB7bd7848374f9f5d99a62de6ac323ea6a2f053dca
refactor: Simplify the Collada module. moved Blender context information into its own class.
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
M source/blender/collada/ArmatureExporter.cpp
M source/blender/collada/ArmatureExporter.h
M source/blender/collada/BCAnimationSampler.cpp
M source/blender/collada/BCAnimationSampler.h
A source/blender/collada/BlenderContext.cpp
A source/blender/collada/BlenderContext.h
M source/blender/collada/CMakeLists.txt
M source/blender/collada/ControllerExporter.cpp
M source/blender/collada/ControllerExporter.h
M source/blender/collada/DocumentExporter.cpp
M source/blender/collada/DocumentExporter.h
M source/blender/collada/GeometryExporter.cpp
M source/blender/collada/GeometryExporter.h
M source/blender/collada/SceneExporter.cpp
M source/blender/collada/SceneExporter.h
M source/blender/collada/collada.cpp
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 7d11dd7668e..35da4060b9d 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -82,22 +82,22 @@ void AnimationExporter::close_animation_container(bool has_container)
closeAnimation();
}
-bool AnimationExporter::exportAnimations(Main *bmain, Scene *sce)
+bool AnimationExporter::exportAnimations()
{
+ Scene *sce = blender_context.get_scene();
+
LinkNode &export_set = *this->export_settings->export_set;
bool has_anim_data = bc_has_animations(sce, export_set);
int animation_count = 0;
if (has_anim_data) {
- this->scene = sce;
-
BCObjectSet animated_subset;
BCAnimationSampler::get_animated_from_export_set(animated_subset, export_set);
animation_count = animated_subset.size();
- BCAnimationSampler animation_sampler(depsgraph, mContext, animated_subset);
+ BCAnimationSampler animation_sampler(blender_context, animated_subset);
try {
- animation_sampler.sample_scene(scene,
+ animation_sampler.sample_scene(
export_settings->sampling_rate,
/*keyframe_at_end = */ true,
export_settings->open_sim,
@@ -517,6 +517,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
std::string AnimationExporter::collada_tangent_from_curve(COLLADASW::InputSemantic::Semantics semantic, BCAnimationCurve &curve, const std::string& anim_id, std::string axis_name)
{
+ Scene *scene = blender_context.get_scene();
std::string channel = curve.get_channel_target();
const std::string source_id = anim_id + get_semantic_suffix(semantic);
@@ -562,6 +563,7 @@ std::string AnimationExporter::collada_source_from_values(
const std::string& anim_id,
const std::string axis_name)
{
+ Scene *scene = blender_context.get_scene();
/* T can be float, int or double */
int stride = 1;
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index bf3c6cf3305..a5d3780af63 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -96,22 +96,20 @@ typedef enum BC_animation_source_type {
class AnimationExporter: COLLADASW::LibraryAnimations
{
private:
- bContext *mContext;
- Scene *scene;
- Depsgraph *depsgraph;
+ BlenderContext &blender_context;
COLLADASW::StreamWriter *sw;
public:
- AnimationExporter(Depsgraph *depsgraph, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
+ AnimationExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
+ blender_context(blender_context),
COLLADASW::LibraryAnimations(sw),
- depsgraph(depsgraph),
export_settings(export_settings)
{
this->sw = sw;
}
- bool exportAnimations(Main *bmain, Scene *sce);
+ bool exportAnimations();
// called for each exported object
void operator() (Object *ob);
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 417e53a0510..efeca5aec35 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -56,9 +56,8 @@ extern "C" {
// XXX exporter writes wrong data for shared armatures. A separate
// controller should be written for each armature-mesh binding how do
// we make controller ids then?
-ArmatureExporter::ArmatureExporter(bContext *C, Depsgraph *depsgraph, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
- mContext(C),
- depsgraph(depsgraph),
+ArmatureExporter::ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) :
+ blender_context(blender_context),
COLLADASW::LibraryControllers(sw), export_settings(export_settings)
{
}
@@ -83,7 +82,7 @@ void ArmatureExporter::add_armature_bones(
for (Bone *bone = (Bone *)armature->bonebase.first; bone; bone = bone->next) {
// start from root bones
if (!bone->parent) {
- add_bone_node(mContext, depsgraph, view_layer, bone, ob_arm, se, child_objects);
+ add_bone_node(bone, ob_arm, se, child_objects);
}
}
@@ -166,9 +165,6 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
// parent_mat is armature-space
void ArmatureExporter::add_bone_node(
- bContext *C,
- Depsgraph *depsgraph,
- ViewLayer *view_layer,
Bone *bone,
Object *ob_arm,
SceneExporter *se,
@@ -244,7 +240,7 @@ void ArmatureExporter::add_bone_node(
mul_m4_m4m4((*i)->parentinv, temp, (*i)->parentinv);
}
- se->writeNodes(C, depsgraph, view_layer, *i);
+ se->writeNodes(*i);
copy_m4_m4((*i)->parentinv, backup_parinv);
child_objects.erase(i++);
}
@@ -252,13 +248,13 @@ void ArmatureExporter::add_bone_node(
}
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(C, depsgraph, view_layer, child, ob_arm, se, child_objects);
+ add_bone_node(child, ob_arm, se, child_objects);
}
node.end();
}
else {
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
- add_bone_node(C, depsgraph, view_layer, child, ob_arm, se, child_objects);
+ add_bone_node(child, ob_arm, se, child_objects);
}
}
}
diff --git a/source/blender/collada/ArmatureExporter.h b/source/blender/collada/ArmatureExporter.h
index 8654adbc962..977a8b9b4a5 100644
--- a/source/blender/collada/ArmatureExporter.h
+++ b/source/blender/collada/ArmatureExporter.h
@@ -57,7 +57,7 @@ class SceneExporter;
class ArmatureExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
{
public:
- ArmatureExporter(bContext *C, struct Depsgraph *depsgraph, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
+ ArmatureExporter(BlenderContext &blender_context, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
void add_armature_bones(
Object *ob_arm,
@@ -70,8 +70,7 @@ public:
private:
UnitConverter converter;
const ExportSettings *export_settings;
- bContext *mContext;
- struct Depsgraph *depsgraph;
+ BlenderContext &blender_context;
#if 0
std::vector<Object *> written_armatures;
@@ -86,9 +85,6 @@ private:
// Scene, SceneExporter and the list of child_objects
// are required for writing bone parented objects
void add_bone_node(
- bContext *C,
- struct Depsgraph *depsgraph,
- ViewLayer *view_layer,
Bone *bone,
Object *ob_arm,
SceneExporter *se,
diff --git a/source/blender/collada/BCAnimationSampler.cpp b/source/blender/collada/BCAnimationSampler.cpp
index 58a5ba8e387..e73656976ca 100644
--- a/source/blender/collada/BCAnimationSampler.cpp
+++ b/source/blender/collada/BCAnimationSampler.cpp
@@ -50,9 +50,8 @@ extern "C" {
static std::string EMPTY_STRING;
static BCAnimationCurveMap BCEmptyAnimationCurves;
-BCAnimationSampler::BCAnimationSampler(Depsgraph *depsgraph, bContext *C, BCObjectSet &object_set):
- depsgraph(depsgraph),
- mContext(C)
+BCAnimationSampler::BCAnimationSampler(BlenderContext &blender_context, BCObjectSet &object_set):
+ blender_context(blender_context)
{
BCObjectSet::iterator it;
for (it = object_set.begin(); it != object_set.end(); ++it) {
@@ -72,7 +71,7 @@ BCAnimationSampler::~BCAnimationSampler()
void BCAnimationSampler::add_object(Object *ob)
{
- BCAnimation *animation = new BCAnimation(mContext, ob);
+ BCAnimation *animation = new BCAnimation(blender_context.get_context(), ob);
objects[ob] = animation;
initialize_keyframes(animation->frame_set, ob);
@@ -172,13 +171,13 @@ BCSample &BCAnimationSampler::sample_object(Object *ob, int frame_index, bool fo
}
void BCAnimationSampler::sample_scene(
- Scene *scene,
int sampling_rate,
int keyframe_at_end,
bool for_opensim,
bool keep_keyframes,
BC_export_animation_type export_animation_type)
{
+ Scene *scene = blender_context.get_scene();
BCFrameSet scene_sample_frames;
get_sample_frames(scene_sample_frames, sampling_rate, keyframe_at_end, scene);
BCFrameSet::iterator it;
@@ -191,7 +190,7 @@ void BCAnimationSampler::sample_scene(
bool is_scene_sample_frame = false;
bool needs_update = true;
if (scene_sample_frames.find(frame_index) != scene_sample_frames.end()) {
- bc_update_scene(depsgraph, mContext, scene, frame_index);
+ bc_update_scene(blender_context, frame_index);
needs_update = false;
is_scene_sample_frame = true;
}
@@ -209,7 +208,7 @@ void BCAnimationSampler::sample_scene(
if (is_scene_sample_frame || object_keyframes.find(frame_index) != object_keyframes.end()) {
if (needs_update) {
- bc_update_scene(depsgraph, mContext, scene, frame_index);
+ bc_update_scene(blender_context, frame_index);
needs_update = false;
}
diff --git a/source/blender/collada/BCAnimationSampler.h b/source/blender/collada/BCAnimationSampler.h
index c91d9b825b1..4becafb31fc 100644
--- a/source/blender/collada/BCAnimationSampler.h
+++ b/source/blender/collada/BCAnimationSampler.h
@@ -163,8 +163,7 @@ public:
class BCAnimationSampler {
private:
- Depsgraph * depsgraph;
- bContext *mContext;
+ BlenderContext &blender_context;
BCSampleFrameContainer sample_data;
BCAnimationObjectMap objects;
@@ -179,12 +178,12 @@ private:
void check_property_is_animated(BCAnimation &animation, float *ref, float *val, std::string data_path, int length);
public:
- BCAnimationSampler(Depsgraph *depsgraph, bContext *C, BCObjectSet &animated_subset);
+ BCAnimationSampler(BlenderContext &blender_context, BCObjectSet &animated_subset);
~BCAnimationSampler();
void add_object(Object *ob);
- void sample_scene(Scene *scene,
+ void sample_scene(
int sampling_rate,
int keyframe_at_end,
bool for_opensim,
diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/BlenderContext.cpp
similarity index 57%
copy from source/blender/collada/DocumentExporter.h
copy to source/blender/collada/BlenderContext.cpp
index a7174417115..536d517bd6e 100644
--- a/source/blender/collada/DocumentExporter.h
+++ b/source/blender/collada/BlenderContext.cpp
@@ -15,38 +15,47 @@
* along with this program; if not,
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list