[Bf-blender-cvs] [bc055258d5a] master: fix: collada transformtype must be identical for animation export and object export

Gaia Clary noreply at git.blender.org
Mon May 27 16:00:48 CEST 2019


Commit: bc055258d5abdd692003e5ae175d2548183818a4
Author: Gaia Clary
Date:   Mon May 27 15:34:05 2019 +0200
Branches: master
https://developer.blender.org/rBbc055258d5abdd692003e5ae175d2548183818a4

fix: collada transformtype must be identical for animation export and object export

When exporting an object we can choose the transformation type 'Matrix'
or 'trans/rot/scale' When exporting an animation we have the same choice
regarding the used transformation type.

However we must make sure that animations and objects use the same
transformation type within one colleda export. The user interface is
now reworked such that the correct settings are always guaranteed.

I also reworked the tool tips

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

M	source/blender/collada/AnimationExporter.cpp
M	source/blender/collada/ExportSettings.h
M	source/blender/collada/SceneExporter.cpp
M	source/blender/collada/TransformWriter.cpp
M	source/blender/collada/TransformWriter.h
M	source/blender/editors/io/io_collada.c

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

diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index edd74886541..2c6ae8a52f5 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -133,7 +133,7 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
    * Note: For Armatures the skeletal animation has already been exported (see above)
    * However Armatures also can have Object animation.
    */
