[Bf-blender-cvs] [0281411b482] master: fix T69772 Collada importer creates wrong fcurves for skeletal animation

Gaia Clary noreply at git.blender.org
Wed Nov 27 11:18:54 CET 2019


Commit: 0281411b482e718922fe446f03caca8c7fadb9a9
Author: Gaia Clary
Date:   Wed Nov 27 11:18:10 2019 +0100
Branches: master
https://developer.blender.org/rB0281411b482e718922fe446f03caca8c7fadb9a9

fix T69772 Collada importer creates wrong fcurves for skeletal animation

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

M	source/blender/collada/AnimationImporter.cpp

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

diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index 9aebde095aa..b17f647bf14 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -513,6 +513,24 @@ void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCur
   }
 }
 
+static int get_animation_axis_index(const COLLADABU::Math::Vector3 &axis)
+{
+  int index;
+  if (COLLADABU::Math::Vector3::UNIT_X == axis) {
+    index = 0;
+  }
+  else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
+    index = 1;
+  }
+  else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
+    index = 2;
+  }
+  else {
+    index = -1;
+  }
+  return index;
+}
+
 /* creates the rna_paths and array indices of fcurves from animations using transformation and
  * bound animation class of each animation. */
 void AnimationImporter::Assign_transform_animations(
@@ -592,30 +610,15 @@ void AnimationImporter::Assign_transform_animations(
       COLLADABU::Math::Vector3 &axis = rot->getRotationAxis();
 
       switch (binding->animationClass) {
-        case COLLADAFW::AnimationList::ANGLE:
-          if (COLLADABU::Math::Vector3::UNIT_X == axis) {
-            modify_fcurve(curves, rna_path, 0);
-          }
-          else if (COLLADABU::Math::Vector3::UNIT_Y == axis) {
-            if (is_joint) {
-              modify_fcurve(curves, rna_path, 2, -1);  // Bone animation from dae to blender
-            }
-            else {
-              modify_fcurve(curves, rna_path, 1);
-            }
-          }
-          else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
-            if (is_joint) {
-              modify_fcurve(curves, rna_path, 1);  // Bone animation from dae to blender
-            }
-            else {
-              modify_fcurve(curves, rna_path, 2);
-            }
+        case COLLADAFW::AnimationList::ANGLE: {
+          int axis_index = get_animation_axis_index(axis);
+          if (axis_index >= 0) {
+            modify_fcurve(curves, rna_path, axis_index);
           }
           else {
             unused_fcurve(curves);
           }
-          break;
+        } break;
         case COLLADAFW::AnimationList::AXISANGLE:
         /* TODO convert axis-angle to quat? or XYZ? */
         default:



More information about the Bf-blender-cvs mailing list