@ -781,16 +781,27 @@ class MaterialConverter:
cached_image = texcache . get_from_texture ( key , compression )
if cached_image is None :
if key . is_cube_map :
numLevels , width , height , data = self . _finalize_cube_map ( key , image , name , compression , dxt )
else :
numLevels , width , height , data = self . _finalize_single_image ( key , image , name , compression , dxt )
texcache . add_texture ( key , numLevels , ( width , height ) , compression , data )
numLevels , width , height , data = self . _finalize_cache ( texcache , key , image , name , compression , dxt )
self . _finalize_bitmap ( key , owners , name , numLevels , width , height , compression , dxt , data )
else :
width , height = cached_image . export_size
data = cached_image . image_data
numLevels = cached_image . mip_levels
# If the cached image data is junk, PyHSPlasma will raise a RuntimeError,
# so we'll attempt a recache...
try :
self . _finalize_bitmap ( key , owners , name , numLevels , width , height , compression , dxt , data )
except RuntimeError :
self . _report . warn ( " Cached image is corrupted! Recaching image... " , indent = 1 )
numLevels , width , height , data = self . _finalize_cache ( texcache , key , image , name , compression , dxt )
self . _finalize_bitmap ( key , owners , name , numLevels , width , height , compression , dxt , data )
inc_progress ( )
def _finalize_bitmap ( self , key , owners , name , numLevels , width , height , compression , dxt , data ) :
mgr = self . _mgr
# Now we poke our new bitmap into the pending layers. Note that we have to do some funny
# business to account for per-page textures
pages = { }
@ -833,9 +844,15 @@ class MaterialConverter:
elif isinstance ( owner , plImageLibMod ) :
owner . addImage ( texture . key )
else :
raise Runtime Error ( owner . ClassName ( ) )
raise NotImplemented Error( owner . ClassName ( ) )
inc_progress ( )
def _finalize_cache ( self , texcache , key , image , name , compression , dxt ) :
if key . is_cube_map :
numLevels , width , height , data = self . _finalize_cube_map ( key , image , name , compression , dxt )
else :
numLevels , width , height , data = self . _finalize_single_image ( key , image , name , compression , dxt )
texcache . add_texture ( key , numLevels , ( width , height ) , compression , data )
return numLevels , width , height , data
def _finalize_cube_map ( self , key , image , name , compression , dxt ) :
oWidth , oHeight = image . size