-  bool export_as_matrix = this->export_settings.get_export_transformation_type() ==
+  bool export_as_matrix = this->export_settings.get_animation_transformation_type() ==
                           BC_TRANSFORMATION_TYPE_MATRIX;
 
   if (export_as_matrix) {
diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h
index 7112aeadb2a..ca118e4d14d 100644
--- a/source/blender/collada/ExportSettings.h
+++ b/source/blender/collada/ExportSettings.h
@@ -81,7 +81,8 @@ typedef struct ExportSettings {
   bool use_object_instantiation;
   bool use_blender_profile;
   bool sort_by_name;
-  BC_export_transformation_type export_transformation_type;
+  BC_export_transformation_type object_transformation_type;
+  BC_export_transformation_type animation_transformation_type;
 
   bool open_sim;
   bool limit_precision;
@@ -232,9 +233,14 @@ class BCExportSettings {
     return export_settings.sort_by_name;
   }
 
-  BC_export_transformation_type get_export_transformation_type()
+  BC_export_transformation_type get_object_transformation_type()
   {
-    return export_settings.export_transformation_type;
+    return export_settings.object_transformation_type;
+  }
+
+  BC_export_transformation_type get_animation_transformation_type()
+  {
+    return export_settings.animation_transformation_type;
   }
 
   bool get_open_sim()
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index 22b2eed79d3..7bf6a145886 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -128,7 +128,7 @@ void SceneExporter::writeNode(Object *ob)
     colladaNode.start();
     if (ob->type == OB_MESH && armature_exported) {
       /* for skinned mesh we write obmat in <bind_shape_matrix> */
-      TransformWriter::add_node_transform_identity(colladaNode);
+      TransformWriter::add_node_transform_identity(colladaNode, this->export_settings);
     }
     else {
       TransformWriter::add_node_transform_ob(colladaNode, ob, this->export_settings);
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 965338a9fd8..fbf75552b85 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -30,11 +30,8 @@ void TransformWriter::add_joint_transform(COLLADASW::Node &node,
                                          float parent_mat[4][4],
                                          BCExportSettings &export_settings,
                                          bool has_restmat
-
 	)
 {
-  // bool limit_precision = export_settings.limit_precision;
-  float loc[3], rot[3], scale[3];
   float local[4][4];
 
   if (parent_mat) {
@@ -55,14 +52,11 @@ void TransformWriter::add_joint_transform(COLLADASW::Node &node,
   converter->mat4_to_dae_double(dmat, local);
   delete converter;
 
-  if (node.getType() == COLLADASW::Node::JOINT) {
-    // XXX Why are joints handled differently ?
-	// GC: I believe this is a mistake. Here we might want to 
-	// export according to how the transformation type
-	// is set, see add_node_transform_ob()
+  if (export_settings.get_object_transformation_type() == BC_TRANSFORMATION_TYPE_MATRIX) {
     node.addMatrix("transform", dmat);
   }
   else {
+    float loc[3], rot[3], scale[3];
     bc_decompose(local, loc, rot, NULL, scale);
     add_transform(node, loc, rot, scale);
   }
@@ -73,7 +67,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
                                             BCExportSettings &export_settings)
 {
   BC_export_transformation_type transformation_type =
-      export_settings.get_export_transformation_type();
+      export_settings.get_object_transformation_type();
   bool limit_precision = export_settings.get_limit_precision();
 
   /* Export the local Matrix (relative to the object parent,
@@ -112,10 +106,28 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
   }
 }
 
-void TransformWriter::add_node_transform_identity(COLLADASW::Node &node)
+void TransformWriter::add_node_transform_identity(
+	COLLADASW::Node &node,
+	BCExportSettings &export_settings)
 {
-  float loc[3] = {0.0f, 0.0f, 0.0f}, scale[3] = {1.0f, 1.0f, 1.0f}, rot[3] = {0.0f, 0.0f, 0.0f};
-  add_transform(node, loc, rot, scale);
+  BC_export_transformation_type transformation_type =
+      export_settings.get_object_transformation_type();
+  switch (transformation_type) {
+    case BC_TRANSFORMATION_TYPE_MATRIX: {
+      BCMatrix mat;
+      DMatrix d_obmat;
+      mat.get_matrix(d_obmat);
+      node.addMatrix("transform", d_obmat);
+      break;
+    }
+    default: {
+      float loc[3] = {0.0f, 0.0f, 0.0f};
+      float scale[3] = {1.0f, 1.0f, 1.0f};
+      float rot[3] = {0.0f, 0.0f, 0.0f};
+      add_transform(node, loc, rot, scale);
+      break;
+    }
+  }
 }
 
 void TransformWriter::add_transform(COLLADASW::Node &node,
diff --git a/source/blender/collada/TransformWriter.h b/source/blender/collada/TransformWriter.h
index e12c2053594..f0bfbaabbc2 100644
--- a/source/blender/collada/TransformWriter.h
+++ b/source/blender/collada/TransformWriter.h
@@ -39,7 +39,7 @@ class TransformWriter {
 
   void add_node_transform_ob(COLLADASW::Node &node, Object *ob, BCExportSettings &export_settings);
 
-  void add_node_transform_identity(COLLADASW::Node &node);
+  void add_node_transform_identity(COLLADASW::Node &node, BCExportSettings &export_settings);
 
  private:
   void add_transform(COLLADASW::Node &node, float loc[3], float rot[3], float scale[3]);
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 7d9ce65473e..fc3bf74f386 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -106,7 +106,8 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
   int use_object_instantiation;
   int use_blender_profile;
   int sort_by_name;
-  int export_transformation_type;
+  int export_object_transformation_type;
+  int export_animation_transformation_type;
 
   int open_sim;
   int limit_precision;
@@ -170,9 +171,13 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
   use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation");
   use_blender_profile = RNA_boolean_get(op->ptr, "use_blender_profile");
   sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name");
-  export_transformation_type = RNA_enum_get(op->ptr, "export_transformation_type_selection");
-  open_sim = RNA_boolean_get(op->ptr, "open_sim");
 
+  export_object_transformation_type = RNA_enum_get(
+    op->ptr, "export_object_transformation_type_selection");
+  export_animation_transformation_type = RNA_enum_get(
+    op->ptr, "export_animation_transformation_type_selection");
+
+  open_sim = RNA_boolean_get(op->ptr, "open_sim");
   limit_precision = RNA_boolean_get(op->ptr, "limit_precision");
   keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info");
 
@@ -192,7 +197,6 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
   export_settings.global_up = global_up;
   export_settings.apply_global_orientation = apply_global_orientation != 0;
 
-  export_settings.export_mesh_type = export_mesh_type;
   export_settings.export_mesh_type = export_mesh_type;
   export_settings.selected = selected != 0;
   export_settings.include_children = include_children != 0;
@@ -213,23 +217,24 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
   export_settings.use_object_instantiation = use_object_instantiation != 0;
   export_settings.use_blender_profile = use_blender_profile != 0;
   export_settings.sort_by_name = sort_by_name != 0;
+  export_settings.object_transformation_type = export_object_transformation_type;
+  export_settings.animation_transformation_type = export_animation_transformation_type;
+  export_settings.keep_smooth_curves = keep_smooth_curves != 0;
 
-  if (export_animation_type == BC_ANIMATION_EXPORT_SAMPLES) {
-    export_settings.export_transformation_type = export_transformation_type;
-  }
-  else {
+  if (export_animation_type != BC_ANIMATION_EXPORT_SAMPLES) {
     // When curves are exported then we can not export as matrix
-    export_settings.export_transformation_type = BC_TRANSFORMATION_TYPE_TRANSROTLOC;
+    export_settings.animation_transformation_type = BC_TRANSFORMATION_TYPE_TRANSROTLOC;
   }
 
-  if (export_settings.export_transformation_type == BC_TRANSFORMATION_TYPE_TRANSROTLOC) {
-    export_settings.keep_smooth_curves = keep_smooth_curves != 0;
-  }
-  else {
+  if (export_settings.animation_transformation_type != BC_TRANSFORMATION_TYPE_TRANSROTLOC) {
     // Can not export smooth curves when Matrix export is enabled.
     export_settings.keep_smooth_curves = false;
   }
 
+  if (include_animations) {
+    export_settings.object_transformation_type = export_settings.animation_transformation_type;
+  }
+
   export_settings.open_sim = open_sim != 0;
   export_settings.limit_precision = limit_precision != 0;
   export_settings.keep_bind_info = keep_bind_info != 0;
@@ -266,10 +271,11 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
   bool include_animations = RNA_boolean_get(imfptr, "include_animations");
   int ui_section = RNA_enum_get(imfptr, "prop_bc_export_ui_section");
 
-  BC_export_animation_type animation_type = RNA_enum_get(imfptr,
-                                                         "export_animation_type_selection");
-  BC_export_transformation_type transformation_type = RNA_enum_get(
-      imfptr, "export_transformation_type_selection");
+  BC_export_animation_type animation_type = RNA_enum_get(
+    imfptr, "export_animation_type_selection");
+
+  BC_export_t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list