Collada - add flag to limit precision of exported data, mainly to simplify debugging
authorGaia Clary <gaia.clary@machinimatrix.org>
Mon, 3 Apr 2017 08:48:00 +0000 (10:48 +0200)
committerGaia Clary <gaia.clary@machinimatrix.org>
Mon, 3 Apr 2017 08:48:00 +0000 (10:48 +0200)
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/ControllerExporter.cpp
source/blender/collada/ExportSettings.h
source/blender/collada/collada.cpp
source/blender/collada/collada.h
source/blender/editors/io/io_collada.c
source/blender/makesrna/intern/rna_scene_api.c

index 49722873a91508436aeb0d778c0f34eefc0c8bfc..9348f3b32851bb0efad43f796d1e753bfc6ff3e2 100644 (file)
@@ -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);
 
 }
index 5444c9dfa6b28cb8b09924eaedc38e252aec5ac3..1c2642e831366ac21fdaa4416e7f5ca5b5ab191d 100644 (file)
@@ -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);
                }
        }
index 03e380dc19896b72074a0bdd1f30b9a52f7815c9..de91f68a492d64fdf6675c098d634fbb39d4da86 100644 (file)
@@ -53,6 +53,7 @@ public:
        BC_export_transformation_type export_transformation_type;
 
        bool open_sim;
+       bool limit_precision;
        bool keep_bind_info;
 
        char *filepath;
index bf3fcf0c3f084d2a0a22369269799662cd1203cb..bfe3180909b6c98d014ffa1eecc53a27c5506612 100644 (file)
@@ -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;
index 09acc4a064ba5b6a4017531670df73e8e2d26163..8035af59c8b1b39772018a090699f9c65a413d17 100644 (file)
@@ -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
index b8794afbf859021d5cc5886877d978bfc089f085..139c9817437c875e6a97b80e2694bc8893bffcd0 100644 (file)
@@ -99,6 +99,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
        int export_transformation_type;
 
        int open_sim;
+       int limit_precision;
        int keep_bind_info;
 
        int export_count;
@@ -150,6 +151,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
        export_transformation_type = RNA_enum_get(op->ptr,    "export_transformation_type_selection");
        open_sim                   = RNA_boolean_get(op->ptr, "open_sim");
 
+       limit_precision = RNA_boolean_get(op->ptr, "limit_precision");
        keep_bind_info = RNA_boolean_get(op->ptr, "keep_bind_info");
 
        /* get editmode results */
@@ -178,6 +180,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
                export_transformation_type,
 
                open_sim,
+               limit_precision,
                keep_bind_info
        );
 
@@ -276,9 +279,13 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
 
        row = uiLayoutRow(box, false);
        uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE);
+
        row = uiLayoutRow(box, false);
        uiItemR(row, imfptr, "keep_bind_info", 0, NULL, ICON_NONE);
 
+       row = uiLayoutRow(box, false);
+       uiItemR(row, imfptr, "limit_precision", 0, NULL, ICON_NONE);
+
 }
 
 static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op)
@@ -396,6 +403,9 @@ void WM_OT_collada_export(wmOperatorType *ot)
        RNA_def_boolean(func, "open_sim", 0, "Export to SL/OpenSim",
                        "Compatibility mode for SL, OpenSim and other compatible online worlds");
 
+       RNA_def_boolean(func, "limit_precision", 0,
+               "Limit Precision", "Reduce the precision of the exported data to 6 digits");
+
        RNA_def_boolean(func, "keep_bind_info", 0,
                "Keep Bind Info", "Store Bindpose information in custom bone properties for later use during Collada export");
 
index f3146c9e6a8ffd3a8024db773fc21f6f94f46871..9b202120b824624d8bbade6dfb74aca90d658004 100644 (file)
@@ -285,6 +285,7 @@ static void rna_Scene_collada_export(
         int sort_by_name,
         int export_transformation_type,
         int open_sim,
+        int limit_precision,
         int keep_bind_info)
 {
        collada_export(scene,
@@ -311,6 +312,7 @@ static void rna_Scene_collada_export(
 
                export_transformation_type,
                open_sim,
+               limit_precision,
                keep_bind_info);
 }
 
@@ -422,7 +424,12 @@ void RNA_api_scene(StructRNA *srna)
        RNA_def_boolean(func, "open_sim", false,
                        "Export to SL/OpenSim", "Compatibility mode for SL, OpenSim and other compatible online worlds");
 
-       RNA_def_boolean(func, "keep_bind_info", false, "Keep Bind Info",
+       RNA_def_boolean(func, "limit_precision", false,
+                       "Limit Precision",
+                       "Reduce the precision of the exported data to 6 digits");
+
+       RNA_def_boolean(func, "keep_bind_info", false,
+                       "Keep Bind Info",
                        "Store bind pose information in custom bone properties for later use during Collada export");
 
 #endif