[Bf-blender-cvs] [43e6bb85cee] collada: Merge 'master' into 'collada'

Brecht Van Lommel noreply at git.blender.org
Thu May 2 16:10:50 CEST 2019


Commit: 43e6bb85cee0802887eae9489a2bd73836daf41d
Author: Brecht Van Lommel
Date:   Thu May 2 16:05:23 2019 +0200
Branches: collada
https://developer.blender.org/rB43e6bb85cee0802887eae9489a2bd73836daf41d

Merge 'master' into 'collada'

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



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

diff --cc source/blender/collada/AnimationExporter.cpp
index c9829b1f706,a34f92f66d6..2c9865bcd95
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@@ -237,19 -237,7 +235,19 @@@ void AnimationExporter::export_matrix_a
    }
  }
  
 +BC_global_rotation_type AnimationExporter::get_global_rotation_type(Object *ob)
 +{
 +  bool is_export_root = this->export_settings.is_export_root(ob);
 +  if (!is_export_root) {
 +    return BC_NO_ROTATION;
 +  }
 +
 +  bool apply_global_rotation = this->export_settings.get_apply_global_orientation();
 +
 +  return (apply_global_rotation) ? BC_DATA_ROTATION : BC_OBJECT_ROTATION;
 +}
 +
- //write bone animations in transform matrix sources
+ /* Write bone animations in transform matrix sources. */
  void AnimationExporter::export_bone_animations_recursive(Object *ob,
                                                           Bone *bone,
                                                           BCAnimationSampler &sampler)
