fix: limit precision also for animation matrixes if the limit option is set (gives...
authorGaia Clary <gaia.clary@machinimatrix.org>
Fri, 16 Feb 2018 15:53:16 +0000 (16:53 +0100)
committerGaia Clary <gaia.clary@machinimatrix.org>
Fri, 16 Feb 2018 15:55:20 +0000 (16:55 +0100)
source/blender/collada/AnimationExporter.cpp
source/blender/collada/collada_utils.cpp
source/blender/collada/collada_utils.h

index d4f434d56fd36f1f9f9456305bf815b8a512c43f..bd5cb05a1faadd31fdc028072a3fc1c178a6b030 100644 (file)
@@ -988,6 +988,9 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
                double outmat[4][4];
                converter.mat4_to_dae_double(outmat, mat);
 
+               if (this->export_settings->limit_precision)
+                       bc_sanitize_mat(outmat, 6);
+
                source.appendValues(outmat);
 
                j++;
index c13757fa2a420264e53d3b087a1bb23d0aaa158c..35bc643d3c7f58e0598af5386cfc164a2fbcec4d 100644 (file)
@@ -864,6 +864,13 @@ void bc_sanitize_mat(float mat[4][4], int precision)
                        mat[i][j] = double_round(mat[i][j], precision);
 }
 
+void bc_sanitize_mat(double mat[4][4], int precision)
+{
+       for (int i = 0; i < 4; i++)
+               for (int j = 0; j < 4; j++)
+                       mat[i][j] = double_round(mat[i][j], precision);
+}
+
 /*
 * Returns name of Active UV Layer or empty String if no active UV Layer defined.
 * Assuming the Object is of type MESH
index ad274777e8dda2bd04b1ddd958794fdd43fb9556..e9066d7db4601fc8a43920bebad0ca05a015dd53 100644 (file)
@@ -100,6 +100,7 @@ extern EditBone *bc_get_edit_bone(bArmature * armature, char *name);
 extern int bc_set_layer(int bitfield, int layer, bool enable);
 extern int bc_set_layer(int bitfield, int layer);
 extern void bc_sanitize_mat(float mat[4][4], int precision);
+extern void bc_sanitize_mat(double mat[4][4], int precision);
 
 extern IDProperty *bc_get_IDProperty(Bone *bone, std::string key);
 extern void bc_set_IDProperty(EditBone *ebone, const char *key, float value);