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:
authorJulian Eisel <julian@blender.org>2022-05-07 00:03:36 +0300
committerYimingWu <xp8110@outlook.com>2022-05-10 08:58:20 +0300
commit3911ae0e03f38c1b729d7010ab3422273317df56 (patch)
tree9d906126718f9e0a80b2caa101afb768fa393374
parent433d493d1ae028c921b34bb53ca71866cb34d41e (diff)
Fix T97751: New OBJ IO - File Browser doesn't filter by .obj/.mtl
Makes the File Browser filter by .obj and .mtl files by default again. Note that this commit focuses on fixing this specific bug, further refactors/tweaks/fixes are planned (see D14863). Differential Revision: https://developer.blender.org/D14862 Reviewed by: Aras Pranckevicius
-rw-r--r--source/blender/editors/io/io_obj.c16
-rw-r--r--source/blender/editors/space_file/filelist.c3
2 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index 3345d422bd1..9156ff15ded 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -231,6 +231,8 @@ static bool wm_obj_export_check(bContext *C, wmOperator *op)
void WM_OT_obj_export(struct wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
ot->name = "Export Wavefront OBJ";
ot->description = "Save the scene to a Wavefront OBJ file";
ot->idname = "WM_OT_obj_export";
@@ -244,7 +246,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot)
ot->flag |= OPTYPE_PRESET;
WM_operator_properties_filesel(ot,
- FILE_TYPE_FOLDER | FILE_TYPE_OBJECT_IO,
+ FILE_TYPE_FOLDER,
FILE_BLENDER,
FILE_SAVE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
@@ -358,6 +360,10 @@ void WM_OT_obj_export(struct wmOperatorType *ot)
"Every smooth-shaded face is assigned group \"1\" and every flat-shaded face \"off\"");
RNA_def_boolean(
ot->srna, "smooth_group_bitflags", false, "Generate Bitflags for Smooth Groups", "");
+
+ /* Only show .obj or .mtl files by default. */
+ prop = RNA_def_string(ot->srna, "filter_glob", "*.obj;*.mtl", 0, "Extension Filter", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
}
static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@@ -415,6 +421,8 @@ static void wm_obj_import_draw(bContext *C, wmOperator *op)
void WM_OT_obj_import(struct wmOperatorType *ot)
{
+ PropertyRNA *prop;
+
ot->name = "Import Wavefront OBJ";
ot->description = "Load a Wavefront OBJ scene";
ot->idname = "WM_OT_obj_import";
@@ -425,7 +433,7 @@ void WM_OT_obj_import(struct wmOperatorType *ot)
ot->ui = wm_obj_import_draw;
WM_operator_properties_filesel(ot,
- FILE_TYPE_FOLDER | FILE_TYPE_OBJECT_IO,
+ FILE_TYPE_FOLDER,
FILE_BLENDER,
FILE_OPENFILE,
WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS,
@@ -453,4 +461,8 @@ void WM_OT_obj_import(struct wmOperatorType *ot)
false,
"Validate Meshes",
"Check imported mesh objects for invalid data (slow)");
+
+ /* Only show .obj or .mtl files by default. */
+ prop = RNA_def_string(ot->srna, "filter_glob", "*.obj;*.mtl", 0, "Extension Filter", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN);
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 9f71d6f77c7..59ecef7d4c6 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -2802,7 +2802,8 @@ int ED_path_extension_type(const char *path)
if (BLI_path_extension_check(path, ".zip")) {
return FILE_TYPE_ARCHIVE;
}
- if (BLI_path_extension_check_n(path, ".obj", ".3ds", ".fbx", ".glb", ".gltf", ".svg", NULL)) {
+ if (BLI_path_extension_check_n(
+ path, ".obj", ".mtl", ".3ds", ".fbx", ".glb", ".gltf", ".svg", NULL)) {
return FILE_TYPE_OBJECT_IO;
}
if (BLI_path_extension_check_array(path, imb_ext_image)) {