[Bf-blender-cvs] [eaacdda4f1c] soc-2019-fast-io: [Fast import/export] Bug fixing, added and fixed UI
Hugo Sales
noreply at git.blender.org
Sun Jun 23 16:43:49 CEST 2019
Commit: eaacdda4f1cae4a6c67601a3831b5d3a1f7fe1df
Author: Hugo Sales
Date: Sun Jun 23 15:43:44 2019 +0100
Branches: soc-2019-fast-io
https://developer.blender.org/rBeaacdda4f1cae4a6c67601a3831b5d3a1f7fe1df
[Fast import/export] Bug fixing, added and fixed UI
===================================================================
M release/scripts/modules/obj_export.py
M source/blender/editors/io/intern/obj.cpp
M source/blender/editors/io/intern/stl.cpp
M source/blender/editors/io/io_common.c
M source/blender/editors/io/io_common.h
M source/blender/editors/io/io_obj.c
===================================================================
diff --git a/release/scripts/modules/obj_export.py b/release/scripts/modules/obj_export.py
index 9125aa85c76..a6844975749 100644
--- a/release/scripts/modules/obj_export.py
+++ b/release/scripts/modules/obj_export.py
@@ -24,7 +24,7 @@ import bpy
from mathutils import Matrix, Vector, Color
from bpy_extras import io_utils, node_shader_utils
-def write_mtl(filepath, materials):
+def write_mtl(filepath, materials, path_mode):
C = bpy.context
scene = C.scene
world = scene.world
@@ -33,6 +33,9 @@ def write_mtl(filepath, materials):
source_dir = os.path.dirname(bpy.data.filepath)
dest_dir = os.path.dirname(filepath)
+ # Set of images topotentially copy
+ copy_set = set()
+
with open(filepath, "w", encoding="utf8", newline="\n") as f:
fw = f.write
@@ -106,7 +109,7 @@ def write_mtl(filepath, materials):
continue
filepath = io_utils.path_reference(image.filepath, source_dir, dest_dir,
- 'AUTO', "", None, image.library)
+ path_mode, "", copy_set, image.library)
options = []
if key == "map_Bump":
if mat_wrap.normalmap_strength != 1.0:
@@ -128,3 +131,6 @@ def write_mtl(filepath, materials):
fw('Ks 0.8 0.8 0.8\n') # Specular
fw('d 1\n') # No alpha
fw('illum 2\n') # light normally
+
+ # After closing file
+ io_utils.path_reference_copy(copy_set)
diff --git a/source/blender/editors/io/intern/obj.cpp b/source/blender/editors/io/intern/obj.cpp
index 897d250d1f4..40a3b7f8dfd 100644
--- a/source/blender/editors/io/intern/obj.cpp
+++ b/source/blender/editors/io/intern/obj.cpp
@@ -58,7 +58,7 @@ extern "C" {
axis remap -- doesn't work. Does it need to update, somehow?
DEG_id_tag_update(&mesh->id, 0); obedit->id.recalc & ID_RECALC_ALL
--selection only
- animation - partly
+ --animation
--apply modifiers
--render modifiers -- mesh_create_derived_{view,render}, deg_get_mode
--edges
@@ -66,9 +66,9 @@ extern "C" {
bitflag smooth groups?
--normals
--uvs
- materials
+ --materials
material groups
- path mode -- python repr
+ path mode -- needed?
--triangulate
nurbs
polygroups?
@@ -78,8 +78,6 @@ extern "C" {
--scale
# units?
# removing duplicates with a threshold and as an option
- TODO someone filter_glob : StringProp weird Python syntax
-
*/
namespace {
@@ -144,7 +142,7 @@ bool OBJ_export_materials(bContext *C,
ss << (mat->id.name + 2) << '"';
}
- ss << "])";
+ ss << "], '" << path_reference_mode[settings->path_mode].identifier << "')";
std::cerr << "Running '" << ss.str() << "'\n";
return BPY_execute_string(C, imports, ss.str().c_str());
#else
diff --git a/source/blender/editors/io/intern/stl.cpp b/source/blender/editors/io/intern/stl.cpp
index fc70c93fdbe..3a20be71fb9 100644
--- a/source/blender/editors/io/intern/stl.cpp
+++ b/source/blender/editors/io/intern/stl.cpp
@@ -87,7 +87,7 @@ std::fstream &operator<<(std::fstream &fs, const T &v)
fs.write((char *)&v, size);
}
else {
- char bytes[8], *pv = (char *)&v;
+ char bytes[size], *pv = (char *)&v;
for (int i = 0; i < size; ++i)
bytes[i] = pv[size - 1 - i];
fs.write(bytes, size);
diff --git a/source/blender/editors/io/io_common.c b/source/blender/editors/io/io_common.c
index f1116ce551d..96e9561f478 100644
--- a/source/blender/editors/io/io_common.c
+++ b/source/blender/editors/io/io_common.c
@@ -25,13 +25,25 @@
#include "UI_interface.h"
#include "UI_resources.h"
-const EnumPropertyItem axis_remap[] = {{AXIS_X, "AXIS_X", ICON_NONE, "X axis", ""},
- {AXIS_Y, "AXIS_Y", ICON_NONE, "Y axis", ""},
- {AXIS_Z, "AXIS_Z", ICON_NONE, "Z axis", ""},
- {AXIS_NEG_X, "AXIS_NEG_X", ICON_NONE, "-X axis", ""},
- {AXIS_NEG_Y, "AXIS_NEG_Y", ICON_NONE, "-Y axis", ""},
- {AXIS_NEG_Z, "AXIS_NEG_Z", ICON_NONE, "-Z axis", ""},
- {0, NULL, 0, NULL, NULL}};
+/* clang-format off */
+const EnumPropertyItem axis_remap[] =
+ {{AXIS_X, "AXIS_X", ICON_NONE, "X axis", ""},
+ {AXIS_Y, "AXIS_Y", ICON_NONE, "Y axis", ""},
+ {AXIS_Z, "AXIS_Z", ICON_NONE, "Z axis", ""},
+ {AXIS_NEG_X, "AXIS_NEG_X", ICON_NONE, "-X axis", ""},
+ {AXIS_NEG_Y, "AXIS_NEG_Y", ICON_NONE, "-Y 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}};
+/* clang-format on */
void io_common_default_declare_export(struct wmOperatorType *ot, eFileSel_File_Types file_type)
{
@@ -278,6 +290,13 @@ void io_common_default_declare_export(struct wmOperatorType *ot, eFileSel_File_T
"Up",
"The axis to remap the up axis to");
+ RNA_def_enum(ot->srna,
+ "path_mode",
+ path_reference_mode,
+ AUTO,
+ "Path mode",
+ "How external files referenced (such as images) are treated");
+
/* This dummy prop is used to check whether we need to init the start and
* end frame values to that of the scene's, otherwise they are reset at
* every change, draw update. */
@@ -329,6 +348,7 @@ ExportSettings *io_common_construct_default_export_settings(struct bContext *C,
settings->dedup_uvs_threshold = RNA_float_get(op->ptr, "dedup_uvs_threshold");
settings->export_edges = RNA_boolean_get(op->ptr, "export_edges");
settings->export_materials = RNA_boolean_get(op->ptr, "export_materials");
+ settings->path_mode = RNA_enum_get(op->ptr, "path_mode");
settings->export_vcolors = RNA_boolean_get(op->ptr, "export_vcolors");
settings->export_face_sets = RNA_boolean_get(op->ptr, "export_face_sets");
settings->export_vweights = RNA_boolean_get(op->ptr, "export_vweights");
diff --git a/source/blender/editors/io/io_common.h b/source/blender/editors/io/io_common.h
index f1526d1cd9a..015c4f58676 100644
--- a/source/blender/editors/io/io_common.h
+++ b/source/blender/editors/io/io_common.h
@@ -14,6 +14,11 @@ 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 {
/* Mostly From Alembic */
@@ -43,6 +48,8 @@ typedef struct ExportSettings {
bool flatten_hierarchy;
+ enum path_reference_mode path_mode;
+
bool export_animations;
bool export_normals;
bool dedup_normals;
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index f33419c4e7f..6735a7026dd 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -35,8 +35,8 @@ static void wm_obj_export_draw(bContext *C, wmOperator *op)
/* So we only do this once, use the dummy property */
if (scene != NULL && RNA_boolean_get(&ptr, "init_scene_frame_range")) {
- RNA_int_set(&ptr, "start", SFRA);
- RNA_int_set(&ptr, "end", EFRA);
+ RNA_int_set(&ptr, "start_frame", SFRA);
+ RNA_int_set(&ptr, "end_frame", EFRA);
RNA_boolean_set(&ptr, "init_scene_frame_range", false);
}
@@ -56,17 +56,18 @@ static void wm_obj_export_draw(bContext *C, wmOperator *op)
uiItemR(row, &ptr, "axis_up", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
- uiItemR(row, &ptr, "export_animations", 0, NULL, ICON_NONE);
+ sub_box = uiLayoutBox(row);
+ uiItemR(sub_box, &ptr, "export_animations", 0, NULL, ICON_NONE);
const bool animations = RNA_boolean_get(&ptr, "export_animations");
- row = uiLayoutRow(box, false);
+ row = uiLayoutRow(sub_box, false);
uiLayoutSetEnabled(row, animations);
- uiItemR(row, &ptr, "start", 0, NULL, ICON_NONE);
+ uiItemR(row, &ptr, "start_frame", 0, NULL, ICON_NONE);
- row = uiLayoutRow(box, false);
+ row = uiLayoutRow(sub_box, false);
uiLayoutSetEnabled(row, animations);
- uiItemR(row, &ptr, "end", 0, NULL, ICON_NONE);
+ uiItemR(row, &ptr, "end_frame", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, &ptr, "selected_only", 0, NULL, ICON_NONE);
@@ -123,9 +124,15 @@ static void wm_obj_export_draw(bContext *C, wmOperator *op)
row = uiLayoutRow(box, false);
uiItemR(row, &ptr, "export_edges", 0, NULL, ICON_NONE);
- row = uiLayoutRow(box, false);
+ sub_box = uiLayoutBox(box);
+ row = uiLayoutRow(sub_box, false);
uiItemR(row, &ptr, "export_materials", 0, NULL, ICON_NONE);
+ const bool materials = RNA_boolean_get(&ptr, "export_materials");
+ row = uiLayoutRow(sub_box, false);
+ uiLayoutSetEnabled(row, materials);
+ uiItemR(row, &ptr, "path_mode", 0, NULL, ICON_NONE);
+
row = uiLayoutRow(box, false);
uiItemR(row, &ptr, "export_vcolors", 0, NULL, ICON_NONE);
@@ -133,11 +140,12 @@ static void wm_obj_export_draw(bContext *C, wmOperator *op)
uiItemR(row, &ptr, "export_face_sets", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
- uiItemR(row, &ptr, "apply_modifiers", 0, NULL, ICON_NONE);
+ sub_box = uiLayoutBox(row);
+ uiItemR(sub_box, &ptr, "apply_modifiers", 0, NULL, ICON_NONE);
const bool modifiers = RNA_boolean_get(&ptr, "apply_modifier
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list