From 8d42c2f3ea4b37c6a538b2b01e4d00f98ca96100 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Sat, 29 Nov 2014 13:24:26 +0100 Subject: Improved Collada Armature Import Collada does not support Bone length. It has only Joints. This patch tries to improve the necessary "guesswork" for importing Rigs. Differential Revision: https://developer.blender.org/D920 --- source/blender/editors/io/io_collada.c | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/io') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index bbf4447dd72..b45f3ccde2a 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -365,6 +365,8 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; int import_units; + int find_chains; + int min_chain_length; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -372,10 +374,15 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) } /* Options panel */ - import_units = RNA_boolean_get(op->ptr, "import_units"); + import_units = RNA_boolean_get(op->ptr, "import_units"); + find_chains = RNA_boolean_get(op->ptr, "find_chains"); + min_chain_length = RNA_int_get(op->ptr, "min_chain_length"); RNA_string_get(op->ptr, "filepath", filename); - if (collada_import(C, filename, import_units)) { + if (collada_import(C, filename, + import_units, + find_chains, + min_chain_length)) { return OPERATOR_FINISHED; } else { @@ -395,6 +402,17 @@ static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr) row = uiLayoutRow(box, false); uiItemR(row, imfptr, "import_units", 0, NULL, ICON_NONE); + + box = uiLayoutBox(layout); + row = uiLayoutRow(box, false); + uiItemL(row, IFACE_("Armature Options:"), ICON_MESH_DATA); + + row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "find_chains", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, false); + uiItemR(row, imfptr, "min_chain_length", 0, NULL, ICON_NONE); + } static void wm_collada_import_draw(bContext *UNUSED(C), wmOperator *op) @@ -423,9 +441,23 @@ void WM_OT_collada_import(wmOperatorType *ot) WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, - "import_units", 0, "Import Units", - "If disabled match import to Blender's current Unit settings, " - "otherwise use the settings from the Imported scene"); + "import_units", 0, "Import Units", + "If disabled match import to Blender's current Unit settings, " + "otherwise use the settings from the Imported scene"); + + RNA_def_boolean(ot->srna, + "find_chains", 0, "Find Bone Chains", + "Find best matching Bone Chains and ensure bones in chain are connected"); + + RNA_def_int(ot->srna, + "min_chain_length", + 0, + 0, + INT_MAX, + "Minimum Chain Length", + "When searching Bone Chains disregard chains of length below this value", + 0, + INT_MAX); } #endif -- cgit v1.2.3