[Bf-extensions-cvs] [58e5857a] master: Update for removal of image.use_alpha

Brecht Van Lommel noreply at git.blender.org
Mon May 20 08:25:05 CEST 2019


Commit: 58e5857aa78bb1d090c2f2de9ec5b6f39ac084ca
Author: Brecht Van Lommel
Date:   Sat May 18 19:38:17 2019 +0200
Branches: master
https://developer.blender.org/rBA58e5857aa78bb1d090c2f2de9ec5b6f39ac084ca

Update for removal of image.use_alpha

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

M	io_import_gimp_image_to_scene.py
M	io_import_images_as_planes.py
M	io_scene_fbx/export_fbx_bin.py
M	io_scene_x3d/import_x3d.py

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

diff --git a/io_import_gimp_image_to_scene.py b/io_import_gimp_image_to_scene.py
index cbf881f9..60e10fac 100644
--- a/io_import_gimp_image_to_scene.py
+++ b/io_import_gimp_image_to_scene.py
@@ -395,9 +395,8 @@ def main(report, File, Path, LayerViewers, MixerViewers, LayerOffset,
 
                 Img = bpy.data.images.new(NameShort+'_A', 128, 128)
                 Img.source = 'FILE'
-                Img.alpha_mode = AlphaMode
+                Img.alpha_mode = 'IGNORE'
                 Img.filepath = '%s%s_A%s' % (PathSaveRaw, Name, ExtSave)
-                Img.use_alpha = False
 
                 Tex.image = Img
 
diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py
index 72b95bda..d610bff5 100644
--- a/io_import_images_as_planes.py
+++ b/io_import_images_as_planes.py
@@ -938,8 +938,10 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
         return plane
 
     def apply_image_options(self, image):
-        image.use_alpha = self.use_transparency
-        image.alpha_mode = self.alpha_mode
+        if self.use_transparency == False:
+            image.alpha_mode = 'IGNORE'
+        else:
+            image.alpha_mode = self.alpha_mode
 
         if self.relative:
             try:  # can't always find the relative path (between drive letters on windows)
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index eb29e5b5..ef2c8d54 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1336,7 +1336,7 @@ def fbx_data_texture_file_elements(root, blender_tex_key, scene_data):
     elem_data_single_string_unicode(fbx_tex, b"RelativeFilename", fname_rel)
 
     alpha_source = 0  # None
-    if img.use_alpha:
+    if img.alpha_mode != 'IGNORE':
         # ~ if tex.texture.use_calculate_alpha:
             # ~ alpha_source = 1  # RGBIntensity as alpha.
         # ~ else:
diff --git a/io_scene_x3d/import_x3d.py b/io_scene_x3d/import_x3d.py
index ba46ffcc..a843a750 100644
--- a/io_scene_x3d/import_x3d.py
+++ b/io_scene_x3d/import_x3d.py
@@ -2774,7 +2774,8 @@ def appearance_LoadImageTexture(imageTexture, ancestry, node):
             # KNOWN BUG; PNGs with a transparent color are not perceived
             # as transparent. Need alpha channel.
 
-            bpyima.use_alpha = bpyima.depth in {32, 128}
+            if bpyima.depth not in {32, 128}:
+                bpyima.alpha_mode = 'IGNORE'
         return bpyima
 
 
@@ -2822,7 +2823,7 @@ def appearance_LoadTexture(tex_node, ancestry, node):
 def appearance_ExpandCachedMaterial(bpymat):
     if 0 and bpymat.texture_slots[0] is not None:
         bpyima = bpymat.texture_slots[0].texture.image
-        tex_has_alpha = bpyima.use_alpha
+        tex_has_alpha = bpyima.alpha_mode not in {'IGNORE', 'CHANNEL_PACKED'}
         return (bpymat, bpyima, tex_has_alpha)
 
     return (bpymat, None, False)
@@ -2861,7 +2862,7 @@ def appearance_Create(vrmlname, material, tex_node, ancestry, node, is_vcol):
         bpymat.use_vertex_color_paint = True
 
     if 0 and bpyima:
-        tex_has_alpha = bpyima.use_alpha
+        tex_has_alpha = bpyima.alpha_mode not in {'IGNORE', 'CHANNEL_PACKED'}
 
         texture = bpy.data.textures.new(bpyima.name, 'IMAGE')
         texture.image = bpyima
@@ -2873,7 +2874,7 @@ def appearance_Create(vrmlname, material, tex_node, ancestry, node, is_vcol):
         mtex.use_map_diffuse = True
         mtex.use = True
 
-        if bpyima.use_alpha:
+        if tex_has_alpha:
             bpymat.use_transparency = True
             mtex.use_map_alpha = True
             mtex.alpha_factor = 0.0
@@ -2971,7 +2972,8 @@ def appearance_LoadPixelTexture(pixelTexture, ancestry):
         print("ImportX3D warning: pixel count in PixelTexture is off")
 
     bpyima = bpy.data.images.new("PixelTexture", w, h, has_alpha, True)
-    bpyima.use_alpha = has_alpha
+    if not has_alpha:
+        bpyima.alpha_mode = 'IGNORE'
 
     # Conditional above the loop, for performance
     if plane_count == 3:  # RGB



More information about the Bf-extensions-cvs mailing list