[Bf-blender-cvs] [9f121ce50ab] collada: Cleanup Collada: renamed parameters for better reading

Gaia Clary noreply at git.blender.org
Wed Mar 28 21:30:31 CEST 2018


Commit: 9f121ce50ab506b5b2f058e3283cbbeb3836e0de
Author: Gaia Clary
Date:   Mon Mar 5 02:10:39 2018 +0100
Branches: collada
https://developer.blender.org/rB9f121ce50ab506b5b2f058e3283cbbeb3836e0de

Cleanup Collada: renamed parameters for better reading

I tested and commited each of the documented changes
separately and amended all changes into one single commit:

None of the changes makes a functional change. All changes are
in AnimationExporter.h and AnimationExporter.cpp

* Renamed from transformName to channel_type
* in create_sampled_animation():
  renamed label to channel_type
* in export_sampled_transrotloc_animation()
  in export_sampled_matrix_animation()
  in export_sampled_animation_set()
  in create_sampled_animation():
  Renamed variable from times to frames
* Fixed Indentation in AnimationExporter.h
* break up function definition into multiple lines.

===================================================================

M	source/blender/collada/AnimationExporter.cpp
M	source/blender/collada/AnimationExporter.h

===================================================================

diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 047279f20f2..afb0947f506 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -119,10 +119,10 @@ bool AnimationExporter::is_flat_line(std::vector<float> &values, int channel_cou
  *		 See export_sampled_animation() further down.
  */
 void AnimationExporter::create_sampled_animation(int channel_count,
-	std::vector<float> &times,
+	std::vector<float> &frames,
 	std::vector<float> &values,
 	std::string ob_name,
-	std::string label,
+	std::string channel_type,
 	std::string axis_name,
 	bool is_rot)
 {
@@ -131,21 +131,21 @@ void AnimationExporter::create_sampled_animation(int channel_count,
 	if (is_flat_line(values, channel_count))
 		return;
 
-	BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(), label.c_str(), axis_name.c_str());
+	BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(), channel_type.c_str(), axis_name.c_str());
 
 	openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
 
 	/* create input source */
-	std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, times, false, anim_id, "");
+	std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, frames, false, anim_id, "");
 
 	/* create output source */
 	std::string output_id;
 	if (channel_count == 1)
 		output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, &values[0], values.size(), is_rot, anim_id, axis_name.c_str());
 	else if (channel_count == 3)
-		output_id = create_xyz_source(&values[0], times.size(), anim_id);
+		output_id = create_xyz_source(&values[0], frames.size(), anim_id);
 	else if (channel_count == 16)
-		output_id = create_4x4_source(times, values, anim_id);
+		output_id = create_4x4_source(frames, values, anim_id);
 
 	std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
 	COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
@@ -154,14 +154,14 @@ void AnimationExporter::create_sampled_animation(int channel_count,
 	sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id));
 
 	/* TODO create in/out tangents source (LINEAR) */
-	std::string interpolation_id = fake_interpolation_source(times.size(), anim_id, "");
+	std::string interpolation_id = fake_interpolation_source(frames.size(), anim_id, "");
 
 	/* Create Sampler */
 	sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
 	addSampler(sampler);
 
 	/* Create channel */
-	std::string target = translate_id(ob_name) + "/" + label + axis_name + ((is_rot) ? ".ANGLE" : "");
+	std::string target = translate_id(ob_name) + "/" + channel_type + axis_name + ((is_rot) ? ".ANGLE" : "");
 	addChannel(COLLADABU::URI(empty, sampler_id), target);
 
 	closeAnimation();
@@ -193,10 +193,10 @@ void AnimationExporter::export_keyframed_animation_set(Object *ob)
 
 	if (this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX) {
 
-		std::vector<float> ctimes;
-		find_keyframes(action, ctimes);
-		if (ctimes.size() > 0)
-			export_sampled_matrix_animation(ob, ctimes);
+		std::vector<float> frames;
+		find_keyframes(action, frames);
+		if (frames.size() > 0)
+			export_sampled_matrix_animation(ob, frames);
 	}
 	else {
 		char *channel_type;
@@ -239,26 +239,26 @@ void AnimationExporter::export_sampled_animation_set(Object *ob)
 		return; /* Object has no animation */
 	}
 
-	std::vector<float>ctimes;
-	find_sampleframes(action, ctimes);
-	if (ctimes.size() > 0) {
+	std::vector<float>frames;
+	find_sampleframes(action, frames);
+	if (frames.size() > 0) {
 		if (this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX)
-			export_sampled_matrix_animation(ob, ctimes);
+			export_sampled_matrix_animation(ob, frames);
 		else
-			export_sampled_transrotloc_animation(ob, ctimes);
+			export_sampled_transrotloc_animation(ob, frames);
 	}
 }
 
