[Bf-blender-cvs] [d291d15] master: Fix for T32843

gaiaclary noreply at git.blender.org
Fri Jan 31 09:35:56 CET 2014


Commit: d291d15c193e98ad9fbc05832587bc17a191aa9e
Author: gaiaclary
Date:   Fri Jan 31 09:35:00 2014 +0100
https://developer.blender.org/rBd291d15c193e98ad9fbc05832587bc17a191aa9e

Fix for T32843

Exported angles for spot size animation is in radians , however Collada expects it to be in degrees.
This patch is for fixing import and export, and also renaming a variable

Reviewers: gaiaclary

Reviewed By: gaiaclary

Differential Revision: https://developer.blender.org/D273

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

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

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

diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 7e90f05..61a675d 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -705,7 +705,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
 	}
 }
 
-void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_rotation, float *values, int *length)
+void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values, int *length)
 {
 	switch (semantic) {
 		case COLLADASW::InputSemantic::INPUT:
@@ -714,7 +714,7 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman
 			break;
 		case COLLADASW::InputSemantic::OUTPUT:
 			*length = 1;
-			if (is_rotation) {
+			if (is_angle) {
 				values[0] = RAD2DEGF(bezt->vec[1][1]);
 			}
 			else {
@@ -730,7 +730,7 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman
 				values[0] = 0;
 				values[1] = 0;
 			}
-			else if (is_rotation) {
+			else if (is_angle) {
 				values[1] = RAD2DEGF(bezt->vec[0][1]);
 			}
 			else {
@@ -746,7 +746,7 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman
 				values[0] = 0;
 				values[1] = 0;
 			}
-			else if (is_rotation) {
+			else if (is_angle) {
 				values[1] = RAD2DEGF(bezt->vec[2][1]);
 			}
 			else {
@@ -763,10 +763,10 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti
 {
 	std::string source_id = anim_id + get_semantic_suffix(semantic);
 
-	//bool is_rotation = !strcmp(fcu->rna_path, "rotation");
+	//bool is_angle = !strcmp(fcu->rna_path, "rotation");
 	bool is_angle = false;
 
-	if (strstr(fcu->rna_path, "rotation")) is_angle = true;
+	if (strstr(fcu->rna_path, "rotation") || strstr(fcu->rna_path,"spot_size")) is_angle = true;
 
 	COLLADASW::FloatSourceF source(mSW);
 	source.setId(source_id);
@@ -1196,7 +1196,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
 std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
 {
 	std::string tm_name;
-	bool is_rotation = false;
+	bool is_angle = false;
 	// when given rna_path, determine tm_type from it
 	if (rna_path) {
 		char *name = extract_transform_name(rna_path);
@@ -1228,7 +1228,7 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co
 		case 0:
 		case 1:
 			tm_name = "rotation";
-			is_rotation = true;
+			is_angle = true;
 			break;
 		case 2:
 			tm_name = "scale";
@@ -1258,7 +1258,7 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co
 	}
 
 	if (tm_name.size()) {
-		if (is_rotation)
+		if (is_angle)
 			return tm_name + std::string(axis_name) + ".ANGLE";
 		else
 		if (axis_name[0])
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 6c844cf..5e7338a 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -140,7 +140,7 @@ protected:
 	void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
 	                           COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform);
 	
-	void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_rotation, float *values, int *length);
+	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 );
 
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 445199d..66312f7 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -648,6 +648,12 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
 			//Add the curves of the current animation to the object
 			for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
 				FCurve *fcu = *iter;
+				/* All anim_types whose values are to be converted from Degree to Radians can be ORed here
+				 *XXX What About " rotation " ? */
+				if (BLI_strcaseeq("spot_size", anim_type))	{
+						/* Convert current values to Radians */
+						fcurve_deg_to_rad(fcu);
+				}
 				BLI_addtail(AnimCurves, fcu);
 			}
 		}




More information about the Bf-blender-cvs mailing list