forked from blender/blender
Caching generated image leads to infinite loop in preview render #53
@ -222,17 +222,17 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *cache_image_func(PyObject * /*self*/, PyObject *args)
|
static PyObject *cache_or_get_image_file_func(PyObject * /*self*/, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *pycontext, *pyimage;
|
PyObject *pycontext, *pyimage;
|
||||||
if (!PyArg_ParseTuple(args, "OOO", &pycontext, &pyimage)) {
|
if (!PyArg_ParseTuple(args, "OO", &pycontext, &pyimage)) {
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
DagerD marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
||||||
Image *image = (Image *)PyLong_AsVoidPtr(pyimage);
|
Image *image = (Image *)PyLong_AsVoidPtr(pyimage);
|
||||||
|
|
||||||
std::string image_path = cache_image_file(image, context, NULL, false);
|
std::string image_path = cache_or_get_image_file(image, context, nullptr);
|
||||||
return PyUnicode_FromString(image_path.c_str());
|
return PyUnicode_FromString(image_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ static PyMethodDef methods[] = {
|
|||||||
{"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},
|
{"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""},
|
||||||
{"engine_set_render_setting", engine_set_render_setting_func, METH_VARARGS, ""},
|
{"engine_set_render_setting", engine_set_render_setting_func, METH_VARARGS, ""},
|
||||||
|
|
||||||
{"cache_image", cache_image_func, METH_VARARGS, ""},
|
{"cache_or_get_image_file", cache_or_get_image_file_func, METH_VARARGS, ""},
|
||||||
|
|
||||||
{NULL, NULL, 0, NULL},
|
{NULL, NULL, 0, NULL},
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
std::string cache_image_file(Image *image, bContext *context, ImageUser *iuser, bool check_exist)
|
static std::string cache_image_file(Image *image, bContext *context, ImageUser *iuser, bool check_exist)
|
||||||
{
|
{
|
||||||
char file_path[FILE_MAX];
|
char file_path[FILE_MAX];
|
||||||
Main *main = CTX_data_main(context);
|
Main *main = CTX_data_main(context);
|
||||||
@ -22,12 +22,10 @@ std::string cache_image_file(Image *image, bContext *context, ImageUser *iuser,
|
|||||||
ImageSaveOptions opts;
|
ImageSaveOptions opts;
|
||||||
if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) {
|
if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) {
|
||||||
char file_name[32];
|
char file_name[32];
|
||||||
const char *r_ext[BKE_IMAGE_PATH_EXT_MAX];
|
const char *r_ext;
|
||||||
snprintf(file_name, sizeof(file_name), "img_%016llx", (uintptr_t)image);
|
BKE_image_path_ext_from_imformat(&scene->r.im_format, &r_ext);
|
||||||
BKE_image_path_ext_from_imformat(&scene->r.im_format, r_ext);
|
snprintf(file_name, sizeof(file_name), "img_%016llx%s", (uintptr_t)image, r_ext);
|
||||||
|
|
||||||
int len = strlen(file_name);
|
|
||||||
STR_CONCAT(file_name, len, *r_ext);
|
|
||||||
BLI_path_join(
|
BLI_path_join(
|
||||||
file_path, sizeof(file_path), BKE_tempdir_session(), "hydra_image_cache", file_name);
|
file_path, sizeof(file_path), BKE_tempdir_session(), "hydra_image_cache", file_name);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
namespace blender::render::hydra {
|
namespace blender::render::hydra {
|
||||||
|
|
||||||
std::string cache_image_file(Image *image, bContext *context, ImageUser *iuser, bool check_exist);
|
|
||||||
std::string cache_or_get_image_file(Image *image, bContext *context, ImageUser *iuser);
|
std::string cache_or_get_image_file(Image *image, bContext *context, ImageUser *iuser);
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
Loading…
Reference in New Issue
Block a user
why did you remove this?
Mistake. Fixed.