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
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user