From dead26b5778b8bebd642884f11a254edd31c11bc Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Mon, 5 Sep 2022 15:25:34 +0200 Subject: I18n: translate untitled file names When saving, the default file name is "untitled" regardless of selected language. This can be translated, like many graphical applications do. This applies to: - blend file - alembic file - collada file - obj file - usd file - rendered image - grease pencil export - subtitles export - other Python exports through ExportHelper Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15868 --- source/blender/editors/io/io_collada.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/io/io_collada.c') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index c491e7a5815..6a5547021e4 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -43,7 +43,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent * const char *blendfile_path = BKE_main_blendfile_path(bmain); if (blendfile_path[0] == '\0') { - BLI_strncpy(filepath, "untitled", sizeof(filepath)); + BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath)); } else { BLI_strncpy(filepath, blendfile_path, sizeof(filepath)); -- cgit v1.2.3 From 97bd04d665cb8c964e9159da94a3c7941cd4841c Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 7 Sep 2022 11:47:29 +0300 Subject: Fix T100797: C++ exporters do not remember the path on subsequent exports Most/all C++ based IO code had a pattern of doing using RNA_struct_property_is_set to check whether a default path needs to be set. However, it returns false for properties restored from "previous operator settings" (property restoration code sets IDP_FLAG_GHOST flag on them, which "is set" sees and goes "nope, not set"). The fix here is to apply similar logic as 10 years ago in the T32855 fix (rBdb250a4): use RNA_struct_property_is_set_ex instead. Reviewed By: Campbell Barton Differential Revision: https://developer.blender.org/D15904 --- source/blender/editors/io/io_collada.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/io/io_collada.c') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 6a5547021e4..7397138d8c5 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -38,7 +38,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent * { Main *bmain = CTX_data_main(C); - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + if (!RNA_struct_property_is_set_ex(op->ptr, "filepath", false)) { char filepath[FILE_MAX]; const char *blendfile_path = BKE_main_blendfile_path(bmain); @@ -98,7 +98,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; } @@ -709,7 +709,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) int keep_bind_info; 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; } -- cgit v1.2.3 From 13a7516f436597e7f60d0696afa16e8e6d6735fb Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Wed, 7 Sep 2022 13:27:27 +0300 Subject: Cleanup: factor out "set default filepath" into a ED_fileselect_ensure_default_filepath Follow up to D15904, a bunch of places had exact same logic for "is filepath set? if not, set some default one", so factor all that out into a separate ED_fileselect_ensure_default_filepath function. --- source/blender/editors/io/io_collada.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'source/blender/editors/io/io_collada.c') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 7397138d8c5..3da7c00d5e2 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_ex(op->ptr, "filepath", false)) { - char filepath[FILE_MAX]; - const char *blendfile_path = BKE_main_blendfile_path(bmain); - - if (blendfile_path[0] == '\0') { - BLI_strncpy(filepath, DATA_("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); -- cgit v1.2.3 From 22bf5ba4d1526c9e942a2dbd6f25e3932e9d71f2 Mon Sep 17 00:00:00 2001 From: Myron Carey Date: Wed, 14 Sep 2022 15:25:31 +0200 Subject: Fix T49814: Collada Import Ignores Vertex Normals We now import and apply custom normals using a similar strategy to the STL importer. We store custom normal data for each loop as we read each MPoly and then apply it to the mesh after `BKE_mesh_calc_edges()` is called. The new behavior is optional and may be disabled in the Collada import UI. When disabled, we use the old behavior of only using normals to determine whether or not to smooth shade an MPoly. ---- Patch as requested in {T49814}. The Collada import UI now has an additional checkbox, similar to the glTF and FBX import UIs: {F13428264} Here is a test Collada file with a simple test cube with flipped custom normals: {F13428260} {F13428282} And a sphere where the two halves are disconnected geometry, but has custom normals that make the halves appear to be connected: {F13436363} {F13436368} I've tested it on a number of my own meshes, and the custom normals appear to be imported correctly. I'm not too sure about how I've plumbed the option down, though, or whether this is the most proper way to apply custom normals. Reviewed By: gaiaclary Differential Revision: https://developer.blender.org/D15804 --- source/blender/editors/io/io_collada.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/editors/io/io_collada.c') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 3da7c00d5e2..1048d0eca32 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -693,6 +693,7 @@ 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_ex(op->ptr, "filepath", false)) { @@ -702,6 +703,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op) /* 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"); @@ -714,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; @@ -741,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); @@ -791,6 +795,12 @@ void WM_OT_collada_import(wmOperatorType *ot) "If disabled match import to Blender's current Unit settings, " "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, -- cgit v1.2.3 From 25b745ae85ea47675508adb0aa46ccb3cb738e21 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Mon, 10 Oct 2022 16:01:18 +0300 Subject: IO: support Presets in Alembic, Collada, OBJ, STL, USD importers The exporters already had Preset functionality, but the importers did not. --- source/blender/editors/io/io_collada.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/editors/io/io_collada.c') diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 1048d0eca32..a630f150e0e 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -770,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, -- cgit v1.2.3