[Bf-blender-cvs] [d7a576ef7da] collada: Collada refactor: Added meaningful Constructor for BCAnimationSampler
Gaia Clary
noreply at git.blender.org
Tue Apr 17 22:38:24 CEST 2018
Commit: d7a576ef7dac568097289cd2e63fcb8f81ac62b6
Author: Gaia Clary
Date: Tue Apr 17 17:54:38 2018 +0200
Branches: collada
https://developer.blender.org/rBd7a576ef7dac568097289cd2e63fcb8f81ac62b6
Collada refactor: Added meaningful Constructor for BCAnimationSampler
The processing was unnecessarily split into creating the Sampler
and initialising it later. This can safely be done in one go
within a Sampler constructor
Also removed the not needed reference to the Sampler inside
the AnimationExporter instance. The Sampler is now a simple
local variable in AnimationExporter::exportAnimations()
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
M source/blender/collada/BCAnimationSampler.cpp
M source/blender/collada/BCAnimationSampler.h
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 54099e131ae..009b7c8a160 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -86,15 +86,14 @@ int AnimationExporter::exportAnimations(Scene *sce)
if (has_anim_data) {
this->scene = sce;
- this->animation_sampler = new BCAnimationSampler();
BCObjectSet animated_subset;
BCAnimationSampler::get_animated_from_export_set(animated_subset, export_set);
animation_count = animated_subset.size();
- animation_sampler->add_objects(animated_subset);
+ BCAnimationSampler animation_sampler(animated_subset);
try {
- animation_sampler->sample_scene(scene,
+ animation_sampler.sample_scene(scene,
export_settings->sampling_rate,
/*keyframe_at_end = */ true,
export_settings->open_sim,
@@ -107,7 +106,7 @@ int AnimationExporter::exportAnimations(Scene *sce)
BCObjectSet::iterator it;
for (it = animated_subset.begin(); it != animated_subset.end(); ++it) {
Object *ob = *it;
- exportAnimation(ob, *animation_sampler);
+ exportAnimation(ob, animation_sampler);
}
}
catch (std::invalid_argument &iae)
@@ -116,7 +115,6 @@ int AnimationExporter::exportAnimations(Scene *sce)
fprintf(stderr, "Exception was: %s", iae.what());
}
- delete animation_sampler;
closeLibrary();
#if 0
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 07ecbf456a8..cce0a517092 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -99,7 +99,6 @@ private:
EvaluationContext * eval_ctx;
Scene *scene;
COLLADASW::StreamWriter *sw;
- BCAnimationSampler *animation_sampler;
std::vector<std::vector<std::string>> anim_meta;
diff --git a/source/blender/collada/BCAnimationSampler.cpp b/source/blender/collada/BCAnimationSampler.cpp
index 5976b05d77d..2ae4912892e 100644
--- a/source/blender/collada/BCAnimationSampler.cpp
+++ b/source/blender/collada/BCAnimationSampler.cpp
@@ -50,6 +50,15 @@ extern "C" {
static std::string EMPTY_STRING;
static BCAnimationCurveMap BCEmptyAnimationCurves;
+BCAnimationSampler::BCAnimationSampler(BCObjectSet &object_set)
+{
+ BCObjectSet::iterator it;
+ for (it = object_set.begin(); it != object_set.end(); ++it) {
+ Object *ob = *it;
+ add_object(ob);
+ }
+}
+
BCAnimationSampler::~BCAnimationSampler()
{
BCAnimationObjectMap::iterator it;
@@ -63,15 +72,6 @@ BCAnimationSampler::~BCAnimationSampler()
}
}
-void BCAnimationSampler::add_objects(BCObjectSet &object_set)
-{
- BCObjectSet::iterator it;
- for (it = object_set.begin(); it != object_set.end(); ++it) {
- Object *ob = *it;
- add_object(ob);
- }
-}
-
void BCAnimationSampler::add_object(Object *ob)
{
BCAnimation &animation = objects[ob];
diff --git a/source/blender/collada/BCAnimationSampler.h b/source/blender/collada/BCAnimationSampler.h
index 8a4be8026e4..fdeee22baa4 100644
--- a/source/blender/collada/BCAnimationSampler.h
+++ b/source/blender/collada/BCAnimationSampler.h
@@ -156,10 +156,10 @@ private:
public:
+ BCAnimationSampler(BCObjectSet &animated_subset);
~BCAnimationSampler();
void add_object(Object *ob);
- void add_objects(BCObjectSet &animated_subset);
void sample_scene(Scene *scene,
int sampling_rate,
More information about the Bf-blender-cvs
mailing list