Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-05-22 23:06:56 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-05-22 23:06:56 +0300
commit7d4c4744b1134af469f8ef6d95c6a3781eed50e3 (patch)
tree256610af123b85abe65ea8d46312a68325a16a71
parent5a7cd7d9b3f7f284ef54be27291d876a999bf48f (diff)
FBX export: do not embed a same file more than once!
-rw-r--r--io_scene_fbx/export_fbx_bin.py23
-rw-r--r--io_scene_fbx/fbx_utils.py2
2 files changed, 17 insertions, 8 deletions
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index 076fc1d7..98ac6cac 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1347,6 +1347,8 @@ def fbx_data_video_elements(root, vid, scene_data):
"""
Write the actual image data block.
"""
+ msetts = scene_data.settings.media_settings
+
vid_key, _texs = scene_data.data_videos[vid]
fname_abs, fname_rel = _gen_vid_path(vid, scene_data)
@@ -1368,15 +1370,21 @@ def fbx_data_video_elements(root, vid, scene_data):
if scene_data.settings.media_settings.embed_textures:
if vid.packed_file is not None:
- elem_data_single_bytes(fbx_vid, b"Content", vid.packed_file.data)
+ # We only ever embed a given file once!
+ if fname_abs not in msetts.embedded_set:
+ elem_data_single_bytes(fbx_vid, b"Content", vid.packed_file.data)
+ msetts.embedded_set.add(fname_abs)
else:
filepath = bpy.path.abspath(vid.filepath)
- try:
- with open(filepath, 'br') as f:
- elem_data_single_bytes(fbx_vid, b"Content", f.read())
- except Exception as e:
- print("WARNING: embedding file {} failed ({})".format(filepath, e))
- elem_data_single_bytes(fbx_vid, b"Content", b"")
+ # We only ever embed a given file once!
+ if filepath not in msetts.embedded_set:
+ try:
+ with open(filepath, 'br') as f:
+ elem_data_single_bytes(fbx_vid, b"Content", f.read())
+ except Exception as e:
+ print("WARNING: embedding file {} failed ({})".format(filepath, e))
+ elem_data_single_bytes(fbx_vid, b"Content", b"")
+ msetts.embedded_set.add(filepath)
# Looks like we'd rather not write any 'Content' element in this case (see T44442).
# Sounds suspect, but let's try it!
#~ else:
@@ -2860,6 +2868,7 @@ def save_single(operator, scene, filepath="",
os.path.splitext(os.path.basename(filepath))[0] + ".fbm", # subdir
embed_textures,
set(), # copy_set
+ set(), # embedded_set
)
settings = FBXExportSettings(
diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py
index e6cab6b0..4cf46ffb 100644
--- a/io_scene_fbx/fbx_utils.py
+++ b/io_scene_fbx/fbx_utils.py
@@ -1181,7 +1181,7 @@ def fbx_name_class(name, cls):
# Helper sub-container gathering all exporter settings related to media (texture files).
FBXExportSettingsMedia = namedtuple("FBXExportSettingsMedia", (
"path_mode", "base_src", "base_dst", "subdir",
- "embed_textures", "copy_set",
+ "embed_textures", "copy_set", "embedded_set",
))
# Helper container gathering all exporter settings.