[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21230] trunk/blender/release/scripts/ import_obj.py: fix for bug while importing transparent faces:

Dalai Felinto dfelinto at gmail.com
Mon Jun 29 04:37:45 CEST 2009

Revision: 21230
Author:   dfelinto
Date:     2009-06-29 04:37:44 +0200 (Mon, 29 Jun 2009)

Log Message:
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.

Modified Paths:

Modified: trunk/blender/release/scripts/import_obj.py
--- trunk/blender/release/scripts/import_obj.py	2009-06-29 02:25:54 UTC (rev 21229)
+++ trunk/blender/release/scripts/import_obj.py	2009-06-29 02:37:44 UTC (rev 21230)
@@ -125,6 +125,14 @@
 		image= obj_image_load(imagepath, DIR, IMAGE_SEARCH)
 		has_data = image.has_data
 		texture.image = image
+		if not has_data:
+			try:
+				# first time using this image. We need to load it first
+				image.glLoad()
+			else:
+				# probably the image is crashed
+				has_data = image.has_data
 		# Adds textures for materials (rendering)
 		if type == 'Kd':

More information about the Bf-blender-cvs mailing list