-void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector<float> &ctimes)
+void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector<float> &frames)
 {
 	UnitConverter converter;
 
 	std::vector<float> values;
 
-	for (std::vector<float>::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime) {
+	for (std::vector<float>::iterator frame = frames.begin(); frame != frames.end(); ++frame) {
 		float fmat[4][4];
 
-		bc_update_scene(scene, *ctime);
+		bc_update_scene(scene, *frame);
 		BKE_object_matrix_local_get(ob, fmat);
 		if (this->export_settings->limit_precision)
 			bc_sanitize_mat(fmat, 6);
@@ -270,10 +270,10 @@ void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector<
 
 	std::string ob_name = id_name(ob);
 
-	create_sampled_animation(16, ctimes, values, ob_name, "transform", "", false);
+	create_sampled_animation(16, frames, values, ob_name, "transform", "", false);
 }
 
-void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::vector<float> &ctimes)
+void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::vector<float> &frames)
 {
 	static int LOC   = 0;
 	static int EULX  = 1;
@@ -283,14 +283,14 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve
 
 	std::vector<float> baked_curves[5];
 
-	for (std::vector<float>::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime ) {
+	for (std::vector<float>::iterator frame = frames.begin(); frame != frames.end(); ++frame) {
 		float fmat[4][4];
 		float floc[3];
 		float fquat[4];
 		float fsize[3];
 		float feul[3];
 
-		bc_update_scene(scene, *ctime);
+		bc_update_scene(scene, *frame);
 		BKE_object_matrix_local_get(ob, fmat);
 		mat4_decompose(floc, fquat, fsize, fmat);
 		quat_to_eul(feul, fquat);
@@ -311,16 +311,16 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve
 
 	std::string ob_name = id_name(ob);
 
-	create_sampled_animation(3, ctimes, baked_curves[SCALE], ob_name, "scale",   "", false);
-	create_sampled_animation(3, ctimes, baked_curves[LOC],  ob_name, "location", "", false);
+	create_sampled_animation(3, frames, baked_curves[SCALE], ob_name, "scale",   "", false);
+	create_sampled_animation(3, frames, baked_curves[LOC],  ob_name, "location", "", false);
 
 	/* Not sure how to export rotation as a 3channel animation, 
 	 * so separate into 3 single animations for now:
 	 */
 
-	create_sampled_animation(1, ctimes, baked_curves[EULX], ob_name, "rotation", "X", true);
-	create_sampled_animation(1, ctimes, baked_curves[EULY], ob_name, "rotation", "Y", true);
-	create_sampled_animation(1, ctimes, baked_curves[EULZ], ob_name, "rotation", "Z", true);
+	create_sampled_animation(1, frames, baked_curves[EULX], ob_name, "rotation", "X", true);
+	create_sampled_animation(1, frames, baked_curves[EULY], ob_name, "rotation", "Y", true);
+	create_sampled_animation(1, frames, baked_curves[EULZ], ob_name, "rotation", "Z", true);
 
 	fprintf(stdout, "Animation Export: Baked %d frames for %s (sampling rate: %d)\n",
 		(int)baked_curves[0].size(),
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 5f594a9255e..6798e18b909 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -134,9 +134,8 @@ protected:
 	// (blend this into dae_bone_animation)
 	void dae_bone_animation(std::vector<float> &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name);
 	
-	void dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone);
-
-	void dae_baked_object_animation(std::vector<float> &fra, Object *ob);
+	void dae_baked_animation(std::vector<float> &frames, Object *ob_arm, Bone *bone);
+	void dae_baked_object_animation(std::vector<float> &frames, Object *ob);
 
 	float convert_time(float frame);
 
@@ -145,8 +144,8 @@ protected:
 	std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic);
 
 	void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
-	                           COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform);
-	
+		COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform);
+
 	void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values, int *length);
 	
 	float* get_eul_source_for_quat(Object *ob );
@@ -155,11 +154,17 @@ protected:
 	bool is_flat_line(std::vector<std::vector<std::vector<double>>> &values);
 
 	void export_keyframed_animation_set(Object *ob);
-	void create_keyframed_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma = NULL);
+	void create_keyframed_animation(Object *ob, FCurve *fcu, char *channel_type, bool is_param, Material *ma = NULL);
 	void export_sampled_animation_set(Object *ob);
-	void export_sampled_transrotloc_animation(Object *ob, std::vector<float> &ctimes);
-	void export_sampled_matrix_animation(Object *ob, std::vector<float> &ctimes);
-	void create_sampled_animation(int channel_count, std::vector<float> &times, std::vector<float> &values, std::string, std::string label, std::string axis_name, bool is_rot);
+	void export_sampled_transrotloc_animation(Object *ob, std::vector<float> &frames);
+	void export_sampled_matrix_animation(Object *ob, std::vector<float> &frames);
+	void create_sampled_animation(int channel_count,
+		std::vector<float> &frames,
+		std::vector<float> &values,
+		std::string ob_name,
+		std::string channel_type,
+		std::string axis_name,
+		bool is_rot);
 
 	void evaluate_anim_with_constraints(Object *ob, float ctime);



More information about the Bf-blender-cvs mailing list