Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-04-03 16:15:56 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-04-03 16:15:56 +0300
commit5884c9f1ba45b8285930508b8ee04279a7b0b387 (patch)
tree11a71aea12aa2e4bf6121f21c041d0da7296928d /source/blender/collada
parent3b6eaf8d96bce59756f669e0c5105ae3bb31bef8 (diff)
parentcc93a66e71a9de09cb41d4433be86e0f056d2b6f (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/ArmatureExporter.cpp4
-rw-r--r--source/blender/collada/ControllerExporter.cpp3
-rw-r--r--source/blender/collada/ExportSettings.h1
-rw-r--r--source/blender/collada/collada.cpp8
-rw-r--r--source/blender/collada/collada.h1
-rw-r--r--source/blender/collada/collada_utils.cpp22
-rw-r--r--source/blender/collada/collada_utils.h3
7 files changed, 17 insertions, 25 deletions
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 c0784ca8eb5..bfe3180909b 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;
@@ -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
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);