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-07-03 18:14:29 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-07-03 18:15:15 +0300
commita740fe7547fc74faab78b1a155b52f653c041868 (patch)
treee8adc2de8c00610d7aa688dd3e206734678e601f
parent7937fe22df4a5fcfa931281aba1dfa05bb0ea4a1 (diff)
FBX Import: Fix (unreported) embeded images not always loaded.
-rw-r--r--io_scene_fbx/__init__.py2
-rw-r--r--io_scene_fbx/import_fbx.py16
2 files changed, 12 insertions, 6 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 42321cf1..5a98fcd9 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
bl_info = {
"name": "FBX format",
"author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
- "version": (3, 4, 2),
+ "version": (3, 4, 3),
"blender": (2, 74, 0),
"location": "File > Import-Export",
"description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index 5d292b1e..0e60ba37 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -1323,6 +1323,13 @@ def blen_read_texture_image(fbx_tmpl, fbx_obj, basedir, settings):
import os
from bpy_extras import image_utils
+ def pack_data_from_content(image, fbx_obj):
+ data = elem_find_first_bytes(fbx_obj, b'Content')
+ if (data):
+ data_len = len(data)
+ if (data_len):
+ image.pack(data=data, data_len=data_len)
+
elem_name_utf8 = elem_name_ensure_classes(fbx_obj, {b'Texture', b'Video'})
image_cache = settings.image_cache
@@ -1348,6 +1355,9 @@ def blen_read_texture_image(fbx_tmpl, fbx_obj, basedir, settings):
image = image_cache.get(filepath)
if image is not None:
+ # Data is only embedded once, we may have already created the image but still be missing its data!
+ if not image.has_data:
+ pack_data_from_content(image, fbx_obj)
return image
image = image_utils.load_image(
@@ -1358,11 +1368,7 @@ def blen_read_texture_image(fbx_tmpl, fbx_obj, basedir, settings):
)
# Try to use embedded data, if available!
- data = elem_find_first_bytes(fbx_obj, b'Content')
- if (data):
- data_len = len(data)
- if (data_len):
- image.pack(data=data, data_len=data_len)
+ pack_data_from_content(image, fbx_obj)
image_cache[filepath] = image
# name can be ../a/b/c