@@@ -643,14 -623,11 +644,14 @@@ std::string AnimationExporter::collada_
    return source_id;
  }
  
 -/**
 - * Create a collada matrix source for a set of samples.
 +/*
 + * Create a collada matrix source for a set of samples
- */
+  */
 -std::string AnimationExporter::collada_source_from_values(BCMatrixSampleMap &samples,
 -                                                          const std::string &anim_id)
 +std::string AnimationExporter::collada_source_from_values(
 +    BCMatrixSampleMap &samples,
 +    const std::string &anim_id,
 +    BC_global_rotation_type global_rotation_type,
 +    Matrix &parentinv)
  {
    COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
    std::string source_id = anim_id + get_semantic_suffix(semantic);
@@@ -667,14 -644,12 +668,13 @@@
    source.prepareToAppendValues();
  
    BCMatrixSampleMap::iterator it;
-   int precision = (this->export_settings.get_limit_precision()) ?
-                       6 :
-                       -1;  // could be made configurable
+   /* could be made configurable */
 -  int precision = (this->export_settings->limit_precision) ? 6 : -1;
++  int precision = (this->export_settings.get_limit_precision()) ? 6 : -1;
    for (it = samples.begin(); it != samples.end(); it++) {
 -    const BCMatrix *sample = it->second;
 -    double daemat[4][4];
 -    sample->get_matrix(daemat, true, precision);
 +    BCMatrix sample = BCMatrix(*it->second);
 +    DMatrix daemat;
 +    sample.add_transform(this->export_settings.get_global_transform());
 +    sample.get_matrix(daemat, true, precision);
      source.appendValues(daemat);
    }
  
diff --cc source/blender/collada/ArmatureExporter.cpp
index 90fadd06217,be50b255f13..7d3904647de
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@@ -248,21 -244,9 +250,21 @@@ void ArmatureExporter::add_bone_node(Bo
    }
  }
  
 +bool ArmatureExporter::is_export_root(Bone *bone)
 +{
 +  Bone *entry = bone->parent;
 +  while (entry) {
 +    if (can_export(entry)) {
 +      return false;
 +    }
 +    entry = entry->parent;
 +  }
 +  return can_export(bone);
 +}
 +
  void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node &node)
  {
-   //bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
+   // bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
  
    float mat[4][4];
    float bone_rest_mat[4][4];   /* derived from bone->arm_mat */
diff --cc source/blender/collada/BCSampleData.cpp
index 2571f3e2566,868526928b0..ceb0e07b9eb
--- a/source/blender/collada/BCSampleData.cpp
+++ b/source/blender/collada/BCSampleData.cpp
@@@ -54,51 -53,11 +54,51 @@@ BCMatrix::BCMatrix(Object *ob
    set_transform(ob);
  }
  
 -void BCMatrix::set_transform(Matrix &mat)
 +BCMatrix::BCMatrix()
  {
 -  copy_m4_m4(matrix, mat);
 -  mat4_decompose(this->loc, this->q, this->size, mat);
 -  quat_to_eul(this->rot, this->q);
 +  unit();
 +}
 +
 +BCMatrix::BCMatrix(BC_global_forward_axis global_forward_axis, BC_global_up_axis global_up_axis)
 +{
 +  float mrot[3][3];
 +  float mat[4][4];
 +  mat3_from_axis_conversion(
 +      BC_DEFAULT_FORWARD, BC_DEFAULT_UP, global_forward_axis, global_up_axis, mrot);
 +
-   //transpose_m3(mrot); // Assume that mat3_from_axis_conversion() returns a transposed matrix
++  // transpose_m3(mrot); // Assume that mat3_from_axis_conversion() returns a transposed matrix
 +  copy_m4_m3(mat, mrot);
 +  set_transform(mat);
 +}
 +
 +void BCMatrix::add_transform(const Matrix &mat, bool inverse)
 +{
 +  add_transform(this->matrix, mat, this->matrix, inverse);
 +}
 +
 +void BCMatrix::add_transform(const BCMatrix &mat, bool inverse)
 +{
 +  add_transform(this->matrix, mat.matrix, this->matrix, inverse);
 +}
 +
 +void BCMatrix::add_transform(Matrix &to, const Matrix &transform, const Matrix &from, bool inverse)
 +{
 +  Matrix globinv;
 +  invert_m4_m4(globinv, transform);
 +  if (inverse) {
 +    add_transform(to, globinv, from, /*inverse=*/false);
 +  }
 +  else {
 +    mul_m4_m4m4(to, transform, from);
 +    mul_m4_m4m4(to, to, globinv);
 +  }
 +}
 +
 +void BCMatrix::add_inverted_transform(Matrix &to, const Matrix &transform, const Matrix &from)
 +{
 +  Matrix workmat;
 +  invert_m4_m4(workmat, transform);
 +  mul_m4_m4m4(to, workmat, from);
  }
  
  void BCMatrix::set_transform(Object *ob)
@@@ -174,16 -126,12 +174,14 @@@ void BCMatrix::sanitize(Matrix &mat, in
  
  void BCMatrix::unit()
  {
 -  unit_m4(matrix);
 +  unit_m4(this->matrix);
 +  mat4_decompose(this->loc, this->q, this->size, this->matrix);
 +  quat_to_eul(this->rot, this->q);
  }
  
- /*
- We need double here because the OpenCollada API needs it.
- precision = -1 indicates to not limit the precision
- */
+ /* We need double here because the OpenCollada API needs it.
+  * precision = -1 indicates to not limit the precision. */
 -void BCMatrix::get_matrix(double (&mat)[4][4], const bool transposed, const int precision) const
 +void BCMatrix::get_matrix(DMatrix &mat, const bool transposed, const int precision) const
  {
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++) {
diff --cc source/blender/collada/ControllerExporter.cpp
index d3d431d4cf8,c79a4e1a1f7..4ae185ae684
--- a/source/blender/collada/ControllerExporter.cpp
+++ b/source/blender/collada/ControllerExporter.cpp
@@@ -428,15 -431,9 +431,15 @@@ void ControllerExporter::add_bind_shape
    float f_obmat[4][4];
    BKE_object_matrix_local_get(ob, f_obmat);
  
 +  if (export_settings.get_apply_global_orientation()) {
 +  }
 +  else {
 +    bc_add_global_transform(f_obmat, export_settings.get_global_transform());
 +  }
 +
-   //UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
+   // UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
    UnitConverter::mat4_to_dae_double(bind_mat, f_obmat);
 -  if (this->export_settings->limit_precision)
 +  if (this->export_settings.get_limit_precision())
      bc_sanitize_mat(bind_mat, LIMITTED_PRECISION);
  
    addBindShapeTransform(bind_mat);
@@@ -534,9 -531,9 +537,8 @@@ std::string ControllerExporter::add_inv
          bc_create_restpose_mat(
              this->export_settings, pchan->bone, bind_mat, pchan->bone->arm_mat, true);
  
-         // SL/OPEN_SIM COMPATIBILITY
+         /* SL/OPEN_SIM COMPATIBILITY */
 -        if (export_settings->open_sim) {
 -
 +        if (export_settings.get_open_sim()) {
- 
            float loc[3];
            float rot[3] = {0, 0, 0};
            float scale[3];
@@@ -547,22 -544,12 +549,22 @@@
          }
        }
  
-       // make world-space matrix (bind_mat is armature-space)
+       /* make world-space matrix (bind_mat is armature-space) */
        mul_m4_m4m4(world, ob_arm->obmat, bind_mat);
  
 +      if (export_settings.get_apply_global_orientation()) {
 +        Vector loc;
 +        copy_v3_v3(loc, world[3]);
 +        bc_add_global_transform(loc, export_settings.get_global_transform());
 +        copy_v3_v3(world[3], loc);
 +      }
 +      else {
 +        bc_add_global_transform(world, export_settings.get_global_transform());
 +      }
 +
        invert_m4_m4(mat, world);
        UnitConverter::mat4_to_dae(inv_bind_mat, mat);
 -      if (this->export_settings->limit_precision)
 +      if (this->export_settings.get_limit_precision())
          bc_sanitize_mat(inv_bind_mat, LIMITTED_PRECISION);
        source.appendValues(inv_bind_mat);
      }
diff --cc source/blender/collada/GeometryExporter.cpp
index c26b70a506e,f9279538742..926d85e7fb2
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@@ -396,9 -395,9 +396,9 @@@ void GeometryExporter::create_mesh_prim
        // char *name = CustomData_get_layer_name(&me->ldata, CD_MLOOPUV, i);
        COLLADASW::Input texcoord_input(
            COLLADASW::InputSemantic::TEXCOORD,
 -          makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings->active_uv_only)),
 +          makeUrl(makeTexcoordSourceId(geom_id, i, this->export_settings.get_active_uv_only())),
            2,  // this is only until we have optimized UV sets
-           (this->export_settings.get_active_uv_only()) ? 0 : layer_index - 1  //set (0,1,2,...)
 -          (this->export_settings->active_uv_only) ? 0 : layer_index - 1 /* set (0,1,2,...) */
++          (this->export_settings.get_active_uv_only()) ? 0 : layer_index - 1 /* set (0,1,2,...) */
        );
        til.push_back(texcoord_input);
      }
@@@ -474,17 -473,10 +474,17 @@@ void GeometryExporter::createVertsSourc
    /* main function, it creates <source id = "">, <float_array id = ""
     * count = ""> */
    source.prepareToAppendValues();
-   //appends data to <float_array>
+   /* appends data to <float_array> */
    int i = 0;
    for (i = 0; i < totverts; i++) {
 -    source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
 +    Vector co;
-     //if (export_settings.get_apply_global_orientation()) {
++    // if (export_settings.get_apply_global_orientation()) {
 +    bc_add_global_transform(co, verts[i].co, export_settings.get_global_transform());
 +    //}
-     //else {
++    // else {
 +    //  copy_v3_v3(co, verts[i].co);
 +    //}
 +    source.appe

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list