diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2022-10-30 00:41:21 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2022-10-30 01:14:59 +0300 |
commit | bc37e8d8399eef686b71341aa90eced9bc117786 (patch) | |
tree | 92e4af388150209df9bc44e2cba6f2f303aa7baf /source/blender/editors/io/io_collada.c | |
parent | 552abb838c76d44a0d7d1226b59a1ab381e88386 (diff) | |
parent | d1d2f002c7caaf4ab457ec27bbc44666d7aac624 (diff) |
Merge remote-tracking branch 'origin/master' into principled-v2
Diffstat (limited to 'source/blender/editors/io/io_collada.c')
-rw-r--r-- | source/blender/editors/io/io_collada.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index c491e7a5815..a630f150e0e 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -19,6 +19,7 @@ # include "DEG_depsgraph.h" +# include "ED_fileselect.h" # include "ED_object.h" # include "RNA_access.h" @@ -36,22 +37,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { - Main *bmain = CTX_data_main(C); - - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - char filepath[FILE_MAX]; - const char *blendfile_path = BKE_main_blendfile_path(bmain); - - if (blendfile_path[0] == '\0') { - BLI_strncpy(filepath, "untitled", sizeof(filepath)); - } - else { - BLI_strncpy(filepath, blendfile_path, sizeof(filepath)); - } - - BLI_path_extension_replace(filepath, sizeof(filepath), ".dae"); - RNA_string_set(op->ptr, "filepath", filepath); - } + ED_fileselect_ensure_default_filepath(C, op, ".dae"); WM_event_add_fileselect(C, op); @@ -98,7 +84,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) int export_count; int sample_animations; - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } @@ -707,15 +693,17 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) int min_chain_length; int keep_bind_info; + int custom_normals; ImportSettings import_settings; - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } /* Options panel */ import_units = RNA_boolean_get(op->ptr, "import_units"); + custom_normals = RNA_boolean_get(op->ptr, "custom_normals"); find_chains = RNA_boolean_get(op->ptr, "find_chains"); auto_connect = RNA_boolean_get(op->ptr, "auto_connect"); fix_orientation = RNA_boolean_get(op->ptr, "fix_orientation"); @@ -728,6 +716,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) import_settings.filepath = filename; import_settings.import_units = import_units != 0; + import_settings.custom_normals = custom_normals != 0; import_settings.auto_connect = auto_connect != 0; import_settings.find_chains = find_chains != 0; import_settings.fix_orientation = fix_orientation != 0; @@ -755,6 +744,7 @@ static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr) uiItemL(box, IFACE_("Import Data Options"), ICON_MESH_DATA); uiItemR(box, imfptr, "import_units", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "custom_normals", 0, NULL, ICON_NONE); box = uiLayoutBox(layout); uiItemL(box, IFACE_("Armature Options"), ICON_ARMATURE_DATA); @@ -780,14 +770,12 @@ void WM_OT_collada_import(wmOperatorType *ot) ot->name = "Import COLLADA"; ot->description = "Load a Collada file"; ot->idname = "WM_OT_collada_import"; - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_PRESET; ot->invoke = WM_operator_filesel; ot->exec = wm_collada_import_exec; ot->poll = WM_operator_winactive; - // ot->flag = OPTYPE_PRESET; - ot->ui = wm_collada_import_draw; WM_operator_properties_filesel(ot, @@ -806,6 +794,12 @@ void WM_OT_collada_import(wmOperatorType *ot) "otherwise use the settings from the Imported scene"); RNA_def_boolean(ot->srna, + "custom_normals", + 1, + "Custom Normals", + "Import custom normals, if available (otherwise Blender will compute them)"); + + RNA_def_boolean(ot->srna, "fix_orientation", 0, "Fix Leaf Bones", |