From 3bf0026bec6f839ae0f7c40bde845299ce22e8de Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Sat, 1 Apr 2017 15:29:40 +0200 Subject: fix: T50412 - collada: Replaced precision local limit function by blender's own implementation --- source/blender/collada/collada_utils.cpp | 22 +++++----------------- source/blender/collada/collada_utils.h | 3 +-- 2 files changed, 6 insertions(+), 19 deletions(-) (limited to 'source/blender/collada') 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()) @@ -823,24 +823,12 @@ 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); -- cgit v1.2.3 From f65d6ea95458ad53715f09165d37f2486e4750be Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 3 Apr 2017 10:45:24 +0200 Subject: fix: collada - do proper conversion from int to bool (as with other nearby parameters) --- source/blender/collada/collada.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/collada') diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index c0784ca8eb5..bf3fcf0c3f0 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -59,7 +59,7 @@ int collada_import(bContext *C, import_settings.find_chains = find_chains != 0; import_settings.fix_orientation = fix_orientation != 0; import_settings.min_chain_length = min_chain_length; - import_settings.keep_bind_info = keep_bind_info; + import_settings.keep_bind_info = keep_bind_info !=0; DocumentImporter imp(C, &import_settings); if (imp.import()) return 1; -- cgit v1.2.3 From 368b74315a58f66187b924cbc646abd05ce6a2b7 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Mon, 3 Apr 2017 10:48:00 +0200 Subject: Collada - add flag to limit precision of exported data, mainly to simplify debugging --- source/blender/collada/ArmatureExporter.cpp | 4 +++- source/blender/collada/ControllerExporter.cpp | 3 ++- source/blender/collada/ExportSettings.h | 1 + source/blender/collada/collada.cpp | 6 +++--- source/blender/collada/collada.h | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) (limited to 'source/blender/collada') diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 49722873a91..9348f3b3285 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -304,7 +304,9 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: } } - bc_sanitize_mat(mat, 6); // XXX: Make this optional ? + if (this->export_settings->limit_precision) + bc_sanitize_mat(mat, 6); + TransformWriter::add_node_transform(node, mat, NULL); } diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index 5444c9dfa6b..1c2642e8313 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -533,7 +533,8 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas invert_m4_m4(mat, world); converter.mat4_to_dae(inv_bind_mat, mat); - bc_sanitize_mat(inv_bind_mat, 6); // XXX: Make this optional ? + if (this->export_settings->limit_precision) + bc_sanitize_mat(inv_bind_mat, 6); source.appendValues(inv_bind_mat); } } diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 03e380dc198..de91f68a492 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -53,6 +53,7 @@ public: BC_export_transformation_type export_transformation_type; bool open_sim; + bool limit_precision; bool keep_bind_info; char *filepath; diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index bf3fcf0c3f0..bfe3180909b 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -90,7 +90,7 @@ int collada_export(Scene *sce, int sort_by_name, BC_export_transformation_type export_transformation_type, int open_sim, - + int limit_precision, int keep_bind_info) { ExportSettings export_settings; @@ -116,8 +116,8 @@ int collada_export(Scene *sce, export_settings.sort_by_name = sort_by_name != 0; export_settings.export_transformation_type = export_transformation_type; export_settings.open_sim = open_sim != 0; - - export_settings.keep_bind_info = keep_bind_info; + export_settings.limit_precision = limit_precision != 0; + export_settings.keep_bind_info = keep_bind_info !=0; int includeFilter = OB_REL_NONE; if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE; diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 09acc4a064b..8035af59c8b 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -85,6 +85,7 @@ int collada_export(struct Scene *sce, BC_export_transformation_type export_transformation_type, int open_sim, + int limit_precision, int keep_bind_info); #ifdef __cplusplus -- cgit v1.2.3