forked from blender/blender-addons
Caching generated image leads to infinite loop in preview render #15
@ -347,6 +347,14 @@ READONLY_IMAGE_FORMATS = {".dds"} # blender can read these formats, but can't w
|
||||
|
||||
|
||||
def cache_image_file(image: bpy.types.Image, cache_check=True):
|
||||
try:
|
||||
import _bpy_hydra
|
||||
return _bpy_hydra.cache_or_get_image_file(bpy.context.as_pointer(), image.as_pointer())
|
||||
|
||||
except ImportError:
|
||||
# without bpy_hydra we are going to cache image through python
|
||||
pass
|
||||
|
||||
image_path = Path(image.filepath_from_user())
|
||||
if not image.packed_file and image.source != 'GENERATED':
|
||||
if not image_path.is_file():
|
||||
@ -379,11 +387,8 @@ def cache_image_file(image: bpy.types.Image, cache_check=True):
|
||||
scene.render.image_settings.color_mode = BLENDER_DEFAULT_COLOR_MODE
|
||||
|
||||
try:
|
||||
import _bpy_hydra
|
||||
image.save_render(filepath=str(temp_path))
|
||||
|
||||
temp_path = _bpy_hydra.cache_image(bpy.context.as_pointer(), scene.as_pointer(), image.as_pointer())
|
||||
except ImportError:
|
||||
print("ERROR: No Hydra scene delegate available")
|
||||
finally:
|
||||
scene.render.image_settings.file_format = user_format
|
||||
scene.render.image_settings.color_mode = user_color_mode
|
||||
|
Loading…
Reference in New Issue
Block a user