Browse Source

Fix tracebacks where ImageTexture.image is None

pull/10/head
Adam Johnson 10 years ago
parent
commit
cc755bf072
  1. 5
      korman/exporter/material.py

5
korman/exporter/material.py

@ -458,10 +458,13 @@ class MaterialConverter:
texture = slot.texture texture = slot.texture
# Does the image have any alpha at all? # Does the image have any alpha at all?
if texture.image is not None:
has_alpha = texture.use_calculate_alpha or slot.use_stencil or self._test_image_alpha(texture.image) has_alpha = texture.use_calculate_alpha or slot.use_stencil or self._test_image_alpha(texture.image)
if (texture.image.use_alpha and texture.use_alpha) and not has_alpha: if (texture.image.use_alpha and texture.use_alpha) and not has_alpha:
warning = "'{}' wants to use alpha, but '{}' is opaque".format(texture.name, texture.image.name) warning = "'{}' wants to use alpha, but '{}' is opaque".format(texture.name, texture.image.name)
self._exporter().report.warn(warning, indent=3) self._exporter().report.warn(warning, indent=3)
else:
has_alpha = True
# First, let's apply any relevant flags # First, let's apply any relevant flags
state = layer.state state = layer.state
@ -480,7 +483,7 @@ class MaterialConverter:
# Otherwise, we toss this layer and some info into our pending texture dict and process it # Otherwise, we toss this layer and some info into our pending texture dict and process it
# when the exporter tells us to finalize all our shit # when the exporter tells us to finalize all our shit
if texture.image is None: if texture.image is None:
bitmap = self.add_object(plDynamicTextMap, name="{}_DynText".format(layer.key.name), bl=bo) bitmap = self._mgr.add_object(plDynamicTextMap, name="{}_DynText".format(layer.key.name), bl=bo)
else: else:
key = _Texture(texture=texture, use_alpha=has_alpha, force_calc_alpha=slot.use_stencil) key = _Texture(texture=texture, use_alpha=has_alpha, force_calc_alpha=slot.use_stencil)
if key not in self._pending: if key not in self._pending:

Loading…
Cancel
Save