[Bf-blender-cvs] [af9ff0f0eef] soc-2019-fast-io: [Fast import/export] UI for OBJ import
Hugo Sales
noreply at git.blender.org
Sun Jul 21 02:37:23 CEST 2019
Commit: af9ff0f0eef5d13effd66116d552beb1d501a62b
Author: Hugo Sales
Date: Mon Jul 15 21:19:33 2019 +0100
Branches: soc-2019-fast-io
https://developer.blender.org/rBaf9ff0f0eef5d13effd66116d552beb1d501a62b
[Fast import/export] UI for OBJ import
===================================================================
M source/blender/editors/io/io_common.c
M source/blender/editors/io/io_common.h
M source/blender/editors/io/io_obj.c
M source/blender/editors/io/io_obj.h
===================================================================
diff --git a/source/blender/editors/io/io_common.c b/source/blender/editors/io/io_common.c
index d3cc6df03af..558d1f2ef81 100644
--- a/source/blender/editors/io/io_common.c
+++ b/source/blender/editors/io/io_common.c
@@ -33,15 +33,6 @@ const EnumPropertyItem axis_remap[] = {{AXIS_X, "AXIS_X", ICON_NONE, "X axis", "
{AXIS_NEG_Z, "AXIS_NEG_Z", ICON_NONE, "-Z axis", ""},
{0, NULL, 0, NULL, NULL}};
-const EnumPropertyItem path_reference_mode[] = {
- {AUTO, "AUTO", ICON_NONE, "Auto", "Use Relative paths with subdirectories only"},
- {ABSOLUTE, "ABSOLUTE", ICON_NONE, "Absolute", "Always write absolute paths"},
- {RELATIVE, "RELATIVE", ICON_NONE, "Relative", "Always write relative paths (where possible)"},
- {MATCH, "MATCH", ICON_NONE, "Match", "Match Absolute/Relative setting with input path"},
- {STRIP, "STRIP", ICON_NONE, "Strip Path", "Filename only"},
- {COPY, "COPY", ICON_NONE, "Copy", "Copy the file to the destination path (or subdirectory)"},
- {0, NULL, 0, NULL, NULL}};
-
void io_common_default_declare_export(struct wmOperatorType *ot, eFileSel_File_Types file_type)
{
// Defines "filepath"
@@ -121,8 +112,20 @@ void io_common_default_declare_export(struct wmOperatorType *ot, eFileSel_File_T
0.0001f,
1000.0f);
}
-void io_common_default_declare_import(struct wmOperatorType *UNUSED(ot))
+void io_common_default_declare_import(struct wmOperatorType *ot)
{
+ RNA_def_enum(ot->srna,
+ "axis_forward",
+ axis_remap,
+ AXIS_NEG_Z, // From orientation helper, not sure why
+ "Forward",
+ "The axis to remap the forward axis to");
+ RNA_def_enum(ot->srna,
+ "axis_up",
+ axis_remap,
+ AXIS_Y, // From orientation helper, not sure why
+ "Up",
+ "The axis to remap the up axis to");
}
ExportSettings *io_common_construct_default_export_settings(struct bContext *C,
diff --git a/source/blender/editors/io/io_common.h b/source/blender/editors/io/io_common.h
index 9f49b5e8f63..31e152b7c95 100644
--- a/source/blender/editors/io/io_common.h
+++ b/source/blender/editors/io/io_common.h
@@ -14,10 +14,7 @@ struct Depsgraph;
enum axis_remap { AXIS_X, AXIS_Y, AXIS_Z, AXIS_NEG_X, AXIS_NEG_Y, AXIS_NEG_Z };
-enum path_reference_mode { AUTO, ABSOLUTE, RELATIVE, MATCH, STRIP, COPY };
-
extern const EnumPropertyItem axis_remap[];
-extern const EnumPropertyItem path_reference_mode[];
typedef struct ExportSettings {
@@ -66,6 +63,13 @@ typedef struct ExportSettings {
} ExportSettings;
+typedef struct ImportSettings {
+ enum axis_remap axis_forward;
+ enum axis_remap axis_up;
+
+ void *format_specific;
+} ImportSettings;
+
void io_common_default_declare_export(struct wmOperatorType *ot, eFileSel_File_Types file_type);
void io_common_default_declare_import(struct wmOperatorType *ot);
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index 2633ef7a1f2..1d9d25bf56d 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -22,6 +22,20 @@
#include "UI_interface.h"
#include "UI_resources.h"
+const EnumPropertyItem path_reference_mode[] = {
+ {AUTO, "AUTO", ICON_NONE, "Auto", "Use Relative paths with subdirectories only"},
+ {ABSOLUTE, "ABSOLUTE", ICON_NONE, "Absolute", "Always write absolute paths"},
+ {RELATIVE, "RELATIVE", ICON_NONE, "Relative", "Always write relative paths (where possible)"},
+ {MATCH, "MATCH", ICON_NONE, "Match", "Match Absolute/Relative setting with input path"},
+ {STRIP, "STRIP", ICON_NONE, "Strip Path", "Filename only"},
+ {COPY, "COPY", ICON_NONE, "Copy", "Copy the file to the destination path (or subdirectory)"},
+ {0, NULL, 0, NULL, NULL}};
+
+const EnumPropertyItem split_mode[] = {
+ {SPLIT_ON, "ON", ICON_NONE, "Split", "Split geometry, omits unused verts"},
+ {SPLIT_OFF, "OFF", ICON_NONE, "Keep Vert Order", "Keep vertex order from file"},
+ {0, NULL, 0, NULL, NULL}};
+
static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
return io_common_export_invoke(C, op, event, ".obj");
@@ -216,19 +230,54 @@ static bool wm_obj_export_check(bContext *C, wmOperator *op)
return io_common_export_check(C, op, ".obj");
}
-static int wm_obj_import_invoke(bContext *UNUSED(C),
- wmOperator *UNUSED(op),
- const wmEvent *UNUSED(event))
+static int wm_obj_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- return OPERATOR_CANCELLED;
+ WM_event_add_fileselect(C, op);
+ return OPERATOR_RUNNING_MODAL;
}
static int wm_obj_import_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
return OPERATOR_CANCELLED;
} /* TODO someone */
-static void wm_obj_import_draw(bContext *UNUSED(C), wmOperator *UNUSED(op))
+static void wm_obj_import_draw(bContext *C, wmOperator *op)
{
- /* TODO someone */
+ PointerRNA ptr;
+ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+
+ uiLayout *box;
+ uiLayout *row;
+
+ row = uiLayoutRow(op->layout, false);
+ uiItemR(row, &ptr, "axis_forward", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(op->layout, false);
+ uiItemR(row, &ptr, "axis_up", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(op->layout, false);
+ uiItemR(row, &ptr, "import_smooth_groups", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(op->layout, false);
+ uiItemR(row, &ptr, "import_edges", 0, NULL, ICON_NONE);
+
+ box = uiLayoutBox(op->layout);
+ row = uiLayoutRow(box, false);
+ uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
+ uiItemR(row, &ptr, "split_mode", 0, NULL, ICON_NONE);
+ /* uiItemEnumR(row, "FOO", ICON_NONE, &ptr, "split_mode", SPLIT_ON); */
+ /* uiItemFullR( */
+ /* row, &ptr, RNA_struct_find_property(op->ptr, "split_mode"), 0, SPLIT_ON, 0, "",
+ * ICON_NONE); */
+
+ row = uiLayoutRow(box, false);
+ const enum split_mode split_mode = RNA_enum_get(&ptr, "split_mode");
+ if (split_mode == SPLIT_ON) {
+ uiItemL(row, IFACE_("Split by:"), ICON_NONE);
+ uiItemR(row, &ptr, "split_by_object", 0, NULL, ICON_NONE);
+ uiItemR(row, &ptr, "split_by_groups", 0, NULL, ICON_NONE);
+ }
+ else {
+ uiItemR(row, &ptr, "import_vertex_groups", 0, NULL, ICON_NONE);
+ }
}
static bool wm_obj_import_check(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
@@ -366,4 +415,40 @@ void WM_OT_obj_import(struct wmOperatorType *ot)
ot->poll = WM_operator_winactive;
ot->ui = wm_obj_import_draw;
ot->check = wm_obj_import_check;
-} /* TODO someone */
+
+ io_common_default_declare_import(ot);
+
+ RNA_def_boolean(ot->srna,
+ "import_smooth_groups",
+ true,
+ "Smooth Groups",
+ "Surround smooth groups by sharp edges");
+
+ RNA_def_boolean(
+ ot->srna, "import_edges", true, "Lines", "Import lines and faces with 2 verts as edge");
+
+ RNA_def_enum(ot->srna,
+ "split_mode",
+ split_mode,
+ SPLIT_ON,
+ "Split Mode",
+ "Whether to split the vertices into objects");
+
+ RNA_def_boolean(
+ ot->srna, "split_by_object", true, "Object", "Import OBJ Objects into Blender Objects");
+
+ RNA_def_boolean(
+ ot->srna, "split_by_groups", false, "Groups", "Import OBJ Groups into Blender Objects");
+
+ RNA_def_boolean(ot->srna,
+ "import_vertex_groups",
+ false,
+ "Vertex Groups",
+ "Import OBJ groups as vertex groups");
+
+ RNA_def_boolean(ot->srna,
+ "use_image_search",
+ false,
+ "Image Search",
+ "Search subdirs for any associated images (Warning: may be slow)");
+}
diff --git a/source/blender/editors/io/io_obj.h b/source/blender/editors/io/io_obj.h
index 395edea6519..2ae9582d28b 100644
--- a/source/blender/editors/io/io_obj.h
+++ b/source/blender/editors/io/io_obj.h
@@ -35,6 +35,12 @@ struct wmOperatorType;
extern "C" {
#endif
+enum path_reference_mode { AUTO, ABSOLUTE, RELATIVE, MATCH, STRIP, COPY };
+enum split_mode { SPLIT_ON, SPLIT_OFF };
+
+extern const EnumPropertyItem path_reference_mode[];
+extern const EnumPropertyItem split_mode[];
+
typedef struct OBJExportSettings {
float start_frame;
float end_frame;
@@ -52,6 +58,16 @@ typedef struct OBJExportSettings {
bool smooth_groups_bitflags;
} OBJExportSettings;
+typedef struct OBJImportSettings {
+ bool import_smooth_groups;
+ bool import_edges;
+ enum split_mode split_mode;
+ bool split_by_object;
+ bool split_by_groups;
+ bool import_vertex_groups;
+ bool use_image_search;
+} OBJImportSettings;
+
void WM_OT_obj_export(struct wmOperatorType *ot);
void WM_OT_obj_import(struct wmOperatorType *ot);
More information about the Bf-blender-cvs
mailing list