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:
authorAras Pranckevicius <aras@nesnausk.org>2022-05-10 11:34:42 +0300
committerAras Pranckevicius <aras@nesnausk.org>2022-05-10 18:58:10 +0300
commit3bc037a7eb8d214aac9d755f8b2dd0e04cdf3a85 (patch)
tree050b1f21550517efd900e13a12a82b6b5d7cfd42 /source/blender/editors/io/io_obj.c
parent1dd177241908906254527052beb01aa52745b6a8 (diff)
Fix T96399: New 3.1 OBJ exporter is missing Path Mode setting
New OBJ exporter is missing "Path Mode" setting for exporting .mtl files. The options that used to be available were: Auto, Absolute, Relative, Match, Strip Path, Copy. All of them are important. The new behavior (without any UI option to control it) curiously does not match any of the previous setting. New behavior is like "Relative, but to the source blender file, and not the destination export file". Most of the previous logic was only present in Python based code (bpy_extras.io_utils.path_reference and friends). The bulk of this commit is porting that to C++. Reviewed By: Howard Trickey Differential Revision: https://developer.blender.org/D14906
Diffstat (limited to 'source/blender/editors/io/io_obj.c')
-rw-r--r--source/blender/editors/io/io_obj.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index 9156ff15ded..886586ff236 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -29,6 +29,7 @@
#include "DEG_depsgraph.h"
+#include "IO_path_util_types.h"
#include "IO_wavefront_obj.h"
#include "io_obj.h"
@@ -59,6 +60,15 @@ static const EnumPropertyItem io_obj_export_evaluation_mode[] = {
"Export objects as they appear in the viewport"},
{0, NULL, 0, NULL, NULL}};
+static const EnumPropertyItem io_obj_path_mode[] = {
+ {PATH_REFERENCE_AUTO, "AUTO", 0, "Auto", "Use Relative paths with subdirectories only"},
+ {PATH_REFERENCE_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Always write absolute paths"},
+ {PATH_REFERENCE_RELATIVE, "RELATIVE", 0, "Relative", "Write relative paths where possible"},
+ {PATH_REFERENCE_MATCH, "MATCH", 0, "Match", "Match Absolute/Relative setting with input path"},
+ {PATH_REFERENCE_STRIP, "STRIP", 0, "Strip", "Write filename only"},
+ {PATH_REFERENCE_COPY, "COPY", 0, "Copy", "Copy the file to the destination path"},
+ {0, NULL, 0, NULL, NULL}};
+
static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -87,6 +97,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
struct OBJExportParams export_params;
+ export_params.file_base_for_tests[0] = '\0';
RNA_string_get(op->ptr, "filepath", export_params.filepath);
export_params.blen_filepath = CTX_data_main(C)->filepath;
export_params.export_animation = RNA_boolean_get(op->ptr, "export_animation");
@@ -103,6 +114,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv");
export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals");
export_params.export_materials = RNA_boolean_get(op->ptr, "export_materials");
+ export_params.path_mode = RNA_enum_get(op->ptr, "path_mode");
export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, "export_triangulated_mesh");
export_params.export_curves_as_nurbs = RNA_boolean_get(op->ptr, "export_curves_as_nurbs");
@@ -119,9 +131,9 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
{
-
const bool export_animation = RNA_boolean_get(imfptr, "export_animation");
const bool export_smooth_groups = RNA_boolean_get(imfptr, "export_smooth_groups");
+ const bool export_materials = RNA_boolean_get(imfptr, "export_materials");
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
@@ -150,6 +162,9 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "export_selected_objects", 0, IFACE_("Selected Only"), ICON_NONE);
uiItemR(sub, imfptr, "apply_modifiers", 0, IFACE_("Apply Modifiers"), ICON_NONE);
uiItemR(sub, imfptr, "export_eval_mode", 0, IFACE_("Properties"), ICON_NONE);
+ sub = uiLayoutColumn(sub, false);
+ uiLayoutSetEnabled(sub, export_materials);
+ uiItemR(sub, imfptr, "path_mode", 0, IFACE_("Path Mode"), ICON_NONE);
/* Options for what to write. */
box = uiLayoutBox(layout);
@@ -162,6 +177,7 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiItemR(sub, imfptr, "export_triangulated_mesh", 0, IFACE_("Triangulated Mesh"), ICON_NONE);
uiItemR(sub, imfptr, "export_curves_as_nurbs", 0, IFACE_("Curves as NURBS"), ICON_NONE);
+ /* Grouping options. */
box = uiLayoutBox(layout);
uiItemL(box, IFACE_("Grouping"), ICON_GROUP);
col = uiLayoutColumn(box, false);
@@ -322,6 +338,12 @@ void WM_OT_obj_export(struct wmOperatorType *ot)
"Export Materials",
"Export MTL library. There must be a Principled-BSDF node for image textures to "
"be exported to the MTL file");
+ RNA_def_enum(ot->srna,
+ "path_mode",
+ io_obj_path_mode,
+ PATH_REFERENCE_AUTO,
+ "Path Mode",
+ "Method used to reference paths");
RNA_def_boolean(ot->srna,
"export_triangulated_mesh",
false,