From d2131c0b9c006702cd64442166b4d9c9b1112bbd Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Wed, 7 Jun 2023 13:13:46 +0300 Subject: [PATCH 01/10] Initial --- source/blender/render/hydra/python.cc | 21 ++++++++++++++++++- .../render/hydra/scene_delegate/image.cc | 20 +++++++++++------- .../render/hydra/scene_delegate/image.h | 5 +++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index d6362d03725f..d3dab4b6b461 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -17,6 +17,7 @@ #include "final_engine.h" #include "preview_engine.h" #include "viewport_engine.h" +#include "scene_delegate/image.h" namespace blender::render::hydra { @@ -266,6 +267,23 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a Py_RETURN_NONE; } +static PyObject *cache_image_func(PyObject * /*self*/, PyObject *args) +{ + PyObject *pycontext, *pyscene ,*pyimage; + if (!PyArg_ParseTuple(args, "OOO", &pycontext, &pyscene, &pyimage)) { + Py_RETURN_NONE; + } + + bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext); + Scene *scene = (Scene *)PyLong_AsVoidPtr(pyscene); + Image *image = (Image *)PyLong_AsVoidPtr(pyimage); + + std::string image_path = cache_image_file(image, context, scene, NULL, false); + + CLOG_INFO(LOG_RENDER_HYDRA, 1, "Cache image"); + return PyUnicode_FromString(image_path.c_str()); +} + static PyMethodDef methods[] = { {"init", init_func, METH_VARARGS, ""}, {"register_plugins", register_plugins_func, METH_VARARGS, ""}, @@ -274,12 +292,13 @@ static PyMethodDef methods[] = { {"engine_create", engine_create_func, METH_VARARGS, ""}, {"engine_free", engine_free_func, METH_VARARGS, ""}, {"engine_sync", engine_sync_func, METH_VARARGS, ""}, - {"engine_sync_usd", engine_sync_usd_func, METH_VARARGS, ""}, {"engine_render", engine_render_func, METH_VARARGS, ""}, {"engine_view_draw", engine_view_draw_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, ""}, + {"cache_image", cache_image_func, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL}, }; diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index 356043b5f9a2..47c791f9b7e8 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -16,8 +16,8 @@ namespace blender::render::hydra { -static std::string cache_image_file(Image *image, - BlenderSceneDelegate *scene_delegate, +std::string cache_image_file(Image *image, + bContext *context, Scene *scene, ImageUser *iuser, bool check_exist) { @@ -34,11 +34,13 @@ static std::string cache_image_file(Image *image, return file_path; } - Main *main = CTX_data_main(scene_delegate->context); + Main *main = CTX_data_main(context); ImageSaveOptions opts; opts.im_format.imtype = R_IMF_IMTYPE_RADHDR; - if (BKE_image_save_options_init(&opts, main, scene_delegate->scene, image, iuser, true, false)) { + auto prev_source = image->source; + + if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) { STRNCPY(opts.filepath, file_path.c_str()); ReportList reports; if (BKE_image_save(&reports, main, image, iuser, &opts)) { @@ -49,6 +51,7 @@ static std::string cache_image_file(Image *image, } } BKE_image_save_options_free(&opts); + image->source = prev_source; return file_path; } @@ -59,17 +62,20 @@ std::string cache_or_get_image_file(Image *image, { std::string file_path(FILE_MAX, 0); if (image->source == IMA_SRC_GENERATED) { - file_path = cache_image_file(image, scene_delegate, iuser, false); + file_path = cache_image_file( + image, scene_delegate->context, scene_delegate->scene, iuser, false); } else if (BKE_image_has_packedfile(image)) { - file_path = cache_image_file(image, scene_delegate, iuser, true); + file_path = cache_image_file( + image, scene_delegate->context, scene_delegate->scene, iuser, true); } else { Main *main = CTX_data_main(scene_delegate->context); BKE_image_user_file_path_ex(main, iuser, image, file_path.data(), false, true); if (!pxr::HioImageRegistry::GetInstance().IsSupportedImageFile(file_path)) { - file_path = cache_image_file(image, scene_delegate, iuser, true); + file_path = cache_image_file( + image, scene_delegate->context, scene_delegate->scene, iuser, true); } } diff --git a/source/blender/render/hydra/scene_delegate/image.h b/source/blender/render/hydra/scene_delegate/image.h index 886385963051..c160e84774a1 100644 --- a/source/blender/render/hydra/scene_delegate/image.h +++ b/source/blender/render/hydra/scene_delegate/image.h @@ -10,6 +10,11 @@ namespace blender::render::hydra { class BlenderSceneDelegate; +std::string cache_image_file(Image *image, + bContext *context, Scene *scene, + ImageUser *iuser, + bool check_exist); + std::string cache_or_get_image_file(Image *image, BlenderSceneDelegate *scene_delegate, ImageUser *iuser); -- 2.30.2 From b8793017cf9ff5e33143ccf37698bd52dad9ca14 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Thu, 8 Jun 2023 14:35:01 +0300 Subject: [PATCH 02/10] fix image caching --- .../render/hydra/scene_delegate/image.cc | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index 47c791f9b7e8..d63f092feda4 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -6,6 +6,7 @@ #include "BKE_appdir.h" #include "BKE_image.h" #include "BKE_image_save.h" +#include "BKE_image_format.h" #include "BLI_fileops.h" #include "BLI_path_util.h" @@ -22,28 +23,28 @@ std::string cache_image_file(Image *image, bool check_exist) { std::string file_path(FILE_MAX, 0); - char file_name[32]; - snprintf(file_name, 32, "img_%016llx.hdr", (uintptr_t)image); - BLI_path_join(file_path.data(), - file_path.capacity(), - BKE_tempdir_session(), - "hydra_image_cache", - file_name); - - if (check_exist && BLI_exists(file_path.c_str())) { - return file_path; - } - Main *main = CTX_data_main(context); ImageSaveOptions opts; - opts.im_format.imtype = R_IMF_IMTYPE_RADHDR; - - auto prev_source = image->source; - if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) { + char file_name[32]; + const char *r_ext[BKE_IMAGE_PATH_EXT_MAX]; + snprintf(file_name, sizeof(file_name), "img_%016llx", (uintptr_t)image); + BKE_image_path_ext_from_imtype(opts.im_format.imtype, r_ext); + + int len = strlen(file_name); + STR_CONCAT(file_name, len, *r_ext); + BLI_path_join(file_path.data(), + file_path.capacity(), + BKE_tempdir_session(), + "hydra_image_cache", + file_name); + + if (check_exist && BLI_exists(file_path.c_str())) { + return file_path; + } + opts.save_copy = true; STRNCPY(opts.filepath, file_path.c_str()); - ReportList reports; - if (BKE_image_save(&reports, main, image, iuser, &opts)) { + if (BKE_image_save(nullptr, main, image, iuser, &opts)) { CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str()); } else { @@ -51,7 +52,6 @@ std::string cache_image_file(Image *image, } } BKE_image_save_options_free(&opts); - image->source = prev_source; return file_path; } -- 2.30.2 From 0c07e52b5998f056a19743c0d4dca74edea0b648 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Thu, 8 Jun 2023 14:45:17 +0300 Subject: [PATCH 03/10] make format --- source/blender/render/hydra/python.cc | 4 ++-- source/blender/render/hydra/scene_delegate/image.cc | 8 +++----- source/blender/render/hydra/scene_delegate/image.h | 6 ++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index d3dab4b6b461..a4c77e6b2d42 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -16,8 +16,8 @@ #include "final_engine.h" #include "preview_engine.h" -#include "viewport_engine.h" #include "scene_delegate/image.h" +#include "viewport_engine.h" namespace blender::render::hydra { @@ -269,7 +269,7 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a static PyObject *cache_image_func(PyObject * /*self*/, PyObject *args) { - PyObject *pycontext, *pyscene ,*pyimage; + PyObject *pycontext, *pyscene, *pyimage; if (!PyArg_ParseTuple(args, "OOO", &pycontext, &pyscene, &pyimage)) { Py_RETURN_NONE; } diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index d63f092feda4..8f587b5087e7 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -5,8 +5,8 @@ #include "BKE_appdir.h" #include "BKE_image.h" -#include "BKE_image_save.h" #include "BKE_image_format.h" +#include "BKE_image_save.h" #include "BLI_fileops.h" #include "BLI_path_util.h" @@ -17,10 +17,8 @@ namespace blender::render::hydra { -std::string cache_image_file(Image *image, - bContext *context, Scene *scene, - ImageUser *iuser, - bool check_exist) +std::string cache_image_file( + Image *image, bContext *context, Scene *scene, ImageUser *iuser, bool check_exist) { std::string file_path(FILE_MAX, 0); Main *main = CTX_data_main(context); diff --git a/source/blender/render/hydra/scene_delegate/image.h b/source/blender/render/hydra/scene_delegate/image.h index c160e84774a1..efc59da780e7 100644 --- a/source/blender/render/hydra/scene_delegate/image.h +++ b/source/blender/render/hydra/scene_delegate/image.h @@ -10,10 +10,8 @@ namespace blender::render::hydra { class BlenderSceneDelegate; -std::string cache_image_file(Image *image, - bContext *context, Scene *scene, - ImageUser *iuser, - bool check_exist); +std::string cache_image_file( + Image *image, bContext *context, Scene *scene, ImageUser *iuser, bool check_exist); std::string cache_or_get_image_file(Image *image, BlenderSceneDelegate *scene_delegate, -- 2.30.2 From 5610ec8d9c17fb6bde89593b93bfa8df86a72981 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Thu, 8 Jun 2023 14:52:53 +0300 Subject: [PATCH 04/10] removed logging from cache_image_func --- source/blender/render/hydra/python.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index a4c77e6b2d42..2d3770d19891 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -279,8 +279,6 @@ static PyObject *cache_image_func(PyObject * /*self*/, PyObject *args) Image *image = (Image *)PyLong_AsVoidPtr(pyimage); std::string image_path = cache_image_file(image, context, scene, NULL, false); - - CLOG_INFO(LOG_RENDER_HYDRA, 1, "Cache image"); return PyUnicode_FromString(image_path.c_str()); } -- 2.30.2 From b60a6291b77b70d674c835d497a30fdcd3257000 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 9 Jun 2023 10:47:24 +0300 Subject: [PATCH 05/10] make format --- source/blender/render/hydra/scene_delegate/image.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index 436ff97ed3ff..be055e431686 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -32,11 +32,8 @@ std::string cache_image_file( int len = strlen(file_name); STR_CONCAT(file_name, len, *r_ext); - BLI_path_join(file_path, - sizeof(file_path), - BKE_tempdir_session(), - "hydra_image_cache", - file_name); + BLI_path_join( + file_path, sizeof(file_path), BKE_tempdir_session(), "hydra_image_cache", file_name); if (check_exist && BLI_exists(file_path)) { return file_path; -- 2.30.2 From 7a66d7c266098c7b553323ef4571f1ac80191812 Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 9 Jun 2023 11:38:34 +0300 Subject: [PATCH 06/10] fix getting image format --- source/blender/render/hydra/scene_delegate/image.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index be055e431686..5e53d4e8adfd 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -28,7 +28,7 @@ std::string cache_image_file( char file_name[32]; const char *r_ext[BKE_IMAGE_PATH_EXT_MAX]; snprintf(file_name, sizeof(file_name), "img_%016llx", (uintptr_t)image); - BKE_image_path_ext_from_imtype(opts.im_format.imtype, r_ext); + BKE_image_path_ext_from_imformat(&scene->r.im_format, r_ext); int len = strlen(file_name); STR_CONCAT(file_name, len, *r_ext); -- 2.30.2 From 5bd140211bfa7c9bb3fba8cf52da9c42a900574a Mon Sep 17 00:00:00 2001 From: "georgiy.m.markelov@gmail.com" Date: Fri, 9 Jun 2023 11:50:18 +0300 Subject: [PATCH 07/10] returned deleted line --- source/blender/render/hydra/python.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index b0f8c0c6a26c..e06a7807c2ce 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -243,6 +243,7 @@ static PyMethodDef methods[] = { {"engine_create", engine_create_func, METH_VARARGS, ""}, {"engine_free", engine_free_func, METH_VARARGS, ""}, {"engine_sync", engine_sync_func, METH_VARARGS, ""}, + {"engine_sync_usd", engine_sync_usd_func, METH_VARARGS, ""}, {"engine_render", engine_render_func, METH_VARARGS, ""}, {"engine_view_draw", engine_view_draw_func, METH_VARARGS, ""}, {"engine_set_sync_setting", engine_set_sync_setting_func, METH_VARARGS, ""}, -- 2.30.2 From 1a45af530980ff957699800f50e9c5cc14934154 Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Tue, 13 Jun 2023 08:07:07 +0300 Subject: [PATCH 08/10] Simplified code: removed scene from arguments --- source/blender/render/hydra/python.cc | 7 +++--- .../render/hydra/scene_delegate/image.cc | 23 ++++++------------- .../render/hydra/scene_delegate/image.h | 12 +++------- .../render/hydra/scene_delegate/world.cc | 3 ++- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index e06a7807c2ce..191b31cdcdbd 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -224,16 +224,15 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a static PyObject *cache_image_func(PyObject * /*self*/, PyObject *args) { - PyObject *pycontext, *pyscene, *pyimage; - if (!PyArg_ParseTuple(args, "OOO", &pycontext, &pyscene, &pyimage)) { + PyObject *pycontext, *pyimage; + if (!PyArg_ParseTuple(args, "OOO", &pycontext, &pyimage)) { Py_RETURN_NONE; } bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext); - Scene *scene = (Scene *)PyLong_AsVoidPtr(pyscene); Image *image = (Image *)PyLong_AsVoidPtr(pyimage); - std::string image_path = cache_image_file(image, context, scene, NULL, false); + std::string image_path = cache_image_file(image, context, NULL, false); return PyUnicode_FromString(image_path.c_str()); } diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index 5e53d4e8adfd..957ff26c3a64 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -4,25 +4,21 @@ #include #include "BKE_appdir.h" -#include "BKE_image.h" #include "BKE_image_format.h" #include "BKE_image_save.h" #include "BLI_fileops.h" #include "BLI_path_util.h" -#include "DNA_windowmanager_types.h" - #include "blender_scene_delegate.h" #include "image.h" namespace blender::render::hydra { -std::string cache_image_file( - Image *image, bContext *context, Scene *scene, ImageUser *iuser, bool check_exist) +std::string cache_image_file(Image *image, bContext *context, ImageUser *iuser, bool check_exist) { char file_path[FILE_MAX]; - char file_name[32]; Main *main = CTX_data_main(context); + Scene *scene = CTX_data_scene(context); ImageSaveOptions opts; if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) { char file_name[32]; @@ -52,26 +48,21 @@ std::string cache_image_file( return file_path; } -std::string cache_or_get_image_file(Image *image, - BlenderSceneDelegate *scene_delegate, - ImageUser *iuser) +std::string cache_or_get_image_file(Image *image, bContext *context, ImageUser *iuser) { std::string file_path(FILE_MAX, 0); if (image->source == IMA_SRC_GENERATED) { - file_path = cache_image_file( - image, scene_delegate->context, scene_delegate->scene, iuser, false); + file_path = cache_image_file(image, context, iuser, false); } else if (BKE_image_has_packedfile(image)) { - file_path = cache_image_file( - image, scene_delegate->context, scene_delegate->scene, iuser, true); + file_path = cache_image_file(image, context, iuser, true); } else { - Main *main = CTX_data_main(scene_delegate->context); + Main *main = CTX_data_main(context); BKE_image_user_file_path_ex(main, iuser, image, file_path.data(), false, true); if (!pxr::HioImageRegistry::GetInstance().IsSupportedImageFile(file_path)) { - file_path = cache_image_file( - image, scene_delegate->context, scene_delegate->scene, iuser, true); + file_path = cache_image_file(image, context, iuser, true); } } diff --git a/source/blender/render/hydra/scene_delegate/image.h b/source/blender/render/hydra/scene_delegate/image.h index efc59da780e7..4e6fbbde37b8 100644 --- a/source/blender/render/hydra/scene_delegate/image.h +++ b/source/blender/render/hydra/scene_delegate/image.h @@ -3,18 +3,12 @@ #pragma once +#include "BKE_context.h" #include "BKE_image.h" -#include "BKE_image_save.h" namespace blender::render::hydra { -class BlenderSceneDelegate; - -std::string cache_image_file( - Image *image, bContext *context, Scene *scene, ImageUser *iuser, bool check_exist); - -std::string cache_or_get_image_file(Image *image, - BlenderSceneDelegate *scene_delegate, - ImageUser *iuser); +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); } // namespace blender::render::hydra diff --git a/source/blender/render/hydra/scene_delegate/world.cc b/source/blender/render/hydra/scene_delegate/world.cc index 8df6dbb04a27..e3ea936300cb 100644 --- a/source/blender/render/hydra/scene_delegate/world.cc +++ b/source/blender/render/hydra/scene_delegate/world.cc @@ -87,7 +87,8 @@ void WorldData::init() NodeTexImage *tex = static_cast(color_input_node->storage); Image *image = (Image *)color_input_node->id; if (image) { - std::string image_path = cache_or_get_image_file(image, scene_delegate_, &tex->iuser); + std::string image_path = cache_or_get_image_file( + image, scene_delegate_->context, &tex->iuser); if (!image_path.empty()) { data_[pxr::HdLightTokens->textureFile] = pxr::SdfAssetPath(image_path, image_path); } -- 2.30.2 From f19c35231488d9c6d982cb77cf6f148720b8801f Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Tue, 13 Jun 2023 08:49:41 +0300 Subject: [PATCH 09/10] Renamed cache_image -> cache_or_get_image_file in bpy_hydra module. Simplified cache_image_file() --- source/blender/render/hydra/python.cc | 8 ++++---- source/blender/render/hydra/scene_delegate/image.cc | 10 ++++------ source/blender/render/hydra/scene_delegate/image.h | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/source/blender/render/hydra/python.cc b/source/blender/render/hydra/python.cc index 191b31cdcdbd..f0c922194881 100644 --- a/source/blender/render/hydra/python.cc +++ b/source/blender/render/hydra/python.cc @@ -222,17 +222,17 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a 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; - if (!PyArg_ParseTuple(args, "OOO", &pycontext, &pyimage)) { + if (!PyArg_ParseTuple(args, "OO", &pycontext, &pyimage)) { Py_RETURN_NONE; } bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext); 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()); } @@ -248,7 +248,7 @@ static PyMethodDef methods[] = { {"engine_set_sync_setting", engine_set_sync_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}, }; diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index 957ff26c3a64..ac5cec1543c0 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -14,7 +14,7 @@ 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]; Main *main = CTX_data_main(context); @@ -22,12 +22,10 @@ std::string cache_image_file(Image *image, bContext *context, ImageUser *iuser, ImageSaveOptions opts; if (BKE_image_save_options_init(&opts, main, scene, image, iuser, false, false)) { char file_name[32]; - const char *r_ext[BKE_IMAGE_PATH_EXT_MAX]; - snprintf(file_name, sizeof(file_name), "img_%016llx", (uintptr_t)image); - BKE_image_path_ext_from_imformat(&scene->r.im_format, r_ext); + const char *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( file_path, sizeof(file_path), BKE_tempdir_session(), "hydra_image_cache", file_name); diff --git a/source/blender/render/hydra/scene_delegate/image.h b/source/blender/render/hydra/scene_delegate/image.h index 4e6fbbde37b8..74fe5f198f84 100644 --- a/source/blender/render/hydra/scene_delegate/image.h +++ b/source/blender/render/hydra/scene_delegate/image.h @@ -8,7 +8,6 @@ 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); } // namespace blender::render::hydra -- 2.30.2 From f71bc33cce821015b547349950baeabf9f2a653c Mon Sep 17 00:00:00 2001 From: Bogdan Nagirniak Date: Tue, 13 Jun 2023 08:53:02 +0300 Subject: [PATCH 10/10] make format --- source/blender/render/hydra/scene_delegate/image.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/render/hydra/scene_delegate/image.cc b/source/blender/render/hydra/scene_delegate/image.cc index ac5cec1543c0..303071a9fe39 100644 --- a/source/blender/render/hydra/scene_delegate/image.cc +++ b/source/blender/render/hydra/scene_delegate/image.cc @@ -14,7 +14,10 @@ namespace blender::render::hydra { -static 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]; Main *main = CTX_data_main(context); -- 2.30.2