[Bf-blender-cvs] [945936277b0] collada: Refactor: Collada: Renamed BCMatrix to BCSample
Gaia Clary
noreply at git.blender.org
Wed Mar 28 21:31:08 CEST 2018
Commit: 945936277b06554e132c5a5d2bc3f97e86ebdaae
Author: Gaia Clary
Date: Fri Mar 23 20:57:49 2018 +0100
Branches: collada
https://developer.blender.org/rB945936277b06554e132c5a5d2bc3f97e86ebdaae
Refactor: Collada: Renamed BCMatrix to BCSample
Since the BCSample Objects will contain either
Matrix data for Object animation or other
data for Lamp, Material, and Camera animation.
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
M source/blender/collada/BCAnimationCurveContainer.cpp
M source/blender/collada/BCAnimationCurveContainer.h
M source/blender/collada/BCSampleData.cpp
M source/blender/collada/BCSampleData.h
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index ec28b9d7127..66bd3703857 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -248,7 +248,7 @@ void AnimationExporter::exportObjectAnimation(Object *ob, BCAnimationSampler &sa
*/
void AnimationExporter::export_curve_animation_set(Object *ob, BCAnimationSampler &sampler)
{
- BCMatrixMap matrices;
+ BCSampleMap matrices;
BCAnimationCurveMap curves;
sampler.get_curves(curves, ob);
@@ -282,7 +282,7 @@ void AnimationExporter::export_matrix_animation_set(Object *ob, BCAnimationSampl
std::vector<float> frames;
sampler.get_frame_set(frames, ob);
if (frames.size() > 0) {
- BCMatrixMap outmats;
+ BCSampleMap outmats;
bool is_flat = sampler.get_matrix_set(outmats, ob);
if (!is_flat) {
export_matrix_animation(ob, frames, outmats, sampler); // there is just one curve to export here
@@ -293,7 +293,7 @@ void AnimationExporter::export_matrix_animation_set(Object *ob, BCAnimationSampl
void AnimationExporter::export_matrix_animation(
Object *ob,
BCFrames &frames,
- BCMatrixMap &outmats,
+ BCSampleMap &outmats,
BCAnimationSampler &sampler)
{
bAction *action = bc_getSceneObjectAction(ob);
@@ -315,7 +315,7 @@ void AnimationExporter::export_bone_animation_recursive(Object *ob, Bone *bone,
sampler.get_frame_set(frames, ob, bone);
if (frames.size()) {
- BCMatrixMap outmats;
+ BCSampleMap outmats;
bool is_flat = sampler.get_matrix_set(outmats, ob, bone);
if (!is_flat) {
export_bone_animation(ob, bone, frames, outmats);
@@ -434,7 +434,7 @@ void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurv
export_collada_curve_animation(id, curve_name, target, axis, curve);
}
-void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &frames, BCMatrixMap &outmats)
+void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &frames, BCSampleMap &outmats)
{
bAction* action = bc_getSceneObjectAction(ob);
std::string bone_name(bone->name);
@@ -513,7 +513,7 @@ void AnimationExporter::export_collada_curve_animation(
closeAnimation();
}
-void AnimationExporter::export_collada_matrix_animation(std::string id, std::string name, std::string target, BCFrames &frames, BCMatrixMap &outmats)
+void AnimationExporter::export_collada_matrix_animation(std::string id, std::string name, std::string target, BCFrames &frames, BCSampleMap &outmats)
{
fprintf(stdout, "Export animation matrix %s (%d control points)\n", id.c_str(), int(frames.size()));
@@ -815,7 +815,7 @@ std::string AnimationExporter::create_source_from_values(COLLADASW::InputSemanti
/*
* Create a collada matrix source for a set of matrix entries
*/
-std::string AnimationExporter::create_4x4_source_from_values(BCMatrixMap &matrices, const std::string &anim_id)
+std::string AnimationExporter::create_4x4_source_from_values(BCSampleMap &matrices, const std::string &anim_id)
{
COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
std::string source_id = anim_id + get_semantic_suffix(semantic);
@@ -831,11 +831,11 @@ std::string AnimationExporter::create_4x4_source_from_values(BCMatrixMap &matric
source.prepareToAppendValues();
- BCMatrixMap::iterator it;
+ BCSampleMap::iterator it;
int j = 0;
int precision = (this->export_settings->limit_precision) ? 6 : -1; // could be made configurable
for (it = matrices.begin(); it != matrices.end(); it++) {
- const BCMatrix *matrix = it->second;
+ const BCSample *matrix = it->second;
double daemat[4][4];
matrix->get_matrix(daemat, true, precision );
source.appendValues(daemat);
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index f94a9a172a8..572c54997ce 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -134,7 +134,7 @@ protected:
void export_matrix_animation (
Object *ob,
BCFrames &frames,
- BCMatrixMap &outmats,
+ BCSampleMap &outmats,
BCAnimationSampler &sampler);
void export_bone_animation_recursive(
@@ -146,14 +146,14 @@ protected:
Object *ob,
Bone *bone,
BCFrames &frames,
- BCMatrixMap &outmats);
+ BCSampleMap &outmats);
void export_collada_matrix_animation(
std::string id,
std::string name,
std::string target,
BCFrames &frames,
- BCMatrixMap &outmats);
+ BCSampleMap &outmats);
/* Helper functions */
void openAnimationWithClip(std::string id, std::string name);
@@ -162,7 +162,7 @@ protected:
std::string create_source_from_values(COLLADASW::InputSemantic::Semantics semantic, std::vector<float> &values, bool is_rot, const std::string& anim_id, const std::string axis_name);
std::string create_4x4_source_from_values(
- BCMatrixMap &cache,
+ BCSampleMap &cache,
const std::string& anim_id);
std::string create_linear_interpolation_source(int tot, const std::string& anim_id);
diff --git a/source/blender/collada/BCAnimationCurveContainer.cpp b/source/blender/collada/BCAnimationCurveContainer.cpp
index 11cdf23486f..13584795a7c 100644
--- a/source/blender/collada/BCAnimationCurveContainer.cpp
+++ b/source/blender/collada/BCAnimationCurveContainer.cpp
@@ -43,7 +43,7 @@ extern "C" {
static std::string EMPTY_STRING;
static BCAnimationCurveMap BCEmptyAnimationCurves;
-static const BCMatrix UNIT_MATRIX;
+static const BCSample UNIT_SAMPLE;
/*
BCAnimationSampler
@@ -300,7 +300,7 @@ void BCAnimationSampler::sample_scene(
float mat[4][4];
BKE_object_matrix_local_get(ob, mat);
- BCMatrix ob_mat(mat);
+ BCSample ob_mat(mat);
sample_data.add(ob, ob_mat, frame_index);
if (ob->type == OB_ARMATURE) {
@@ -308,7 +308,7 @@ void BCAnimationSampler::sample_scene(
for (pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
Bone *bone = pchan->bone;
if (bone_matrix_local_get(ob, bone, mat, for_opensim)) {
- BCMatrix bone_mat(mat);
+ BCSample bone_mat(mat);
sample_data.add(ob, bone, bone_mat, frame_index);
}
}
@@ -341,17 +341,17 @@ void BCAnimationSampler::sample_scene(
}
-bool BCAnimationSampler::is_flat_line(BCMatrixMap &values) const
+bool BCAnimationSampler::is_flat_line(BCSampleMap &values) const
{
static float MIN_DISTANCE = 0.00001;
if (values.size() < 2)
return true; // need at least 2 entries to be not flat
- BCMatrixMap::iterator it;
- const BCMatrix *refmat = nullptr;
+ BCSampleMap::iterator it;
+ const BCSample *refmat = nullptr;
for (it = values.begin(); it != values.end(); ++it) {
- const BCMatrix *matrix = it->second;
+ const BCSample *matrix = it->second;
if (refmat == nullptr) {
refmat = matrix;
@@ -386,14 +386,14 @@ void BCAnimationSampler::get_frame_set(BCFrames &frames, Object *ob, const BCAni
curve.get_sampled_frames(frames);
}
-bool BCAnimationSampler::get_matrix_set(BCMatrixMap &matrices, Object *ob, Bone *bone)
+bool BCAnimationSampler::get_matrix_set(BCSampleMap &matrices, Object *ob, Bone *bone)
{
const BCSampleKey key(ob, bone);
sample_data.get_matrices(key, matrices);
return is_flat_line(matrices);
}
-bool BCAnimationSampler::get_matrix_set(BCMatrixMap &matrices, Object *ob)
+bool BCAnimationSampler::get_matrix_set(BCSampleMap &matrices, Object *ob)
{
const BCSampleKey key(ob);
sample_data.get_matrices(key, matrices);
@@ -407,19 +407,19 @@ bool BCAnimationSampler::get_matrix_set(BCMatrixMap &matrices, Object *ob)
BCAnimationSampler is removed (by its destructor)
*/
void BCAnimationSampler::add_value_set(
- BCMatrixMap &matrices,
+ BCSampleMap &matrices,
BCAnimationCurve &curve,
BC_export_animation_type animation_type)
{
int array_index = curve.get_array_index();
std::string target = curve.get_channel_target();
- BCMatrixMap::iterator it;
+ BCSampleMap::iterator it;
for (it = matrices.begin(); it != matrices.end(); ++it) {
const int frame_index = it->first;
if (animation_type == BC_ANIMATION_TYPE_SAMPLE || curve.is_keyframe(frame_index)) {
- const BCMatrix *matrix = it->second;
+ const BCSample *matrix = it->second;
float val = 0;
bool good = matrix->get_value_for(target, array_index, &val);
@@ -538,36 +538,36 @@ void BCAnimationSampler::get_curves(BCAnimationCurveMap &curves, Object *ob)
/* ==================================================================== */
-void BCSampleFrame::add(Object *ob, BCMatrix &matrix)
+void BCSampleFrame::add(Object *ob, BCSample &matrix)
{
sampleMap[BCSampleKey(ob)] = matrix;
}
/* Add a new Bone to this map with the given Matrix*/
-void BCSampleFrame::add(Object *ob, Bone *bone, BCMatrix &matrix)
+void BCSampleFrame::add(Object *ob, Bone *bone, BCSample &matrix)
{
sampleMap[BCSampleKey(ob, bone)] = matrix;
}
/* Get the matrix for the given key, returns Unity when the key does not exist */
-const BCMatrix &BCSampleFrame::get_sample(const BCSampleKey key) const
+const BCSample &BCSampleFrame::get_sample(const BCSampleKey key) const
{
BCSamplesMap::const_iterator it = sampleMap.find(key);
if (it == sampleMap.end()) {
- return UNIT_MATRIX;
+ return UNIT_SAMPLE;
}
return it->second;
}
/* Get the matrix for the given Object, returns Unity when the Objewct is not sampled */
-const BCMatrix &BCSampleFrame::get_sample(Object *ob) const
+const BCSample &BCSampleFrame::get_sample(Object *ob) const
{
const BCSampleKey key(ob);
return get_sample(key);
}
/* Get the matrix for the given Bone, returns Unity when the Objewct is not sampled */
-const BCMatrix &BCSampleFrame::get_sample(Object *ob, Bone *bone) const
+const BCSample &BCSampleFrame::get_sample(Object *ob, Bone *bone) const
{
const BCSampleKey key(ob, bone);
return get_sample(key);
@@ -602,7 +602,7 @@ const BCSamplesMap &BCSampleFrame::get_samples() const
/* ==================================================================== */
/* Add object for frame. Creates a new BCSampleFrame if it does not yet exist */
-BCSampleFrame &BCSampleFrames::add(Object *ob, BCMatrix &matrix, int frame_index)
+BCSampleFrame &BCSampleFrames::add
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list