[Bf-extensions-cvs] [a740fe7] master: FBX Import: Fix (unreported) embeded images not always loaded.

Bastien Montagne noreply at git.blender.org
Fri Jul 3 17:15:39 CEST 2015


Commit: a740fe7547fc74faab78b1a155b52f653c041868
Author: Bastien Montagne
Date:   Fri Jul 3 17:14:29 2015 +0200
Branches: master
https://developer.blender.org/rBAa740fe7547fc74faab78b1a155b52f653c041868

FBX Import: Fix (unreported) embeded images not always loaded.

===================================================================

M	io_scene_fbx/__init__.py
M	io_scene_fbx/import_fbx.py

===================================================================

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index 42321cf..5a98fcd 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 5d292b1..0e60ba3 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



More information about the Bf-extensions-cvs mailing list