fix for bug while importing transparent faces:

image.has_data can't be called before you load an image, otherwise it will return false even for valid images.
The workaround is to try to run image.glLoad() before. That will crash if the image is corrupted (for we are using try/catch here).

Campbell (ideasman42) thinks it would be better to have an api call proper for that. Since 2.4xx is close to its end I really don't think it's time to keep working in its API. Specially if we have similar functions doing what we need.

@ Arystanbek (kazanbas): I'm done with the obj fixes I told you. You are free to go with the importers :)
You may want to take a look at implementing a proper image.load() to 2.5 as Campbell suggested.
This commit is contained in:
Dalai Felinto
2009-06-29 02:37:44 +00:00
parent 417aeb935a
commit b5a4492069

View File

@@ -126,6 +126,16 @@ def create_materials(filepath, material_libs, unique_materials, unique_material_
has_data = image.has_data has_data = image.has_data
texture.image = image texture.image = image
if not has_data:
try:
# first time using this image. We need to load it first
image.glLoad()
except:
# probably the image is crashed
pass
else:
has_data = image.has_data
# Adds textures for materials (rendering) # Adds textures for materials (rendering)
if type == 'Kd': if type == 'Kd':
if has_data and image.depth == 32: if has_data and image.depth == 32: