[Bf-blender-cvs] [ccf0fea00bc] collada: Refactor Collada: use BCKeyPoint to construct the exported FCurves
Gaia Clary
noreply at git.blender.org
Thu Apr 19 18:56:36 CEST 2018
Commit: ccf0fea00bca1598251e98b1dee10ded5702fa96
Author: Gaia Clary
Date: Thu Apr 19 18:49:32 2018 +0200
Branches: collada
https://developer.blender.org/rBccf0fea00bca1598251e98b1dee10ded5702fa96
Refactor Collada: use BCKeyPoint to construct the exported FCurves
Before the handles where taken from the FCurves. But this caused
odd behavior when exporting Object hierarhcies with parent_inverse
matrices. Then the handles where calculated wrong. Now there wil be no
handles for those cases. (we might still consider to optionally
generate handles here (to be decided)
===================================================================
M source/blender/collada/AnimationExporter.cpp
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 0e67dfca6fb..34f7df12eae 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -379,7 +379,7 @@ void AnimationExporter::export_collada_curve_animation(
std::string name,
std::string collada_target,
std::string axis,
- const BCAnimationCurve &curve)
+ BCAnimationCurve &curve)
{
BCFrames frames;
BCValues values;
@@ -404,8 +404,8 @@ void AnimationExporter::export_collada_curve_animation(
std::string intangent_id;
std::string outtangent_id;
if (has_tangents) {
- intangent_id = collada_tangent_from_curve(COLLADASW::InputSemantic::IN_TANGENT, curve, frames, id, axis);
- outtangent_id = collada_tangent_from_curve(COLLADASW::InputSemantic::OUT_TANGENT, curve, frames, id, axis);
+ intangent_id = collada_tangent_from_curve(COLLADASW::InputSemantic::IN_TANGENT, curve, id, axis);
+ outtangent_id = collada_tangent_from_curve(COLLADASW::InputSemantic::OUT_TANGENT, curve, id, axis);
}
std::string sampler_id = std::string(id) + SAMPLER_ID_SUFFIX;
@@ -554,7 +554,7 @@ int AnimationExporter::get_point_in_curve(BCBezTriple &bezt, COLLADASW::InputSem
return length;
}
-std::string AnimationExporter::collada_tangent_from_curve(COLLADASW::InputSemantic::Semantics semantic, const BCAnimationCurve &curve, std::vector<float>frames, const std::string& anim_id, std::string axis_name)
+std::string AnimationExporter::collada_tangent_from_curve(COLLADASW::InputSemantic::Semantics semantic, BCAnimationCurve &curve, const std::string& anim_id, std::string axis_name)
{
std::string channel = curve.get_channel_target();
@@ -574,26 +574,36 @@ std::string AnimationExporter::collada_tangent_from_curve(COLLADASW::InputSemant
source.prepareToAppendValues();
- std::vector<float> values;
- curve.get_sampled_values(values);
+ BCValueMap &value_map = curve.get_value_map();
+ BCValueMap::iterator it;
+ for (it = value_map.begin(); it != value_map.end(); ++it) {
+
+ int frame_index = it->first;
+ BCKeyPoint &point = it->second;
+ float sampled_time;
+ float sampled_val;
- const FCurve *fcu = curve.get_fcurve(); // need this to get the original tangents
+ if (point.has_handles()) {
- for (unsigned int frame_index = 0; frame_index < values.size(); frame_index++) {
- float sampled_val = values[frame_index];
+ if (semantic == COLLADASW::InputSemantic::IN_TANGENT) {
+ sampled_val = point.get_in_tangent()[1];
+ sampled_time = point.get_in_tangent()[0];
+ }
+ else {
+ sampled_val = point.get_out_tangent()[1];
+ sampled_time = point.get_out_tangent()[0];
+ }
+ }
+ else {
+ sampled_val = point.get_value();
+ sampled_time = point.get_frame();
+ }
if (is_angle) {
sampled_val = RAD2DEGF(sampled_val);
}
- float vals[3]; // be careful!
- int length = get_point_in_curve(curve, frames[frame_index], semantic, is_angle, vals);
- float offset = 0;
- float bases[3];
- int len = get_point_in_curve(curve, frames[frame_index], COLLADASW::InputSemantic::OUTPUT, is_angle, bases);
- sampled_val += vals[1] - bases[0];
-
- source.appendValues(vals[0]);
+ source.appendValues(FRA2TIME(sampled_time));
source.appendValues(sampled_val);
}
More information about the Bf-blender-cvs
mailing list