[Bf-blender-cvs] [3bf0026bec6] master: fix: T50412 - collada: Replaced precision local limit function by blender's own implementation

Gaia Clary noreply at git.blender.org
Sat Apr 1 15:30:00 CEST 2017


Commit: 3bf0026bec6f839ae0f7c40bde845299ce22e8de
Author: Gaia Clary
Date:   Sat Apr 1 15:29:40 2017 +0200
Branches: master
https://developer.blender.org/rB3bf0026bec6f839ae0f7c40bde845299ce22e8de

fix: T50412 - collada: Replaced precision local limit function by blender's own implementation

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

M	source/blender/collada/collada_utils.cpp
M	source/blender/collada/collada_utils.h

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

diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 407f0799014..ac4395e1430 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -32,9 +32,6 @@
 #include "COLLADAFWMeshPrimitive.h"
 #include "COLLADAFWMeshVertexData.h"
 
-#include "collada_utils.h"
-#include "ExportSettings.h"
-
 extern "C" {
 #include "DNA_modifier_types.h"
 #include "DNA_customdata_types.h"
@@ -64,6 +61,9 @@ extern "C" {
 #include "bmesh_tools.h"
 }
 
+#include "collada_utils.h"
+#include "ExportSettings.h"
+
 float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index)
 {
 	if (index >= array.getValuesCount())
@@ -824,23 +824,11 @@ void bc_create_restpose_mat(const ExportSettings *export_settings, Bone *bone, f
 }
 
 /*
-    To get rid of those lengthy float values which make the numbers unreadable.
-*/
-float bc_sanitize_float(float value, float precision)
-{
-	float result = floor((value * pow(10, precision) + 0.5)) / pow(10, precision);
-	if (abs(result) < 1 / pow(10, precision)) {
-		result = 0;
-	}
-	return result;
-}
-
-/*
     Make 4*4 matrices better readable
 */
-void bc_sanitize_mat(float mat[4][4], float precision)
+void bc_sanitize_mat(float mat[4][4], int precision)
 {
 	for (int i = 0; i < 4; i++)
 		for (int j = 0; j < 4; j++)
-			mat[i][j] = bc_sanitize_float(mat[i][j], precision);
+			mat[i][j] = double_round(mat[i][j], precision);
 }
\ No newline at end of file
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index b98f8bfb188..38c0bd5096a 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -97,8 +97,7 @@ extern bool bc_is_leaf_bone(Bone *bone);
 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 float bc_sanitize_float(float value, float precision);
-extern void bc_sanitize_mat(float mat[4][4], float precision);
+extern void bc_sanitize_mat(float 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);




More information about the Bf-blender-cvs mailing list