[Bf-blender-cvs] [163d4aa094d] master: Fix T103707: Use beauty fill for the UV select overlap operator
Commit: 163d4aa094d1407c474bbef6895a793425f8c00b Author: Jesse Yurkovich Date: Wed Jan 18 21:25:55 2023 -0800 Branches: master https://developer.blender.org/rB163d4aa094d1407c474bbef6895a793425f8c00b Fix T103707: Use beauty fill for the UV select overlap operator The original code used `BLI_polyfill_calc` which can create degenerate triangles during triangulation per T103913. This causes the subsequent overlap test to produce incorrect results in certain cases. Change to using a "beauty" fill instead. Differential Revision: https://developer.blender.org/D17015 === M source/blender/editors/uvedit/uvedit_select.c === diff --git a/source/blender/editors/uvedit/uvedit_select.c b/source/blender/editors/uvedit/uvedit_select.c index a54d62b11b0..dc68b2c6475 100644 --- a/source/blender/editors/uvedit/uvedit_select.c +++ b/source/blender/editors/uvedit/uvedit_select.c @@ -22,11 +22,14 @@ #include "BLI_alloca.h" #include "BLI_blenlib.h" #include "BLI_hash.h" +#include "BLI_heap.h" #include "BLI_kdopbvh.h" #include "BLI_kdtree.h" #include "BLI_lasso_2d.h" #include "BLI_math.h" +#include "BLI_memarena.h" #include "BLI_polyfill_2d.h" +#include "BLI_polyfill_2d_beautify.h" #include "BLI_utildefines.h" #include "BKE_context.h" @@ -4359,6 +4362,9 @@ static int uv_select_overlap(bContext *C, const bool extend) float(*uv_verts)[2] = MEM_mallocN(sizeof(*uv_verts) * face_len_alloc, "UvOverlapCoords"); uint(*indices)[3] = MEM_mallocN(sizeof(*indices) * (face_len_alloc - 2), "UvOverlapTris"); + MemArena *arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); + Heap *heap = BLI_heap_new_ex(BLI_POLYFILL_ALLOC_NGON_RESERVE); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -4393,7 +4399,14 @@ static int uv_select_overlap(bContext *C, const bool extend) copy_v2_v2(uv_verts[vert_index], luv); } - BLI_polyfill_calc(uv_verts, face_len, 0, indices); + /* The winding order of the coordinates is not guaranteed, determine it automatically. */ + const int coords_sign = 0; + BLI_polyfill_calc_arena(uv_verts, face_len, coords_sign, indices, arena); + + /* A beauty fill is necessary to remove degenerate triangles that may be produced from the + * above polyfill (see T103913), otherwise the overlap tests can fail. + */ + BLI_polyfill_beautify(uv_verts, face_len, indices, arena, heap); for (int t = 0; t < tri_len; t++) { overlap_data[data_index].ob_index = ob_index; @@ -4413,10 +4426,15 @@ static int uv_select_overlap(bContext *C, const bool extend) BLI_bvhtree_insert(uv_tree, data_index, [0][0], 3); data_index++; } + + BLI_memarena_clear(arena); + BLI_heap_clear(heap, NULL); } } BLI_assert(data_index == uv_tri_len); + BLI_memarena_free(arena); + BLI_heap_free(heap, NULL); MEM_freeN(uv_verts); MEM_freeN(indices); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b6c74b4c6f6] master: Fix T82081: Remove workaround for OCIO Unicode issue on Windows
Commit: b6c74b4c6f6b2b1ec28ec9db091a2a0f4fe66b94 Author: Jesse Yurkovich Date: Thu Jan 5 20:44:24 2023 -0800 Branches: master https://developer.blender.org/rBb6c74b4c6f6b2b1ec28ec9db091a2a0f4fe66b94 Fix T82081: Remove workaround for OCIO Unicode issue on Windows This workaround is no longer needed and prevents our OCIO configuration from being loaded if Blender is unpacked under a Unicode path. Differential Revision: https://developer.blender.org/D16818 === M source/blender/imbuf/intern/colormanagement.c === diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index 0678c224e6b..9f14ca0d596 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -671,17 +671,7 @@ void colormanagement_init(void) if (configdir) { BLI_path_join(configfile, sizeof(configfile), configdir, BCM_CONFIG_FILE); -#ifdef WIN32 - { -/* Quite a hack to support loading configuration from path with non-ACII symbols. */ - -char short_name[256]; -BLI_get_short_name(short_name, configfile); -config = OCIO_configCreateFromFile(short_name); - } -#else config = OCIO_configCreateFromFile(configfile); -#endif } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0710ec485e4] master: Cleanup: Remove unused IMB tile cache code (part 2)
Commit: 0710ec485e4075bee9b1d1f70bed38c6ecb189f3 Author: Jesse Yurkovich Date: Thu Nov 24 12:40:18 2022 -0800 Branches: master https://developer.blender.org/rB0710ec485e4075bee9b1d1f70bed38c6ecb189f3 Cleanup: Remove unused IMB tile cache code (part 2) Missed in the first commit[1]. Initially it was reported that the `flags` parameter was unused on `imb_cache_filename` but it turns out another swath of code was unused related to that same function. Clean this up now too. [1] 38573d515e49f3e0b22b0e58c7b0357bae107a4d === M source/blender/imbuf/IMB_imbuf_types.h M source/blender/imbuf/intern/readimage.c === diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 0851aaa8669..06f7770d267 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -233,8 +233,6 @@ typedef struct ImBuf { ImbFormatOptions foptions; /** filename associated with this image */ char name[IMB_FILENAME_SIZE]; - /** full filename used for reading from cache */ - char cachename[IMB_FILENAME_SIZE]; /* memory cache limiter */ /** handle for cache limiter */ diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 36714fa90a2..c9b6a6f6f56 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -186,34 +186,22 @@ ImBuf *IMB_loadifffile( return ibuf; } -static void imb_cache_filename(char *filepath, const char *name, int flags) -{ - BLI_strncpy(filepath, name, IMB_FILENAME_SIZE); -} - ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) { ImBuf *ibuf; int file; - char filepath_tx[IMB_FILENAME_SIZE]; BLI_assert(!BLI_path_is_rel(filepath)); - imb_cache_filename(filepath_tx, filepath, flags); - - file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { return NULL; } - ibuf = IMB_loadifffile(file, filepath, flags, colorspace, filepath_tx); + ibuf = IMB_loadifffile(file, filepath, flags, colorspace, filepath); if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); -BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); -for (int a = 1; a < ibuf->miptot; a++) { - BLI_strncpy(ibuf->mipmap[a - 1]->cachename, filepath_tx, sizeof(ibuf->cachename)); -} } close(file); @@ -280,23 +268,19 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) { ImBuf *ibuf; int file; - char filepath_tx[IMB_FILENAME_SIZE]; char colorspace[IM_MAX_SPACE] = "\0"; BLI_assert(!BLI_path_is_rel(filepath)); - imb_cache_filename(filepath_tx, filepath, flags); - - file = BLI_open(filepath_tx, O_BINARY | O_RDONLY, 0); + file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); if (file == -1) { return NULL; } - ibuf = IMB_loadifffile(file, filepath, flags | IB_test | IB_multilayer, colorspace, filepath_tx); + ibuf = IMB_loadifffile(file, filepath, flags | IB_test | IB_multilayer, colorspace, filepath); if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); -BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); } close(file); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [38573d515e4] master: Cleanup: Remove unused IMB tile cache code
Commit: 38573d515e49f3e0b22b0e58c7b0357bae107a4d Author: Jesse Yurkovich Date: Wed Nov 23 19:31:10 2022 -0800 Branches: master https://developer.blender.org/rB38573d515e49f3e0b22b0e58c7b0357bae107a4d Cleanup: Remove unused IMB tile cache code This removes the unused code for the IBM tile cache APIs. These have been unused for as far back as I could manage to search. Since TIFF was used for the cached images, this removal will allow for an easier review when it comes time to move TIFF to OIIO as part of T101413. Differential Revision: https://developer.blender.org/D16587 === M source/blender/imbuf/CMakeLists.txt M source/blender/imbuf/IMB_imbuf.h M source/blender/imbuf/IMB_imbuf_types.h M source/blender/imbuf/intern/IMB_filetype.h M source/blender/imbuf/intern/allocimbuf.c D source/blender/imbuf/intern/cache.c M source/blender/imbuf/intern/filetype.c M source/blender/imbuf/intern/module.c M source/blender/imbuf/intern/readimage.c M source/blender/imbuf/intern/tiff.c === diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 1309e3810be..823866c75bb 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -24,7 +24,6 @@ set(SRC intern/allocimbuf.c intern/anim_movie.c intern/bmp.c - intern/cache.c intern/colormanagement.c intern/colormanagement_inline.c intern/divers.c diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index a05bc51fcea..a5bb34392b1 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -452,17 +452,6 @@ void IMB_makemipmap(struct ImBuf *ibuf, int use_filter); void IMB_remakemipmap(struct ImBuf *ibuf, int use_filter); struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level); -/** - * \attention Defined in cache.c - */ - -/** - * Presumed to be called when no threads are running. - */ -void IMB_tile_cache_params(int totthread, int maxmem); -unsigned int *IMB_gettile(struct ImBuf *ibuf, int tx, int ty, int thread); -void IMB_tiles_to_rect(struct ImBuf *ibuf); - /** * \attention Defined in filter.c */ @@ -816,9 +805,6 @@ bool imb_addrectfloatImBuf(struct ImBuf *ibuf, const unsigned int channels); void imb_freerectfloatImBuf(struct ImBuf *ibuf); void imb_freemipmapImBuf(struct ImBuf *ibuf); -bool imb_addtilesImBuf(struct ImBuf *ibuf); -void imb_freetilesImBuf(struct ImBuf *ibuf); - /** Free all pixel data (associated with image size). */ void imb_freerectImbuf_all(struct ImBuf *ibuf); diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 81e9420c8ba..0851aaa8669 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -144,8 +144,7 @@ typedef enum eImBufFlags { IB_multilayer = 1 << 7, IB_metadata = 1 << 8, IB_animdeinterlace = 1 << 9, - IB_tiles = 1 << 10, - IB_tilecache = 1 << 11, + /** indicates whether image on disk have premul alpha */ IB_alphamode_premul = 1 << 12, /** if this flag is set, alpha mode would be guessed from file */ @@ -202,11 +201,6 @@ typedef struct ImBuf { /** Resolution in pixels per meter. Multiply by `0.0254` for DPI. */ double ppm[2]; - /* tiled pixel storage */ - int tilex, tiley; - int xtiles, ytiles; - unsigned int **tiles; - /* zbuffer */ /** z buffer data, original zbuffer */ int *zbuf; diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index bd17316d173..8252b0dd0b3 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -49,12 +49,6 @@ typedef struct ImFileType { size_t *r_height); /** Save to a file (or memory if #IB_mem is set in `flags` and the format supports it). */ bool (*save)(struct ImBuf *ibuf, const char *filepath, int flags); - void (*load_tile)(struct ImBuf *ibuf, -const unsigned char *mem, -size_t size, -int tx, -int ty, -unsigned int *rect); int flag; @@ -73,15 +67,6 @@ const ImFileType *IMB_file_type_from_ibuf(const struct ImBuf *ibuf); void imb_filetypes_init(void); void imb_filetypes_exit(void); -void imb_tile_cache_init(void); -void imb_tile_cache_exit(void); - -void imb_loadtile(struct ImBuf *ibuf, int tx, int ty, unsigned int *rect); -/** - * External free. - */ -void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty); - /** \} */ /* Type Specific Functions */ @@ -235,8 +220,6 @@ struct ImBuf *imb_loadtiff(const unsigned char *mem, size_t size, int flags,
[Bf-blender-cvs] [4130cad4891] master: Fix T101607: Changing Image source inadvertently clears file path
Commit: 4130cad4891e0ccd568934b0ee5b505d1a933d0f Author: Jesse Yurkovich Date: Sat Oct 22 20:22:31 2022 -0700 Branches: master https://developer.blender.org/rB4130cad4891e0ccd568934b0ee5b505d1a933d0f Fix T101607: Changing Image source inadvertently clears file path This could result in wrong behavior depending on the order in which the Image.filepath and Image.source fields are set from within Python for example. Caused by rB72ab6faf5d80 === M source/blender/blenkernel/intern/image.cc === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 51d8f02616f..eae8b454189 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -3082,16 +3082,10 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) /* Free all but the first tile. */ image_remove_all_tiles(ima); -/* If the remaining tile is generated, we need to again ensure that we - * wouldn't continue to use the old filepath. - * - * Otherwise, if this used to be a UDIM image, get the concrete filepath associated +/* If this used to be a UDIM image, get the concrete filepath associated * with the remaining tile and use that as the new filepath. */ ImageTile *base_tile = BKE_image_get_tile(ima, 0); -if ((base_tile->gen_flag & IMA_GEN_TILE) != 0) { - ima->filepath[0] = '\0'; -} -else if (BKE_image_is_filename_tokenized(ima->filepath)) { +if (BKE_image_is_filename_tokenized(ima->filepath)) { const bool was_relative = BLI_path_is_rel(ima->filepath); eUDIM_TILE_FORMAT tile_format; @@ -3183,10 +3177,14 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) * left. */ image_remove_all_tiles(ima); - int remaining_tile_number = ((ImageTile *)ima->tiles.first)->tile_number; + ImageTile *base_tile = BKE_image_get_tile(ima, 0); + int remaining_tile_number = base_tile->tile_number; bool needs_final_cleanup = true; - /* Add in all the new tiles. */ + /* Add in all the new tiles. As the image is proven to be on disk at this point, remove + * the generation flag from the remaining tile in case this was previously a generated + * image. */ + base_tile->gen_flag &= ~IMA_GEN_TILE; LISTBASE_FOREACH (LinkData *, new_tile, _tiles) { int new_tile_number = POINTER_AS_INT(new_tile->data); BKE_image_add_tile(ima, new_tile_number, nullptr); @@ -3202,6 +3200,11 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) } BLI_freelistN(_tiles); } + else if (ima->filepath[0] != '\0') { +/* If the filepath is set at this point remove the generation flag. */ +ImageTile *base_tile = BKE_image_get_tile(ima, 0); +base_tile->gen_flag &= ~IMA_GEN_TILE; + } if (iuser) { image_tag_reload(ima, nullptr, iuser, ima); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [af34c13da4e] master: Cleanup: Remove data duplication from large array in eevee_camera.hh
Commit: af34c13da4e4566d62c60a7c6aec33f4481bed3c Author: Jesse Yurkovich Date: Sun Oct 9 00:34:59 2022 -0700 Branches: master https://developer.blender.org/rBaf34c13da4e4566d62c60a7c6aec33f4481bed3c Cleanup: Remove data duplication from large array in eevee_camera.hh Use `inline constexpr` instead of `static const` to prevent these variables from being duplicated in each translation unit that includes the eevee_camera.hh header (was included into 17 different object files with MSVC). Differential Revision: https://developer.blender.org/D16200 === M source/blender/draw/engines/eevee_next/eevee_camera.hh === diff --git a/source/blender/draw/engines/eevee_next/eevee_camera.hh b/source/blender/draw/engines/eevee_next/eevee_camera.hh index aaef0f5898d..c1d65dbf31e 100644 --- a/source/blender/draw/engines/eevee_next/eevee_camera.hh +++ b/source/blender/draw/engines/eevee_next/eevee_camera.hh @@ -13,7 +13,7 @@ namespace blender::eevee { class Instance; -static const float cubeface_mat[6][4][4] = { +inline constexpr float cubeface_mat[6][4][4] = { /* Pos X */ {{0.0f, 0.0f, -1.0f, 0.0f}, {0.0f, -1.0f, 0.0f, 0.0f}, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [099ae99589b] master: Fix: Missed return in ASSET_OT_bundle_install item enumerator
Commit: 099ae99589bf21e03bbf380613438114953dd8ea Author: Jesse Yurkovich Date: Thu Sep 8 23:05:35 2022 -0700 Branches: master https://developer.blender.org/rB099ae99589bf21e03bbf380613438114953dd8ea Fix: Missed return in ASSET_OT_bundle_install item enumerator Discovered from inspection. Differential Revision: https://developer.blender.org/D15699 === M source/blender/editors/asset/intern/asset_ops.cc === diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index 05d0b7d0af4..ba7b56db3ec 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -781,6 +781,7 @@ static const EnumPropertyItem *rna_asset_library_reference_itemf(bContext *UNUSE const EnumPropertyItem *items = ED_asset_library_reference_to_rna_enum_itemf(false); if (!items) { *r_free = false; +return nullptr; } *r_free = true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0491ba09c21] master: Cleanup: Remove data duplication from BLI_any.hh support variables
Commit: 0491ba09c21a89f3ac32cb93a7800c95aacb0816 Author: Jesse Yurkovich Date: Thu Aug 18 19:40:15 2022 -0700 Branches: master https://developer.blender.org/rB0491ba09c21a89f3ac32cb93a7800c95aacb0816 Cleanup: Remove data duplication from BLI_any.hh support variables Use `inline constexpr` instead of `static constexpr` to prevent these variables from being duplicated in each translation unit that includes the BLI_any.hh header. Differential Revision: https://developer.blender.org/D15698 === M source/blender/blenlib/BLI_any.hh === diff --git a/source/blender/blenlib/BLI_any.hh b/source/blender/blenlib/BLI_any.hh index a20239f214f..f9b53436763 100644 --- a/source/blender/blenlib/BLI_any.hh +++ b/source/blender/blenlib/BLI_any.hh @@ -39,7 +39,7 @@ template struct AnyTypeInfo { * Used when #T is stored directly in the inline buffer of the #Any. */ template -static constexpr AnyTypeInfo info_for_inline = { +inline constexpr AnyTypeInfo info_for_inline = { is_trivially_copy_constructible_extended_v ? nullptr : +[](void *dst, const void *src) { new (dst) T(*(const T *)src); }, @@ -57,7 +57,7 @@ static constexpr AnyTypeInfo info_for_inline = { */ template using Ptr = std::unique_ptr; template -static constexpr AnyTypeInfo info_for_unique_ptr = { +inline constexpr AnyTypeInfo info_for_unique_ptr = { [](void *dst, const void *src) { new (dst) Ptr(new T(**(const Ptr *)src)); }, [](void *dst, void *src) { new (dst) Ptr(new T(std::move(**(Ptr *)src))); }, [](void *src) { std::destroy_at((Ptr *)src); }, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0d476bcacd1] master: Merge remote-tracking branch 'origin/blender-v3.3-release'
Commit: 0d476bcacd17b82cf596819229d1937be0321250 Author: Jesse Yurkovich Date: Thu Aug 4 19:46:51 2022 -0700 Branches: master https://developer.blender.org/rB0d476bcacd17b82cf596819229d1937be0321250 Merge remote-tracking branch 'origin/blender-v3.3-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bd467100dd3] blender-v3.3-release: Fix T100142: Compare correct render_slot variable during clear operation
Commit: bd467100dd3bd038b0628993f196b44d880ccc98 Author: Jesse Yurkovich Date: Thu Aug 4 19:41:03 2022 -0700 Branches: blender-v3.3-release https://developer.blender.org/rBbd467100dd3bd038b0628993f196b44d880ccc98 Fix T100142: Compare correct render_slot variable during clear operation In {rB0ef8a6179d2a773b2570352bd0cb7eb18b666da2} the parameter name was changed to match the header declaration (slot) but it missed updating the variable name inside the function correctly in one instance. This prevents slot 0 from being cleared if the last slot to be rendered was not also 0. Differential Revision: https://developer.blender.org/D15620 === M source/blender/blenkernel/intern/image.cc === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 975373fcf3b..fa3cc06b087 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -5516,7 +5516,7 @@ bool BKE_image_clear_renderslot(Image *ima, ImageUser *iuser, int slot) } RenderSlot *render_slot = static_cast(BLI_findlink(>renderslots, slot)); - if (!slot) { + if (!render_slot) { return false; } if (render_slot->render) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fdd282021a9] master: Cleanup: Fix compile warnings
Commit: fdd282021a98ac89f40cff7d33f646fb96a96133 Author: Jesse Yurkovich Date: Thu Aug 4 00:45:25 2022 -0700 Branches: master https://developer.blender.org/rBfdd282021a98ac89f40cff7d33f646fb96a96133 Cleanup: Fix compile warnings === M source/blender/editors/space_image/image_buttons.c M source/blender/editors/space_image/image_undo.cc === diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 48f43e05315..2109d3f9701 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -869,7 +869,8 @@ void uiTemplateImage(uiLayout *layout, uiItemS(col); uiItemR(col, , "generated_type", UI_ITEM_R_EXPAND, IFACE_("Type"), ICON_NONE); -if (ima->gen_type == IMA_GENTYPE_BLANK) { +ImageTile *base_tile = BKE_image_get_tile(ima, 0); +if (base_tile->gen_type == IMA_GENTYPE_BLANK) { uiItemR(col, , "generated_color", 0, NULL, ICON_NONE); } } diff --git a/source/blender/editors/space_image/image_undo.cc b/source/blender/editors/space_image/image_undo.cc index 9e8db58ccc2..065641c4051 100644 --- a/source/blender/editors/space_image/image_undo.cc +++ b/source/blender/editors/space_image/image_undo.cc @@ -454,7 +454,6 @@ struct UndoImageBuf { struct { short source; bool use_float; -char gen_type; } image_state; }; @@ -473,7 +472,6 @@ static UndoImageBuf *ubuf_from_image_no_tiles(Image *image, const ImBuf *ibuf) MEM_callocN(sizeof(*ubuf->tiles) * ubuf->tiles_len, __func__)); BLI_strncpy(ubuf->ibuf_name, ibuf->name, sizeof(ubuf->ibuf_name)); - ubuf->image_state.gen_type = image->gen_type; ubuf->image_state.source = image->source; ubuf->image_state.use_float = ibuf->rect_float != nullptr; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [72ab6faf5d8] master: Fix T97251: Store generated type information for each UDIM tile
Commit: 72ab6faf5d80a3d26e5b6252e5b6f0041763209c Author: Jesse Yurkovich Date: Wed Aug 3 22:00:52 2022 -0700 Branches: master https://developer.blender.org/rB72ab6faf5d80a3d26e5b6252e5b6f0041763209c Fix T97251: Store generated type information for each UDIM tile Various situations can lead to un-saved UDIM tiles potentially losing their contents. The most notable situation is a save and re-load of a .blend file that has "generated" UDIM tiles that haven't been written to disk yet. Normal "generated" images are reconstructed on demand in these circumstances but UDIM tiles do not retain the information required for reconstruction and empty tiles are presented to the user. This patch stores the generated type information for each tile to solve this particular issue. It also shifts the Image generation info into the 1st tile. The existing DNA fields are deprecated but RNA was modified as to not break API compat. There's two broad changes here that merit special callout: - How to distinguish between a tile that should be reconstructed vs. a tile that should remain empty because loading failed for the UDIMs - How to better handle Image Source changes The first issue is addressed as follows: - Each time a tile is filled with generated content we set a new IMA_GEN_TILE flag - Each time a tile is saved to disk we remove the IMA_GEN_TILE flag - When requesting an ibuf: If the ibuf is null, we check to see if IMA_GEN_TILE is set. If it is set, go ahead and re-create the tile. Otherwise, do nothing. The second set of changes have to do with ensuring that information is carried along as far as possible when the, sometimes destructive, act of changing an Image Source is performed. Behavior should be a bit more natural and expected now; though users will rarely, or should rarely, be modifying this property. The full table describing the behavior is in the differential. Differential Revision: https://developer.blender.org/D14885 === M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/intern/image.cc M source/blender/blenkernel/intern/image_save.cc M source/blender/blenloader/intern/versioning_300.c M source/blender/editors/space_image/image_ops.c M source/blender/makesdna/DNA_image_types.h M source/blender/makesrna/intern/rna_image.c === diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 8512992282f..8c66e92f762 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -364,14 +364,7 @@ bool BKE_image_remove_tile(struct Image *ima, struct ImageTile *tile); void BKE_image_reassign_tile(struct Image *ima, struct ImageTile *tile, int new_tile_number); void BKE_image_sort_tiles(struct Image *ima); -bool BKE_image_fill_tile(struct Image *ima, - struct ImageTile *tile, - int width, - int height, - const float color[4], - int gen_type, - int planes, - bool is_float); +bool BKE_image_fill_tile(struct Image *ima, struct ImageTile *tile); typedef enum { UDIM_TILE_FORMAT_NONE = 0, diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 4ce413d3705..f3e7ae449a1 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -627,6 +627,16 @@ void BKE_image_free_data(Image *ima) image_free_data(>id); } +static ImageTile *imagetile_alloc(int tile_number) +{ + ImageTile *tile = MEM_cnew("Image Tile"); + tile->tile_number = tile_number; + tile->gen_x = 1024; + tile->gen_y = 1024; + tile->gen_type = IMA_GENTYPE_GRID; + return tile; +} + /* only image block itself */ static void image_init(Image *ima, short source, short type) { @@ -641,8 +651,7 @@ static void image_init(Image *ima, short source, short type) ima->flag |= IMA_VIEW_AS_RENDER; } - ImageTile *tile = MEM_cnew("Image Tiles"); - tile->tile_number = 1001; + ImageTile *tile = imagetile_alloc(1001); BLI_addtail(>tiles, tile); if (type == IMA_TYPE_R_RESULT) { @@ -1100,73 +1109,70 @@ static void image_buf_fill_isolated(void *usersata_v) } } -static ImBuf *add_ibuf_size(unsigned int width, -unsigned int height, -const char *name, -int depth, -int floatbuf, -short gen_type, -const float color[4], -ColorManagedColorspaceSettings *colorspace_settings) +static ImBuf *add_ibuf_for_tile(Image *ima, ImageTile *tile) { ImBuf *ibuf; unsigne
[Bf-blender-cvs] [1a0fab56b4b] master: Merge remote-tracking branch 'origin/blender-v3.3-release'
Commit: 1a0fab56b4bcc641548e82e6a5782acf8deb11fa Author: Jesse Yurkovich Date: Fri Jul 29 23:23:07 2022 -0700 Branches: master https://developer.blender.org/rB1a0fab56b4bcc641548e82e6a5782acf8deb11fa Merge remote-tracking branch 'origin/blender-v3.3-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8ae14bc1d74] blender-v3.3-release: Fix 100035: Make UDIM detection less aggressive
Commit: 8ae14bc1d74021bb1385c46fb637721b4d3dbb2d Author: Jesse Yurkovich Date: Fri Jul 29 23:17:41 2022 -0700 Branches: blender-v3.3-release https://developer.blender.org/rB8ae14bc1d74021bb1385c46fb637721b4d3dbb2d Fix 100035: Make UDIM detection less aggressive There's been a handful of reports where "obviously" not a UDIM filenames were detected as such during image open.[1] This change makes the detection less aggressive by enforcing that the 4-digit sequence be delineated on both sides by one of the following 3 characters ., -, _ This fixes the problem for such filenames as: "screenshot-1080p.png", "Image-1920x1080.png", "(1999) Photo.png", and "antiguaChestnut_X_1240Wx814H.png" [1] T97366 T98918 T99154 T100035 Differential Revision: https://developer.blender.org/D15573 === M source/blender/blenkernel/intern/image.cc M source/blender/blenkernel/intern/image_test.cc === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index c2b8ec95a46..ae5eead2547 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -3410,9 +3410,8 @@ void BKE_image_ensure_tile_token(char *filename) /* General 4-digit "udim" pattern. As this format is susceptible to ambiguity * with other digit sequences, we can leverage the supported range of roughly - * 1000 through 2000 to provide better detection. - */ - std::regex pattern(R"((^|.*?\D)([12]\d{3})(\D.*))"); + * 1000 through 2000 to provide better detection. */ + std::regex pattern(R"((.*[._-])([12]\d{3})([._-].*))"); if (std::regex_search(path, match, pattern)) { BLI_strncpy(filename, match.format("$1$3").c_str(), FILE_MAX); return; diff --git a/source/blender/blenkernel/intern/image_test.cc b/source/blender/blenkernel/intern/image_test.cc index 9c15fc62d21..7004d39c805 100644 --- a/source/blender/blenkernel/intern/image_test.cc +++ b/source/blender/blenkernel/intern/image_test.cc @@ -32,8 +32,12 @@ TEST(udim, image_ensure_tile_token) verify("test_1002_ao.png", "test__ao.png"); verify("test.1002.ver0023.png", "test..ver0023.png"); verify("test.ver0023.1002.png", "test.ver0023..png"); - verify("1002test.png", "test.png"); - verify("test1002.png", "test.png"); + verify("test.1002.1.png", "test..1.png"); + verify("test.1.1002.png", "test.1..png"); + verify("test-2022-01-01.1002.png", "test-2022-01-01..png"); + verify("_11.1002.png", "_11..png"); + verify("2111_01.1002.png", "2111_01..png"); + verify("2022_1002_100200.1002.png", "2022_1002_100200..png"); /* UVTILE pattern detection. */ verify("uv-test.u2_v10.png", "uv-test..png"); @@ -44,8 +48,15 @@ TEST(udim, image_ensure_tile_token) verify("u2_v10uv-test.png", "uv-test.png"); verify("u2_v10u_v-test.png", "u_v-test.png"); - /* Incorrect patterns. */ - for (const char *incorrect : {"test.123.png", + /* Patterns which should not be detected as UDIMs. */ + for (const char *incorrect : {"1002.png", +"1002test.png", +"test1002.png", +"test(1002).png", +"(1002)test.png", +"test-1080p.png", +"test-1920x1080.png", +"test.123.png", "test.12345.png", "test.uv.png", "test.u1v.png", ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [22d276a5dce] blender-v3.2-release: Fix T99785: Make Principled Hair IOR input behave like other IOR sliders
Commit: 22d276a5dce2e9bbe248796a903af4314ce723bd Author: Jesse Yurkovich Date: Mon Jul 18 20:37:11 2022 -0700 Branches: blender-v3.2-release https://developer.blender.org/rB22d276a5dce2e9bbe248796a903af4314ce723bd Fix T99785: Make Principled Hair IOR input behave like other IOR sliders Was accidental regression in rBed9b21098dd27bf9364397357f89b4c2648f40c2 Remove the input slider's PROP_FACTOR subtype in favor of the default to align with other IOR sliders. This provides much better control when dragging the value with the mouse. Differential Revision: https://developer.blender.org/D15477 === M source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc === diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index 6495dcfffba..a0579372a15 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -42,8 +42,7 @@ static void node_declare(NodeDeclarationBuilder ) .min(0.0f) .max(1.0f) .subtype(PROP_FACTOR); - b.add_input(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f).subtype( - PROP_FACTOR); + b.add_input(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f); b.add_input(N_("Offset")) .default_value(2.0f * ((float)M_PI) / 180.0f) .min(-M_PI_2) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [533a5a6a8c6] master: Fix T99785: Make Principled Hair IOR input behave like other IOR sliders
Commit: 533a5a6a8c60686dd7d627cf7815915d7a6b467b Author: Jesse Yurkovich Date: Mon Jul 18 20:37:11 2022 -0700 Branches: master https://developer.blender.org/rB533a5a6a8c60686dd7d627cf7815915d7a6b467b Fix T99785: Make Principled Hair IOR input behave like other IOR sliders Was accidental regression in rBed9b21098dd27bf9364397357f89b4c2648f40c2 Remove the input slider's PROP_FACTOR subtype in favor of the default to align with other IOR sliders. This provides much better control when dragging the value with the mouse. Differential Revision: https://developer.blender.org/D15477 === M source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc === diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index 6495dcfffba..a0579372a15 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -42,8 +42,7 @@ static void node_declare(NodeDeclarationBuilder ) .min(0.0f) .max(1.0f) .subtype(PROP_FACTOR); - b.add_input(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f).subtype( - PROP_FACTOR); + b.add_input(N_("IOR")).default_value(1.55f).min(0.0f).max(1000.0f); b.add_input(N_("Offset")) .default_value(2.0f * ((float)M_PI) / 180.0f) .min(-M_PI_2) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [675f6ef089c] master: Cleanup: Use const pointers for ImageSaveOptions and ImageFormatData
Commit: 675f6ef089ceeed2f03284e7e81e6af7130e46d7 Author: Jesse Yurkovich Date: Thu Jul 14 21:27:58 2022 -0700 Branches: master https://developer.blender.org/rB675f6ef089ceeed2f03284e7e81e6af7130e46d7 Cleanup: Use const pointers for ImageSaveOptions and ImageFormatData Use const pointers to ImageSaveOptions and ImageFormatData for API parameters where appropriate. Differential Revision: https://developer.blender.org/D15400 === M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/BKE_image_save.h M source/blender/blenkernel/BKE_writeffmpeg.h M source/blender/blenkernel/intern/image.cc M source/blender/blenkernel/intern/image_save.cc M source/blender/blenkernel/intern/writeffmpeg.c M source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc M source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h M source/blender/compositor/operations/COM_OutputFileOperation.cc M source/blender/compositor/operations/COM_OutputFileOperation.h M source/blender/editors/object/object_bake_api.c M source/blender/editors/space_image/image_ops.c M source/blender/nodes/NOD_composite.h M source/blender/nodes/composite/nodes/node_composite_output_file.cc === diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 6ec1285af0c..4e622a5708f 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -97,7 +97,7 @@ int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, const struct ImageForm */ int BKE_imbuf_write_as(struct ImBuf *ibuf, const char *name, - struct ImageFormatData *imf, + const struct ImageFormatData *imf, bool save_copy); /** diff --git a/source/blender/blenkernel/BKE_image_save.h b/source/blender/blenkernel/BKE_image_save.h index 673a7dffb82..e17136174eb 100644 --- a/source/blender/blenkernel/BKE_image_save.h +++ b/source/blender/blenkernel/BKE_image_save.h @@ -48,14 +48,14 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, struct ImageUser *iuser, const bool guess_path, const bool save_as_render); -void BKE_image_save_options_update(struct ImageSaveOptions *opts, struct Image *ima); +void BKE_image_save_options_update(struct ImageSaveOptions *opts, const struct Image *ima); void BKE_image_save_options_free(struct ImageSaveOptions *opts); bool BKE_image_save(struct ReportList *reports, struct Main *bmain, struct Image *ima, struct ImageUser *iuser, -struct ImageSaveOptions *opts); +const struct ImageSaveOptions *opts); /* Render saving. */ diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index 3f92d6fa117..736f7548bb4 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -68,7 +68,7 @@ void BKE_ffmpeg_filepath_get(char *string, const char *suffix); void BKE_ffmpeg_preset_set(struct RenderData *rd, int preset); -void BKE_ffmpeg_image_type_verify(struct RenderData *rd, struct ImageFormatData *imf); +void BKE_ffmpeg_image_type_verify(struct RenderData *rd, const struct ImageFormatData *imf); bool BKE_ffmpeg_alpha_channel_is_supported(const struct RenderData *rd); void *BKE_ffmpeg_context_create(void); diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 92e98935e83..6ec1c52c61a 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -2475,7 +2475,10 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, const ImageFormatData *imf) return ok; } -int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, const bool save_copy) +int BKE_imbuf_write_as(ImBuf *ibuf, + const char *name, + const ImageFormatData *imf, + const bool save_copy) { ImBuf ibuf_back = *ibuf; int ok; diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 3f6f81845e2..cd86d3f7087 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -204,7 +204,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, return (ibuf != nullptr); } -void BKE_image_save_options_update(ImageSaveOptions *opts, Image *image) +void BKE_image_save_options_update(ImageSaveOptions *opts, const Image *image) { /* Auto update color space when
[Bf-blender-cvs] [14980c9b3ad] master: Fix: Save modified images during file close
Commit: 14980c9b3ad849340cad2cce5aa475228ff0c2b4 Author: Jesse Yurkovich Date: Thu Jul 7 02:36:54 2022 -0700 Branches: master https://developer.blender.org/rB14980c9b3ad849340cad2cce5aa475228ff0c2b4 Fix: Save modified images during file close Regressed in the following commit due to an inverted conditional: {rB1159b63a07fd2cbc7fc48e162d57721c9c85b3f6} Differential Revision: https://developer.blender.org/D15389 === M source/blender/editors/space_image/image_ops.c === diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b77bdc11ca5..49420e9a2a1 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2391,7 +2391,7 @@ bool ED_image_save_all_modified(const bContext *C, ReportList *reports) if (image_has_valid_path(ima)) { ImageSaveOptions opts; Scene *scene = CTX_data_scene(C); - if (!BKE_image_save_options_init(, bmain, scene, ima, NULL, false, false)) { + if (BKE_image_save_options_init(, bmain, scene, ima, NULL, false, false)) { bool saved_successfully = BKE_image_save(reports, bmain, ima, NULL, ); ok = ok && saved_successfully; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f2562018762] master: Fix T99388: Obey relative path option when saving UDIMs
Commit: f25620187620e75772adc18eaf121ef00416c791 Author: Jesse Yurkovich Date: Thu Jul 7 02:08:32 2022 -0700 Branches: master https://developer.blender.org/rBf25620187620e75772adc18eaf121ef00416c791 Fix T99388: Obey relative path option when saving UDIMs Ensure that the Image maintains the proper file path after saving all the individual tiles. The image_save_post function is unaware that the filepath it receives is only for a single tile, not the entire Image, and happily keeps setting ima->filepath to the concrete filepath for each tile. There were 2 problems with the code that attempted to correct the Image filepath back to the UDIM virtual form: - It would trample the "relative" directory that might have been set - It would do the wrong thing if no tiles could be saved at all The design is now as follows: Example of trying to save to a new PathB | | all tiles ok | any tile not ok| | | | ---| | ima->filepath is currently empty | set to new PathB | keep empty | | ima->filepath is currently PathA | set to new PathB | keep PathA | Differential Revision: https://developer.blender.org/D15384 === M source/blender/blenkernel/intern/image_save.cc === diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 9dda3762553..07ffc35907a 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -253,6 +253,21 @@ void BKE_image_save_options_free(ImageSaveOptions *opts) BKE_image_format_free(>im_format); } +static void image_save_update_filepath(Image *ima, + const char *filepath, + const ImageSaveOptions *opts) +{ + if (opts->do_newpath) { +BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath)); + +/* only image path, never ibuf */ +if (opts->relative) { + const char *relbase = ID_BLEND_PATH(opts->bmain, >id); + BLI_path_rel(ima->filepath, relbase); /* only after saving */ +} + } +} + static void image_save_post(ReportList *reports, Image *ima, ImBuf *ibuf, @@ -273,13 +288,11 @@ static void image_save_post(ReportList *reports, if (opts->do_newpath) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); -BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath)); + } -/* only image path, never ibuf */ -if (opts->relative) { - const char *relbase = ID_BLEND_PATH(opts->bmain, >id); - BLI_path_rel(ima->filepath, relbase); /* only after saving */ -} + /* The tiled image codepath must call this on its own. */ + if (ima->source != IMA_SRC_TILED) { +image_save_update_filepath(ima, filepath, opts); } ibuf->userflags &= ~IB_BITMAPDIRTY; @@ -640,22 +653,23 @@ bool BKE_image_save( ok = image_save_single(reports, ima, iuser, opts, _changed); } else { -char filepath[FILE_MAX]; -BLI_strncpy(filepath, opts->filepath, sizeof(filepath)); - /* Save all the tiles. */ LISTBASE_FOREACH (ImageTile *, tile, >tiles) { + ImageSaveOptions tile_opts = *opts; BKE_image_set_filepath_from_tile_number( - opts->filepath, udim_pattern, tile_format, tile->tile_number); + tile_opts.filepath, udim_pattern, tile_format, tile->tile_number); iuser->tile = tile->tile_number; - ok = image_save_single(reports, ima, iuser, opts, _changed); + ok = image_save_single(reports, ima, iuser, _opts, _changed); if (!ok) { break; } } -BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath)); -BLI_strncpy(opts->filepath, filepath, sizeof(opts->filepath)); + +/* Set the image path only if all tiles were ok. */ +if (ok) { + image_save_update_filepath(ima, opts->filepath, opts); +} MEM_freeN(udim_pattern); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [581604d17ab] blender-v3.2-release: OBJ: Use filename as the default object name
Commit: 581604d17ab7dad152a55fe555f0c68f9cf75219 Author: Jesse Yurkovich Date: Mon Jun 6 22:34:06 2022 -0700 Branches: blender-v3.2-release https://developer.blender.org/rB581604d17ab7dad152a55fe555f0c68f9cf75219 OBJ: Use filename as the default object name To match the existing Python .obj importer, and to make it easier for the user to determine which object is which, use the filename for the default object name instead of "New object". Differential Revision: https://developer.blender.org/D15133 === M source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc M source/blender/io/wavefront_obj/tests/obj_importer_tests.cc === diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index c069093ac06..f1c9959cae5 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -342,9 +342,14 @@ void OBJParser::parse(Vector> _all_geometries, return; } + /* Use the filename as the default name given to the initial object. */ + char ob_name[FILE_MAXFILE]; + BLI_strncpy(ob_name, BLI_path_basename(import_params_.filepath), FILE_MAXFILE); + BLI_path_extension_replace(ob_name, FILE_MAXFILE, ""); + VertexIndexOffset offsets; Geometry *curr_geom = create_geometry( - nullptr, GEOM_MESH, "", r_global_vertices, r_all_geometries, offsets); + nullptr, GEOM_MESH, ob_name, r_global_vertices, r_all_geometries, offsets); /* State variables: once set, they remain the same for the remaining * elements in the object. */ diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc index 3d34fb6f9c6..e959f71fffb 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -133,7 +133,7 @@ TEST_F(obj_importer_test, import_cube) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", + {"OBcube", OB_MESH, 8, 12, @@ -168,7 +168,7 @@ TEST_F(obj_importer_test, import_nurbs) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", + {"OBnurbs", OB_CURVES_LEGACY, 12, 0, @@ -184,7 +184,7 @@ TEST_F(obj_importer_test, import_nurbs_curves) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)}, + {"OBnurbs_curves", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)}, {"OBNurbsCurveDiffWeights", OB_CURVES_LEGACY, 4, @@ -211,7 +211,7 @@ TEST_F(obj_importer_test, import_nurbs_cyclic) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", + {"OBnurbs_cyclic", OB_CURVES_LEGACY, 31, 0, @@ -262,7 +262,7 @@ TEST_F(obj_importer_test, import_materials) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)}, + {"OBmaterials", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)}, }; import_and_check("materials.obj", expect, std::size(expect), 4); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [99847cd6423] master: OBJ: Use filename as the default object name
Commit: 99847cd642385105e06a486200d377a682b597a0 Author: Jesse Yurkovich Date: Mon Jun 6 22:34:06 2022 -0700 Branches: master https://developer.blender.org/rB99847cd642385105e06a486200d377a682b597a0 OBJ: Use filename as the default object name To match the existing Python .obj importer, and to make it easier for the user to determine which object is which, use the filename for the default object name instead of "New object". Differential Revision: https://developer.blender.org/D15133 === M source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc M source/blender/io/wavefront_obj/tests/obj_importer_tests.cc === diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index c7990028312..a627e7261e3 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -343,9 +343,14 @@ void OBJParser::parse(Vector> _all_geometries, return; } + /* Use the filename as the default name given to the initial object. */ + char ob_name[FILE_MAXFILE]; + BLI_strncpy(ob_name, BLI_path_basename(import_params_.filepath), FILE_MAXFILE); + BLI_path_extension_replace(ob_name, FILE_MAXFILE, ""); + VertexIndexOffset offsets; Geometry *curr_geom = create_geometry( - nullptr, GEOM_MESH, "", r_global_vertices, r_all_geometries, offsets); + nullptr, GEOM_MESH, ob_name, r_global_vertices, r_all_geometries, offsets); /* State variables: once set, they remain the same for the remaining * elements in the object. */ diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc index 48990975416..235e9ac77e6 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -133,7 +133,7 @@ TEST_F(obj_importer_test, import_cube) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", + {"OBcube", OB_MESH, 8, 12, @@ -168,7 +168,7 @@ TEST_F(obj_importer_test, import_nurbs) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", + {"OBnurbs", OB_CURVES_LEGACY, 12, 0, @@ -184,7 +184,7 @@ TEST_F(obj_importer_test, import_nurbs_curves) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)}, + {"OBnurbs_curves", OB_CURVES_LEGACY, 4, 0, 4, 0, float3(2, -2, 0), float3(-2, -2, 0)}, {"OBNurbsCurveDiffWeights", OB_CURVES_LEGACY, 4, @@ -211,7 +211,7 @@ TEST_F(obj_importer_test, import_nurbs_cyclic) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", + {"OBnurbs_cyclic", OB_CURVES_LEGACY, 31, 0, @@ -262,7 +262,7 @@ TEST_F(obj_importer_test, import_materials) { Expectation expect[] = { {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, - {"OBNew object", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)}, + {"OBmaterials", OB_MESH, 8, 12, 6, 24, float3(-1, -1, 1), float3(1, -1, -1)}, }; import_and_check("materials.obj", expect, std::size(expect), 4); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ee57afe7e15] master: Merge remote-tracking branch 'origin/blender-v3.2-release'
Commit: ee57afe7e1536dc45b50093d2284180e80038db3 Author: Jesse Yurkovich Date: Tue May 31 21:09:35 2022 -0700 Branches: master https://developer.blender.org/rBee57afe7e1536dc45b50093d2284180e80038db3 Merge remote-tracking branch 'origin/blender-v3.2-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [12642bdeabe] blender-v3.2-release: Fix T96984: Create new image.browse operator for uiTemplateImage layouts
Commit: 12642bdeabeb35802ee196868c9dbd23c153f622 Author: Jesse Yurkovich Date: Tue May 31 20:57:33 2022 -0700 Branches: blender-v3.2-release https://developer.blender.org/rB12642bdeabeb35802ee196868c9dbd23c153f622 Fix T96984: Create new image.browse operator for uiTemplateImage layouts The existing BUTTONS_OT_file_browse operator that's used for uiTemplateImage layouts fails to work correctly with UDIM textures. This is mainly due to it not realizing that it must tokenize the filepath before signaling that an update has been made. It also doesn't work correctly when executing its SHIFT-click behavior to open the image in an external application. Lastly, it doesn't set the filters to Images and Movies which is suboptimal for the user. The new operator takes the unique features of BUTTONS_OT_file_browse and creates a customized variant better suited for images. Differential Revision: https://developer.blender.org/D14824 === M source/blender/editors/space_image/image_buttons.c M source/blender/editors/space_image/image_intern.h M source/blender/editors/space_image/image_ops.c M source/blender/editors/space_image/space_image.c === diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 208928afc1f..d0c21f85472 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -845,7 +845,10 @@ void uiTemplateImage(uiLayout *layout, row = uiLayoutRow(row, true); uiLayoutSetEnabled(row, is_packed == false); -uiItemR(row, , "filepath", 0, "", ICON_NONE); + +prop = RNA_struct_find_property(, "filepath"); +uiDefAutoButR(block, , prop, -1, "", ICON_NONE, 0, 0, 200, UI_UNIT_Y); +uiItemO(row, "", ICON_FILEBROWSER, "image.file_browse"); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 2322420069e..364bec1377d 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -49,6 +49,7 @@ void IMAGE_OT_new(struct wmOperatorType *ot); * Called by other space types too. */ void IMAGE_OT_open(struct wmOperatorType *ot); +void IMAGE_OT_file_browse(struct wmOperatorType *ot); /** * Called by other space types too. */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 68d342e2143..b01eec53e73 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1534,6 +1534,120 @@ void IMAGE_OT_open(wmOperatorType *ot) /** \} */ +/* */ +/** \name Browse Image Operator + * \{ */ + +static int image_file_browse_exec(bContext *C, wmOperator *op) +{ + Image *ima = op->customdata; + if (ima == NULL) { +return OPERATOR_CANCELLED; + } + + char filepath[FILE_MAX]; + RNA_string_get(op->ptr, "filepath", filepath); + + /* If loading into a tiled texture, ensure that the filename is tokenized. */ + if (ima->source == IMA_SRC_TILED) { +char *filename = (char *)BLI_path_basename(filepath); +BKE_image_ensure_tile_token(filename); + } + + PointerRNA imaptr; + PropertyRNA *imaprop; + RNA_id_pointer_create(>id, ); + imaprop = RNA_struct_find_property(, "filepath"); + + RNA_property_string_set(, imaprop, filepath); + RNA_property_update(C, , imaprop); + + return OPERATOR_FINISHED; +} + +static int image_file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + Image *ima = image_from_context(C); + if (!ima) { +return OPERATOR_CANCELLED; + } + + char filepath[FILE_MAX]; + BLI_strncpy(filepath, ima->filepath, sizeof(filepath)); + + /* Shift+Click to open the file, Alt+Click to browse a folder in the OS's browser. */ + if (event->modifier & (KM_SHIFT | KM_ALT)) { +wmOperatorType *ot = WM_operatortype_find("WM_OT_path_open", true); +PointerRNA props_ptr; + +if (event->modifier & KM_ALT) { + char *lslash = (char *)BLI_path_slash_rfind(filepath); + if (lslash) { +*lslash = '\0'; + } +} +else if (ima->source == IMA_SRC_TILED) { + ImageUser iuser; + BKE_imageuser_default(); + + /* Use the file associated with the active tile. Otherwise use the first tile. */ + const ImageTile *active = (ImageTile *)BLI_findlink(>tiles, ima->active_tile_index); + iuser.tile = active ? active->tile_number : ((ImageTile *)ima->tiles.first)->tile_number; + BKE_image_user_file_path(, ima
[Bf-blender-cvs] [138a4846e2d] master: Merge remote-tracking branch 'origin/blender-v3.2-release'
Commit: 138a4846e2dbb719a4e8f39b7ffd2d0f95db06c6 Author: Jesse Yurkovich Date: Fri May 27 22:16:14 2022 -0700 Branches: master https://developer.blender.org/rB138a4846e2dbb719a4e8f39b7ffd2d0f95db06c6 Merge remote-tracking branch 'origin/blender-v3.2-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [86baf6e3edc] blender-v3.2-release: Re-fix T97366: Support single-file UDIMs
Commit: 86baf6e3edc8925c0701786550b2bac8fe5203d3 Author: Jesse Yurkovich Date: Fri May 27 22:11:52 2022 -0700 Branches: blender-v3.2-release https://developer.blender.org/rB86baf6e3edc8925c0701786550b2bac8fe5203d3 Re-fix T97366: Support single-file UDIMs The original fix for T97366 was too restrictive and breaks real-world cases of single-file UDIM textures. See D13297 for an example. This patch effectively reverts the original fix and instead fixes the downstream code to accept single-file ranges as necessary. Note: This means it is very important for users to make use of the "UDIM detection" option during `image.open` or drag n' drop scenarios in order to declare their intent when loading their files. Differential Revision: https://developer.blender.org/D14853 === M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/intern/image.cc M source/blender/editors/include/ED_image.h M source/blender/editors/space_image/image_ops.c M source/blender/editors/space_image/image_sequence.c === diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 42d0e66cf49..0417f335d11 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -378,6 +378,11 @@ typedef enum { UDIM_TILE_FORMAT_UVTILE = 2 } eUDIM_TILE_FORMAT; +/** + * Checks if the filename portion of the path contains a UDIM token. + */ +bool BKE_image_is_filename_tokenized(char *filepath); + /** * Ensures that `filename` contains a UDIM token if we find a supported format pattern. * \note This must only be the name component (without slashes). diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index dfa820519a5..4bf25c24235 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -2927,6 +2927,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) MEM_freeN(tile); } base_tile->next = nullptr; +base_tile->tile_number = 1001; ima->tiles.last = base_tile; } @@ -3108,7 +3109,9 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, char filename[FILE_MAXFILE], dirname[FILE_MAXDIR]; BLI_split_dirfile(filepath, dirname, filename, sizeof(dirname), sizeof(filename)); - BKE_image_ensure_tile_token(filename); + if (!BKE_image_is_filename_tokenized(filename)) { +BKE_image_ensure_tile_token(filename); + } eUDIM_TILE_FORMAT tile_format; char *udim_pattern = BKE_image_get_tile_strformat(filename, _format); @@ -3142,10 +3145,7 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, BLI_filelist_free(dirs, dirs_num); MEM_SAFE_FREE(udim_pattern); - /* Ensure that all discovered UDIMs are valid and that there's at least 2 files in total. - * Downstream code checks the range value to determine tiled-ness; it's important we match that - * expectation here too (T97366). */ - if (all_valid_udim && min_udim <= IMA_UDIM_MAX && max_udim > min_udim) { + if (all_valid_udim && min_udim <= IMA_UDIM_MAX) { BLI_join_dirfile(filepath, FILE_MAX, dirname, filename); *r_tile_start = min_udim; @@ -3317,13 +3317,18 @@ bool BKE_image_fill_tile(struct Image *ima, return false; } +bool BKE_image_is_filename_tokenized(char *filepath) +{ + const char *filename = BLI_path_basename(filepath); + return strstr(filename, "") != nullptr || strstr(filename, "") != nullptr; +} + void BKE_image_ensure_tile_token(char *filename) { BLI_assert_msg(BLI_path_slash_find(filename) == nullptr, "Only the file-name component should be used!"); - /* Is there a '<' character in the filename? Assume tokens already present. */ - if (strstr(filename, "<") != nullptr) { + if (BKE_image_is_filename_tokenized(filename)) { return; } diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index f79d3ce205d..774115fa188 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -173,6 +173,7 @@ typedef struct ImageFrameRange { int length; int offset; /* UDIM tiles. */ + bool udims_detected; ListBase udim_tiles; /* Temporary data. */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index aa77aab2283..68d342e2143 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1274,8 +1274,8 @@ static Image *image_open_single(Main *bmain, BKE_image_free_views(ima); } -if ((range->lengt
[Bf-blender-cvs] [3f1f4df3fd9] master: Fix unreported misuse of Win32 clipboard API
Commit: 3f1f4df3fd9b37fb97fbf4632725032de87d0828 Author: Jesse Yurkovich Date: Fri May 27 20:52:52 2022 -0700 Branches: master https://developer.blender.org/rB3f1f4df3fd9b37fb97fbf4632725032de87d0828 Fix unreported misuse of Win32 clipboard API An ASAN build highlighted a longstanding bug during ctrl+c operations inside various text widgets. The existing code had mismatched memory lock/unlock calls and was using the wrong allocator. Fix the code surrounding `SetClipboardData` to be correct per MSDN: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setclipboarddata Differential Revision: https://developer.blender.org/D15039 === M intern/ghost/intern/GHOST_SystemWin32.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 8e07bf4ea3d..28c86db53e2 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -2211,31 +2211,28 @@ char *GHOST_SystemWin32::getClipboard(bool selection) const void GHOST_SystemWin32::putClipboard(const char *buffer, bool selection) const { - if (selection) { + if (selection || !buffer) { return; } // for copying the selection, used on X11 if (OpenClipboard(NULL)) { -HLOCAL clipbuffer; -wchar_t *data; +EmptyClipboard(); -if (buffer) { - size_t len = count_utf_16_from_8(buffer); - EmptyClipboard(); +// Get length of buffer including the terminating null +size_t len = count_utf_16_from_8(buffer); - clipbuffer = LocalAlloc(LMEM_FIXED, sizeof(wchar_t) * len); - data = (wchar_t *)GlobalLock(clipbuffer); +HGLOBAL clipbuffer = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * len); +if (clipbuffer) { + wchar_t *data = (wchar_t *)GlobalLock(clipbuffer); conv_utf_8_to_16(buffer, data, len); - LocalUnlock(clipbuffer); + GlobalUnlock(clipbuffer); SetClipboardData(CF_UNICODETEXT, clipbuffer); } + CloseClipboard(); } - else { -return; - } } /* */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [51195c17ac4] master: Merge remote-tracking branch 'origin/blender-v3.2-release'
Commit: 51195c17ac441b44117a19d0408cdcf13d0466c5 Author: Jesse Yurkovich Date: Tue May 17 00:30:54 2022 -0700 Branches: master https://developer.blender.org/rB51195c17ac441b44117a19d0408cdcf13d0466c5 Merge remote-tracking branch 'origin/blender-v3.2-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [210d0f1b801] blender-v3.2-release: Fix T96414: Stencil mapping is incorrect for UDIMs
Commit: 210d0f1b801fb23c7edabb35b67224eab671e363 Author: Jesse Yurkovich Date: Tue May 17 00:27:23 2022 -0700 Branches: blender-v3.2-release https://developer.blender.org/rB210d0f1b801fb23c7edabb35b67224eab671e363 Fix T96414: Stencil mapping is incorrect for UDIMs When texture painting, brush textures and brush texture masks were not transformed to account for UDIM tiles. Differential Revision: https://developer.blender.org/D14671 === M source/blender/editors/sculpt_paint/paint_image_2d.c === diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index d30aa4dfab1..fae2e6863fa 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -621,39 +621,38 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter, } static void brush_painter_2d_tex_mapping(ImagePaintState *s, - ImBuf *canvas, + ImagePaintTile *tile, const int diameter, - const float startpos[2], const float pos[2], const float mouse[2], int mapmode, rctf *mapping) { - float invw = 1.0f / (float)canvas->x; - float invh = 1.0f / (float)canvas->y; - int xmin, ymin, xmax, ymax; - int ipos[2]; + float invw = 1.0f / (float)tile->canvas->x; + float invh = 1.0f / (float)tile->canvas->y; + float start[2]; /* find start coordinate of brush in canvas */ - ipos[0] = (int)floorf((pos[0] - diameter / 2) + 1.0f); - ipos[1] = (int)floorf((pos[1] - diameter / 2) + 1.0f); + start[0] = pos[0] - diameter / 2.0f; + start[1] = pos[1] - diameter / 2.0f; if (mapmode == MTEX_MAP_MODE_STENCIL) { /* map from view coordinates of brush to region coordinates */ -UI_view2d_view_to_region(s->v2d, ipos[0] * invw, ipos[1] * invh, , ); -UI_view2d_view_to_region( -s->v2d, (ipos[0] + diameter) * invw, (ipos[1] + diameter) * invh, , ); +float xmin, ymin, xmax, ymax; +UI_view2d_view_to_region_fl(s->v2d, start[0] * invw, start[1] * invh, , ); +UI_view2d_view_to_region_fl( +s->v2d, (start[0] + diameter) * invw, (start[1] + diameter) * invh, , ); /* output mapping from brush ibuf x/y to region coordinates */ -mapping->xmin = xmin; -mapping->ymin = ymin; mapping->xmax = (xmax - xmin) / (float)diameter; mapping->ymax = (ymax - ymin) / (float)diameter; +mapping->xmin = xmin + (tile->uv_origin[0] * tile->size[0] * mapping->xmax); +mapping->ymin = ymin + (tile->uv_origin[1] * tile->size[1] * mapping->ymax); } else if (mapmode == MTEX_MAP_MODE_3D) { /* 3D mapping, just mapping to canvas 0..1. */ -mapping->xmin = 2.0f * (ipos[0] * invw - 0.5f); -mapping->ymin = 2.0f * (ipos[1] * invh - 0.5f); +mapping->xmin = 2.0f * (start[0] * invw - 0.5f); +mapping->ymin = 2.0f * (start[1] * invh - 0.5f); mapping->xmax = 2.0f * invw; mapping->ymax = 2.0f * invh; } @@ -665,8 +664,10 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s, mapping->ymax = 1.0f; } else /* if (mapmode == MTEX_MAP_MODE_TILED) */ { -mapping->xmin = (int)(-diameter * 0.5) + (int)floorf(pos[0]) - (int)floorf(startpos[0]); -mapping->ymin = (int)(-diameter * 0.5) + (int)floorf(pos[1]) - (int)floorf(startpos[1]); +mapping->xmin = (int)(-diameter * 0.5) + (int)floorf(pos[0]) - +(int)floorf(tile->start_paintpos[0]); +mapping->ymin = (int)(-diameter * 0.5) + (int)floorf(pos[1]) - +(int)floorf(tile->start_paintpos[1]); mapping->xmax = 1.0f; mapping->ymax = 1.0f; } @@ -711,14 +712,8 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, do_partial_update = true; } -brush_painter_2d_tex_mapping(s, - tile->canvas, - diameter, - tile->start_paintpos, - pos, - mouse, - brush->mtex.brush_map_mode, - >tex_mapping); +brush_painter_2d_tex_mapping( +s, tile, diameter, pos, mouse, brush->mtex.brush_map_mode, >tex_mapping); } if (cache->is_maskbrush) { @@ -745,14 +740,8 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, renew_maxmask) { MEM_SAFE_FREE(cache->tex_mask);
[Bf-blender-cvs] [578771ae4dc] master: UDIM: Add support for packing inside .blend files
Commit: 578771ae4dcb8643214c69a7b9761ca154f40f63 Author: Jesse Yurkovich Date: Wed May 11 20:11:44 2022 -0700 Branches: master https://developer.blender.org/rB578771ae4dcb8643214c69a7b9761ca154f40f63 UDIM: Add support for packing inside .blend files This completes support for tiled texture packing on the Blender / Cycles side of things. Most of these changes fall into one of three categories: - Updating Image handling code to pack/unpack tiled and multi-view images - Updating Cycles to handle tiled textures through BlenderImageLoader - Updating OSL to properly handle textures with multiple slots Differential Revision: https://developer.blender.org/D14395 === M intern/cycles/blender/image.cpp M intern/cycles/blender/image.h M intern/cycles/blender/shader.cpp M intern/cycles/kernel/osl/services.cpp M intern/cycles/kernel/osl/services.h M intern/cycles/scene/image.cpp M intern/cycles/scene/image.h M intern/cycles/scene/osl.cpp M intern/cycles/scene/osl.h M intern/cycles/scene/shader_nodes.cpp M source/blender/blenkernel/intern/image.cc M source/blender/blenkernel/intern/packedFile.c M source/blender/blenloader/intern/versioning_300.c M source/blender/editors/space_image/image_ops.c M source/blender/makesdna/DNA_image_types.h M source/blender/makesrna/intern/rna_image.c M source/blender/makesrna/intern/rna_image_api.c === diff --git a/intern/cycles/blender/image.cpp b/intern/cycles/blender/image.cpp index ca4c8f5904a..e01b72c1653 100644 --- a/intern/cycles/blender/image.cpp +++ b/intern/cycles/blender/image.cpp @@ -13,9 +13,11 @@ CCL_NAMESPACE_BEGIN BlenderImageLoader::BlenderImageLoader(BL::Image b_image, const int frame, + const int tile_number, const bool is_preview_render) : b_image(b_image), frame(frame), + tile_number(tile_number), /* Don't free cache for preview render to avoid race condition from T93560, to be fixed properly later as we are close to release. */ free_cache(!is_preview_render && !b_image.has_data()) @@ -66,12 +68,11 @@ bool BlenderImageLoader::load_pixels(const ImageMetaData , { const size_t num_pixels = ((size_t)metadata.width) * metadata.height; const int channels = metadata.channels; - const int tile = 0; /* TODO(lukas): Support tiles here? */ if (b_image.is_float()) { /* image data */ float *image_pixels; -image_pixels = image_get_float_pixels_for_frame(b_image, frame, tile); +image_pixels = image_get_float_pixels_for_frame(b_image, frame, tile_number); if (image_pixels && num_pixels * channels == pixels_size) { memcpy(pixels, image_pixels, pixels_size * sizeof(float)); @@ -99,7 +100,7 @@ bool BlenderImageLoader::load_pixels(const ImageMetaData , } } else { -unsigned char *image_pixels = image_get_pixels_for_frame(b_image, frame, tile); +unsigned char *image_pixels = image_get_pixels_for_frame(b_image, frame, tile_number); if (image_pixels && num_pixels * channels == pixels_size) { memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char)); @@ -153,7 +154,13 @@ string BlenderImageLoader::name() const bool BlenderImageLoader::equals(const ImageLoader ) const { const BlenderImageLoader _loader = (const BlenderImageLoader &)other; - return b_image == other_loader.b_image && frame == other_loader.frame; + return b_image == other_loader.b_image && frame == other_loader.frame && + tile_number == other_loader.tile_number; +} + +int BlenderImageLoader::get_tile_number() const +{ + return tile_number; } /* Point Density */ diff --git a/intern/cycles/blender/image.h b/intern/cycles/blender/image.h index ee576b31f7e..c2cc0f51b9b 100644 --- a/intern/cycles/blender/image.h +++ b/intern/cycles/blender/image.h @@ -12,7 +12,10 @@ CCL_NAMESPACE_BEGIN class BlenderImageLoader : public ImageLoader { public: - BlenderImageLoader(BL::Image b_image, const int frame, const bool is_preview_render); + BlenderImageLoader(BL::Image b_image, + const int frame, + const int tile_number, + const bool is_preview_render); bool load_metadata(const ImageDeviceFeatures , ImageMetaData ) override; bool load_pixels(const ImageMetaData , @@ -22,8 +25,11 @@ class BlenderImageLoader : public ImageLoader { string name() const override; bool equals(const ImageLoader ) const override; + int get_tile_number() const override; + BL::Image b_image; int frame; + int tile_number; bool free_cache; }; diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cp
[Bf-blender-cvs] [2a2261d7e19] master: Cleanup: Remove the OSL workaround
Commit: 2a2261d7e1933a1f5cfe478dbf109888c91697e8 Author: Jesse Yurkovich Date: Fri May 6 21:41:31 2022 -0700 Branches: master https://developer.blender.org/rB2a2261d7e1933a1f5cfe478dbf109888c91697e8 Cleanup: Remove the OSL workaround Partially reverts rB46ae0831134 now that we have a new version of OSL/OIIO that supports directly. Differential Revision: https://developer.blender.org/D14851 === M intern/cycles/scene/shader_nodes.cpp === diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index 06a2052d4cb..9a61a8a753b 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -19,7 +19,6 @@ #include "util/color.h" #include "util/foreach.h" #include "util/log.h" -#include "util/string.h" #include "util/transform.h" #include "kernel/tables.h" @@ -450,12 +449,8 @@ void ImageTextureNode::compile(OSLCompiler ) const ustring known_colorspace = metadata.colorspace; if (handle.svm_slot() == -1) { -/* OIIO currently does not support substitutions natively. Replace with a format they - * understand. */ -std::string osl_filename = filename.string(); -string_replace(osl_filename, "", "_"); compiler.parameter_texture( -"filename", ustring(osl_filename), compress_as_srgb ? u_colorspace_raw : known_colorspace); +"filename", filename, compress_as_srgb ? u_colorspace_raw : known_colorspace); } else { compiler.parameter_texture("filename", handle.svm_slot()); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [98eb1115685] master: Fix T97366: Misdetection of numbers as UDIMs in certain filepaths
Commit: 98eb11156854e102a0405af1a64b2266eea22368 Author: Jesse Yurkovich Date: Sat Apr 16 14:18:08 2022 -0700 Branches: master https://developer.blender.org/rB98eb11156854e102a0405af1a64b2266eea22368 Fix T97366: Misdetection of numbers as UDIMs in certain filepaths In some circumstances singular files with numbers in their name (like turntable-1080p.png or frame-1042.png) might be detected as a UDIM. The root cause in this particular instance was because `BKE_image_get_tile_info` believed this file to be a tiled texture and replaced the filename with a tokenized version of it. However, later on, the code inside `image_open_single` did not believe it was tiled because only 1 file was detected and our tiled textures require at least 2. This discrepancy lead to the broken filename situation. This was a regression since rB180b66ae8a1f as that introduced the tokenization changes. Differential Revision: https://developer.blender.org/D14667 === M source/blender/blenkernel/intern/image.cc === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 482537d7fa9..53ec148fd2d 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -3106,7 +3106,7 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, eUDIM_TILE_FORMAT tile_format; char *udim_pattern = BKE_image_get_tile_strformat(filename, _format); - bool is_udim = true; + bool all_valid_udim = true; int min_udim = IMA_UDIM_MAX + 1; int max_udim = 0; int id; @@ -3124,7 +3124,7 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, } if (id < 1001 || id > IMA_UDIM_MAX) { - is_udim = false; + all_valid_udim = false; break; } @@ -3135,7 +3135,10 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, BLI_filelist_free(dirs, dirs_num); MEM_SAFE_FREE(udim_pattern); - if (is_udim && min_udim <= IMA_UDIM_MAX) { + /* Ensure that all discovered UDIMs are valid and that there's at least 2 files in total. + * Downstream code checks the range value to determine tiled-ness; it's important we match that + * expectation here too (T97366). */ + if (all_valid_udim && min_udim <= IMA_UDIM_MAX && max_udim > min_udim) { BLI_join_dirfile(filepath, FILE_MAX, dirname, filename); *r_tile_start = min_udim; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [92c89d7b879] master: UDIM: Move UDIM grid controls to the Overlay panel
Commit: 92c89d7b879229ac01390da068026d0a11d864f1 Author: Jesse Yurkovich Date: Fri Apr 8 21:40:05 2022 -0700 Branches: master https://developer.blender.org/rB92c89d7b879229ac01390da068026d0a11d864f1 UDIM: Move UDIM grid controls to the Overlay panel This change moves the grid panel UI from the View tab up into the Overlay panel. Reasons to move to the Overlay panel include: - Consistency with the grid options in the 3D viewport - The grid has been drawn as an Overlay for quite some time already Additional changes that now make sense to have: - The grid responds to the main Overlay show/hide toggle - Adds a toggle to show/hide the grid which is consistent with overlays in general As before, these grid controls are only available for active UV edit sessions. Differential Revision: https://developer.blender.org/D11862 === M release/scripts/startup/bl_ui/space_image.py M source/blender/blenkernel/BKE_blender_version.h M source/blender/blenloader/intern/versioning_300.c M source/blender/draw/engines/overlay/overlay_grid.c M source/blender/editors/space_image/space_image.c M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 785a841a0e6..1dd50c979e2 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1453,66 +1453,57 @@ class IMAGE_PT_uv_cursor(Panel): col.prop(sima, "cursor_location", text="Location") -class IMAGE_PT_udim_grid(Panel): +class IMAGE_PT_overlay(Panel): bl_space_type = 'IMAGE_EDITOR' -bl_region_type = 'UI' -bl_category = "View" -bl_label = "UDIM Grid" - -@classmethod -def poll(cls, context): -sima = context.space_data - -return sima.show_uvedit +bl_region_type = 'HEADER' +bl_label = "Overlays" +bl_ui_units_x = 13 def draw(self, context): -layout = self.layout - -sima = context.space_data -uvedit = sima.uv_editor - -layout.use_property_split = True -layout.use_property_decorate = False +pass -col = layout.column() -col.prop(uvedit, "tile_grid_shape", text="Grid Shape") -class IMAGE_PT_custom_grid(Panel): +class IMAGE_PT_overlay_guides(Panel): bl_space_type = 'IMAGE_EDITOR' -bl_region_type = 'UI' -bl_category = "View" -bl_label = "Custom Grid" +bl_region_type = 'HEADER' +bl_label = "Guides" +bl_parent_id = 'IMAGE_PT_overlay' @classmethod def poll(cls, context): sima = context.space_data -return sima.show_uvedit -def draw_header(self, context): -sima = context.space_data -uvedit = sima.uv_editor -self.layout.prop(uvedit, "use_custom_grid", text="") +return sima.show_uvedit def draw(self, context): layout = self.layout sima = context.space_data +overlay = sima.overlay uvedit = sima.uv_editor -layout.use_property_split = True -layout.use_property_decorate = False +layout.active = overlay.show_overlays -col = layout.column() -col.prop(uvedit, "custom_grid_subdivisions", text="Subdivisions") +row = layout.row() +row_el = row.column() +row_el.prop(overlay, "show_grid_background", text="Grid") -class IMAGE_PT_overlay(Panel): -bl_space_type = 'IMAGE_EDITOR' -bl_region_type = 'HEADER' -bl_label = "Overlays" -bl_ui_units_x = 13 +if overlay.show_grid_background: +layout.use_property_split = True +col = layout.column(align=False, heading="Fixed Subdivisions") +col.use_property_decorate = False -def draw(self, context): -pass +row = col.row(align=True) +sub = row.row(align=True) +sub.prop(uvedit, "use_custom_grid", text="") +sub = sub.row(align=True) +sub.active = uvedit.use_custom_grid +sub.prop(uvedit, "custom_grid_subdivisions", text="") + +row = layout.row() +row.use_property_split = True +row.use_property_decorate = False +row.prop(uvedit, "tile_grid_shape", text="Tiles") class IMAGE_PT_overlay_uv_edit(Panel): @@ -1689,9 +1680,8 @@ classes = ( IMAGE_PT_scope_sample, IMAGE_PT_uv_cursor, IMAGE_PT_annotation, -IMAGE_PT_udim_grid, -IMAGE_PT_custom_grid, IMAGE_PT_overlay, +IMAGE_PT_overlay_guides, IMAGE
[Bf-blender-cvs] [77155ae1c03] master: Cleanup: Reduce duplication to prepare for UDIM packing
Commit: 77155ae1c03e6bd430c4a3a1b9a09bd6d245a156 Author: Jesse Yurkovich Date: Sun Mar 27 17:49:26 2022 -0700 Branches: master https://developer.blender.org/rB77155ae1c03e6bd430c4a3a1b9a09bd6d245a156 Cleanup: Reduce duplication to prepare for UDIM packing In preparation for supporting packing of UDIM tiled textures, this patch refactors a small portion of image.cc. The refactor should lead to less duplicate code now and when Tiled images are added in the near future. This patch is based on the prior work done for D6492 where it was requested this part be split and can be summarized as follows: - `load_sequence_single` is removed and merged with `load_image_single` - `image_load_sequence_file` is removed and merged with `image_load_image_file` Reviewed By: lukasstockner97 Differential Revision: https://developer.blender.org/D14327 === M source/blender/blenkernel/intern/image.cc === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index b65f3416f0f..3eade265bf2 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -468,7 +468,9 @@ constexpr IDTypeInfo get_type_info() IDTypeInfo IDType_ID_IM = get_type_info(); /* prototypes */ -static int image_num_files(struct Image *ima); +static int image_num_viewfiles(Image *ima); +static ImBuf *image_load_image_file( +Image *ima, ImageUser *iuser, int entry, int cfra, bool is_sequence); static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock); static void image_update_views_format(Image *ima, ImageUser *iuser); static void image_add_view(Image *ima, const char *viewname, const char *filepath); @@ -1277,9 +1279,9 @@ bool BKE_image_memorypack(Image *ima) void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath) { - const int totfiles = image_num_files(ima); + const int tot_viewfiles = image_num_viewfiles(ima); - if (totfiles == 1) { + if (tot_viewfiles == 1) { ImagePackedFile *imapf = static_cast( MEM_mallocN(sizeof(ImagePackedFile), "Image packed file")); BLI_addtail(>packedfiles, imapf); @@ -1313,9 +1315,9 @@ void BKE_image_packfiles_from_mem(ReportList *reports, char *data, const size_t data_len) { - const int totfiles = image_num_files(ima); + const int tot_viewfiles = image_num_viewfiles(ima); - if (totfiles != 1) { + if (tot_viewfiles != 1) { BKE_report(reports, RPT_ERROR, "Cannot pack multiview images from raw data currently..."); } else { @@ -2944,9 +2946,9 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) case IMA_SIGNAL_RELOAD: /* try to repack file */ if (BKE_image_has_packedfile(ima)) { -const int totfiles = image_num_files(ima); +const int tot_viewfiles = image_num_viewfiles(ima); -if (totfiles != BLI_listbase_count_at_most(>packedfiles, totfiles + 1)) { +if (tot_viewfiles != BLI_listbase_count_at_most(>packedfiles, tot_viewfiles + 1)) { /* in case there are new available files to be loaded */ image_free_packedfiles(ima); BKE_image_packfiles(nullptr, ima, ID_BLEND_PATH(bmain, >id)); @@ -3739,7 +3741,7 @@ static int imbuf_alpha_flags_for_image(Image *ima) /** * \return the number of files will vary according to the stereo format. */ -static int image_num_files(Image *ima) +static int image_num_viewfiles(Image *ima) { const bool is_multiview = BKE_image_is_multiview(ima); @@ -3754,117 +3756,6 @@ static int image_num_files(Image *ima) return BLI_listbase_count(>views); } -static ImBuf *load_sequence_single( -Image *ima, ImageUser *iuser, int frame, const int view_id, bool *r_cache_ibuf) -{ - struct ImBuf *ibuf; - char name[FILE_MAX]; - int flag; - ImageUser iuser_t{}; - - *r_cache_ibuf = true; - - ima->lastframe = frame; - - if (iuser) { -iuser_t = *iuser; - } - else { -/* BKE_image_user_file_path() uses this value for file name for sequences. */ -iuser_t.framenr = frame; -/* TODO(sergey): Do we need to initialize something else here? */ - } - - iuser_t.view = view_id; - BKE_image_user_file_path(_t, ima, name); - - flag = IB_rect | IB_multilayer | IB_metadata; - flag |= imbuf_alpha_flags_for_image(ima); - - /* read ibuf */ - ibuf = IMB_loadiffname(name, flag, ima->colorspace_settings.name); - -#if 0 - if (ibuf) { -printf(AT " loaded %s\n", name); - } - else { -printf(AT " missed %s\n", name); - } -#endif - - if (ibuf) { -#ifdef WITH_OPENEXR -if (ibuf->ftype == IMB_FTYPE_OPENEXR && ibuf->userdata) { - /* Handle multilayer and multiview cases, don't assign ib
[Bf-blender-cvs] [07846b31f34] master: Cleanup: Optimize viewport view data creation
Commit: 07846b31f34caa88244d192ee7d3aa6c057ac602 Author: Jesse Yurkovich Date: Thu Mar 24 21:13:02 2022 +0100 Branches: master https://developer.blender.org/rB07846b31f34caa88244d192ee7d3aa6c057ac602 Cleanup: Optimize viewport view data creation Each time the user clicks the viewport 2 sets of engine views are created. Each set is currently composed of 8 view objects, each of size 592 bytes. Because space is not reserved in the vector that holds them, several unnecessary re-allocation/copy cycles occur as the vector resizes and the total allocation load is 8880 bytes. This happens twice. Reduce to just the allocations necessary and with exactly 4736 bytes allocated for each set - Before: 8 allocations and 8 deallocations totaling 17760 bytes - After: 2 allocations and 2 deallocations totaling 9472 bytes Reviewed By: fclem, jbakker Differential Revision: https://developer.blender.org/D13782 === M source/blender/draw/intern/draw_view_data.cc === diff --git a/source/blender/draw/intern/draw_view_data.cc b/source/blender/draw/intern/draw_view_data.cc index 682728eb22b..0e55d28f6df 100644 --- a/source/blender/draw/intern/draw_view_data.cc +++ b/source/blender/draw/intern/draw_view_data.cc @@ -37,7 +37,10 @@ struct DRWViewData { DRWViewData *DRW_view_data_create(ListBase *engine_types) { + const int engine_types_len = BLI_listbase_count(engine_types); + DRWViewData *view_data = new DRWViewData(); + view_data->engines.reserve(engine_types_len); LISTBASE_FOREACH (DRWRegisteredDrawEngine *, type, engine_types) { ViewportEngineData engine = {}; engine.engine_type = type; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a1598d6835d] master: UDIM: Improve tile format detection in filenames
Commit: a1598d6835d0c579579881bca900f9259b26d11a Author: Jesse Yurkovich Date: Wed Mar 23 21:01:36 2022 -0700 Branches: master https://developer.blender.org/rBa1598d6835d0c579579881bca900f9259b26d11a UDIM: Improve tile format detection in filenames There are some filenames where the UDIM pattern guessing would fail unnecessarily. The user can fix these up afterwards but it would be nicer if they would detect properly in the first place. Examples: `test.1001.ver0023.png` would guess wrong since it uses the image sequence detection code which finds the first sequence from the end. It would guess `filename.1001.ver.png` `uv-test.u1_v2.png` would fail detection due to a bug in the processing. Make this much more reliable and add tests for the most important tile related get/set/detection functions. Differential Revision: https://developer.blender.org/D14320 === M source/blender/blenkernel/CMakeLists.txt M source/blender/blenkernel/intern/image.cc A source/blender/blenkernel/intern/image_test.cc === diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 3b5272aa600..268239ed7b5 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -818,6 +818,7 @@ if(WITH_GTESTS) intern/cryptomatte_test.cc intern/curves_geometry_test.cc intern/fcurve_test.cc +intern/image_test.cc intern/idprop_serialize_test.cc intern/image_partial_update_test.cc intern/lattice_deform_test.cc diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index cfdd048495d..0e3c913189c 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -9,6 +9,7 @@ #include #include #include +#include #include #ifndef WIN32 # include @@ -16,7 +17,8 @@ # include #endif -#include +#include +#include #include "BLI_array.hh" @@ -3316,69 +3318,24 @@ void BKE_image_ensure_tile_token(char *filename) return; } - /* Is there a sequence of digits in the filename? */ - ushort digits; - char head[FILE_MAX], tail[FILE_MAX]; - BLI_path_sequence_decode(filename, head, tail, ); - if (digits == 4) { -sprintf(filename, "%s%s", head, tail); -return; - } - - /* Is there a sequence like u##_v in the filename? */ - uint cur = 0; - uint name_end = strlen(filename); - uint u_digits = 0; - uint v_digits = 0; - uint u_start = (uint)-1; - bool u_found = false; - bool v_found = false; - bool sep_found = false; - while (cur < name_end) { -if (filename[cur] == 'u') { - u_found = true; - u_digits = 0; - u_start = cur; -} -else if (filename[cur] == 'v') { - v_found = true; - v_digits = 0; -} -else if (u_found && !v_found) { - if (isdigit(filename[cur]) && u_digits < 2) { -u_digits++; - } - else if (filename[cur] == '_') { -sep_found = true; - } - else { -u_found = false; - } -} -else if (u_found && u_digits > 0 && v_found) { - if (isdigit(filename[cur])) { -if (v_digits < 4) { - v_digits++; -} -else { - u_found = false; - v_found = false; -} - } - else if (v_digits > 0) { -break; - } -} + std::string path(filename); + std::smatch match; -cur++; + /* General 4-digit "udim" pattern. As this format is susceptible to ambiguity + * with other digit sequences, we can leverage the supported range of roughly + * 1000 through 2000 to provide better detection. + */ + std::regex pattern("(^|.*?\\D)([12]\\d{3})(\\D.*)"); + if (std::regex_search(path, match, pattern)) { +BLI_strncpy(filename, match.format("$1$3").c_str(), FILE_MAX); +return; } - if (u_found && sep_found && v_found && (u_digits + v_digits > 1)) { -const char *token = ""; -const size_t token_length = strlen(token); -memmove(filename + u_start + token_length, filename + cur, name_end - cur); -memcpy(filename + u_start, token, token_length); -filename[u_start + token_length + (name_end - cur)] = '\0'; + /* General u##_v### "uvtile" pattern. */ + pattern = std::regex("(.*)(u\\d{1,2}_v\\d{1,3})(\\D.*)"); + if (std::regex_search(path, match, pattern)) { +BLI_strncpy(filename, match.format("$1$3").c_str(), FILE_MAX); +return; } } diff --git a/source/blender/blenkernel/intern/image_test.cc b/source/blender/blenkernel/intern/image_test.cc new file mode 100644 index 000..9c15fc62d21 --- /dev/null +++ b/source/blender/blenkernel/intern/image_test.cc @@ -0,0 +1,186 @@ +/*
[Bf-blender-cvs] [c655146b87f] master: Fix T96584: Properly translate operator on splash screen
Commit: c655146b87fe20853e52b87991b46732a04d749e Author: Jesse Yurkovich Date: Fri Mar 18 20:31:24 2022 -0700 Branches: master https://developer.blender.org/rBc655146b87fe20853e52b87991b46732a04d749e Fix T96584: Properly translate operator on splash screen The previous fix looks to have been accidentally removed as part of rB7aec5b06227. Restore the change. === M release/scripts/startup/bl_operators/wm.py === diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index a7f401afad1..d6e5604fde0 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2996,7 +2996,7 @@ class WM_MT_splash_quick_setup(Menu): old_version = bpy.types.PREFERENCES_OT_copy_prev.previous_version() if bpy.types.PREFERENCES_OT_copy_prev.poll(context) and old_version: -sub.operator("preferences.copy_prev", text="Load %d.%d Settings" % old_version) +sub.operator("preferences.copy_prev", text=iface_("Load %d.%d Settings", "Operator") % old_version) sub.operator("wm.save_userpref", text="Save New Settings") else: sub.label() ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [24ada9c9602] master: Cleanup: Remove volatile from RenderResult and related APIs
Commit: 24ada9c96027971e50e9d103c746d674024b6892 Author: Jesse Yurkovich Date: Tue Mar 15 20:53:10 2022 -0700 Branches: master https://developer.blender.org/rB24ada9c96027971e50e9d103c746d674024b6892 Cleanup: Remove volatile from RenderResult and related APIs Volatile fields were introduced to the RenderResult struct years ago[1]. However, volatile is most likely not doing what it was intended to do in this instance, and is problematic when moving files to c++ (see discussion from D13962). There are complex rules around what happens to these fields but none of them guarantee what the above commit alluded to. This patch drops the volatile and cleans up the APIs surrounding it. [1] rB7930c40051ef1b1a26140629cf1299aa89eed859 Passing on all platforms: https://builder.blender.org/admin/#/builders/18/builds/338 Differential Revision: https://developer.blender.org/D14298 === M source/blender/blenkernel/intern/image.cc M source/blender/editors/render/render_internal.cc M source/blender/editors/render/render_preview.cc M source/blender/render/RE_pipeline.h M source/blender/render/intern/pipeline.c M source/blender/render/intern/render_types.h === diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index 4a1cbdba42a..8831e1c 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -5105,31 +5105,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc RE_AcquireResultImage(re, , actview); } else if ((slot = BKE_image_get_renderslot(ima, ima->render_slot))->render) { -/* Unfortunately each field needs to be set individually because RenderResult - * contains volatile fields and using memcpy would invoke undefined behavior with c++. */ -rres.next = slot->render->next; -rres.prev = slot->render->prev; -rres.rectx = slot->render->rectx; -rres.recty = slot->render->recty; -rres.sample_nr = slot->render->sample_nr; -rres.rect32 = slot->render->rect32; -rres.rectf = slot->render->rectf; -rres.rectz = slot->render->rectz; -rres.tilerect = slot->render->tilerect; -rres.xof = slot->render->xof; -rres.yof = slot->render->yof; -rres.layers = slot->render->layers; -rres.views = slot->render->views; -rres.renrect.xmin = slot->render->renrect.xmin; -rres.renrect.xmax = slot->render->renrect.xmax; -rres.renrect.ymin = slot->render->renrect.ymin; -rres.renrect.ymax = slot->render->renrect.ymax; -rres.renlay = slot->render->renlay; -rres.framenr = slot->render->framenr; -rres.text = slot->render->text; -rres.error = slot->render->error; -rres.stamp_data = slot->render->stamp_data; -rres.passes_allocated = slot->render->passes_allocated; +rres = *(slot->render); rres.have_combined = ((RenderView *)rres.views.first)->rectf != nullptr; } diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index 6c04523ed07..6796eff29d4 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -101,7 +101,7 @@ struct RenderJob { /* called inside thread! */ static bool image_buffer_calc_tile_rect(const RenderResult *rr, const ImBuf *ibuf, -volatile rcti *renrect, +rcti *renrect, rcti *r_ibuf_rect, int *r_offset_x, int *r_offset_y) @@ -556,7 +556,7 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, } } -static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect) +static void image_rect_update(void *rjv, RenderResult *rr, rcti *renrect) { RenderJob *rj = static_cast(rjv); Image *ima = rj->image; diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index cfb88cd7868..57858b202d2 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -987,9 +987,7 @@ static void action_preview_render(IconPreview *preview, IconPreviewSize *preview * \{ */ /* inside thread, called by renderer, sets job update value */ -static void shader_preview_update(void *spv, - RenderResult *UNUSED(rr), - volatile struct rcti *UNUSED(rect)) +static void shader_preview_update(void *spv, Rende
[Bf-blender-cvs] [0ef8a6179d2] master: Cleanup: Move image.c to c++
Commit: 0ef8a6179d2a773b2570352bd0cb7eb18b666da2 Author: Jesse Yurkovich Date: Wed Mar 9 20:55:17 2022 -0800 Branches: master https://developer.blender.org/rB0ef8a6179d2a773b2570352bd0cb7eb18b666da2 Cleanup: Move image.c to c++ Passing on all platforms: https://builder.blender.org/admin/#/builders/18/builds/329 Differential Revision: https://developer.blender.org/D13962 === M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/CMakeLists.txt R086source/blender/blenkernel/intern/image.c source/blender/blenkernel/intern/image.cc === diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index a5a2d57f9d3..ea0202e3b5f 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -486,7 +486,7 @@ bool BKE_image_is_dirty(struct Image *image); void BKE_image_mark_dirty(struct Image *image, struct ImBuf *ibuf); bool BKE_image_buffer_format_writable(struct ImBuf *ibuf); -bool BKE_image_is_dirty_writable(struct Image *image, bool *is_format_writable); +bool BKE_image_is_dirty_writable(struct Image *image, bool *r_is_writable); /** * Guess offset for the first frame in the sequence. diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index a12a956cbf5..3828d442f58 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -150,7 +150,7 @@ set(SRC intern/idprop_serialize.cc intern/idprop_utils.c intern/idtype.c - intern/image.c + intern/image.cc intern/image_partial_update.cc intern/image_gen.c intern/image_gpu.cc diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.cc similarity index 86% rename from source/blender/blenkernel/intern/image.c rename to source/blender/blenkernel/intern/image.cc index e01f8cb76c8..967f0f61e07 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.cc @@ -5,18 +5,20 @@ * \ingroup bke */ -#include +#include +#include +#include +#include #include -#include -#include -#include #ifndef WIN32 # include #else # include #endif -#include +#include + +#include "BLI_array.hh" #include "CLG_log.h" @@ -99,6 +101,8 @@ #include "DNA_space_types.h" #include "DNA_view3d_types.h" +using blender::Array; + static CLG_LogRef LOG = {"bke.image"}; static void image_init(Image *ima, short source, short type); @@ -110,28 +114,28 @@ static void image_runtime_reset(struct Image *image) { memset(>runtime, 0, sizeof(image->runtime)); image->runtime.cache_mutex = MEM_mallocN(sizeof(ThreadMutex), "image runtime cache_mutex"); - BLI_mutex_init(image->runtime.cache_mutex); + BLI_mutex_init(static_cast(image->runtime.cache_mutex)); } /* Reset runtime image fields when data-block is being copied. */ static void image_runtime_reset_on_copy(struct Image *image) { image->runtime.cache_mutex = MEM_mallocN(sizeof(ThreadMutex), "image runtime cache_mutex"); - BLI_mutex_init(image->runtime.cache_mutex); + BLI_mutex_init(static_cast(image->runtime.cache_mutex)); - image->runtime.partial_update_register = NULL; - image->runtime.partial_update_user = NULL; + image->runtime.partial_update_register = nullptr; + image->runtime.partial_update_user = nullptr; } static void image_runtime_free_data(struct Image *image) { - BLI_mutex_end(image->runtime.cache_mutex); + BLI_mutex_end(static_cast(image->runtime.cache_mutex)); MEM_freeN(image->runtime.cache_mutex); - image->runtime.cache_mutex = NULL; + image->runtime.cache_mutex = nullptr; - if (image->runtime.partial_update_user != NULL) { + if (image->runtime.partial_update_user != nullptr) { BKE_image_partial_update_free(image->runtime.partial_update_user); -image->runtime.partial_update_user = NULL; +image->runtime.partial_update_user = nullptr; } BKE_image_partial_update_register_free(image); } @@ -140,7 +144,7 @@ static void image_init_data(ID *id) { Image *image = (Image *)id; - if (image != NULL) { + if (image != nullptr) { image_init(image, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); } } @@ -155,16 +159,17 @@ static void image_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c copy_image_packedfiles(_dst->packedfiles, _src->packedfiles); - image_dst->stereo3d_format = MEM_dupallocN(image_src->stereo3d_format); + image_dst->stereo3d_format = static_cast( + MEM_dupallocN(image_src->stereo3d_format)); BLI_duplicatelist(_dst->views, _src->views); /* Cleanup stuff that cannot be copied. */ - image_dst->cache = NULL; - image_dst-&
[Bf-blender-cvs] [4f16dad6b33] blender-v2.83-release: Fix T95137: Spline calc_length not working with just 1 NURB point
Commit: 4f16dad6b33fc9aaf8f7a3829d96447bcd954311 Author: Jesse Yurkovich Date: Thu Feb 3 22:39:57 2022 +1100 Branches: blender-v2.83-release https://developer.blender.org/rB4f16dad6b33fc9aaf8f7a3829d96447bcd954311 Fix T95137: Spline calc_length not working with just 1 NURB point The NURB case did not properly handle a curve with only 1 point. Ref D13904 === M source/blender/blenkernel/intern/curve.c === diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 5282cbe4c67..f23c0654877 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -746,7 +746,7 @@ float BKE_nurb_calc_length(const Nurb *nu, int resolution) pntsit = points + 3; } - while (--b) { + while (--b > 0) { length += len_v3v3(prevpntsit, pntsit); prevpntsit = pntsit; pntsit += 3; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1ee4e6bf31f] blender-v2.93-release: Fix T89542: Crash when loading certain .hdr files
Commit: 1ee4e6bf31ff32f87f9cd1eafa548d6811794380 Author: Jesse Yurkovich Date: Tue Jan 11 20:48:32 2022 -0800 Branches: blender-v2.93-release https://developer.blender.org/rB1ee4e6bf31ff32f87f9cd1eafa548d6811794380 Fix T89542: Crash when loading certain .hdr files The direct cause of the bug in question was passing in the raw memory buffer to sscanf. It should be called with a null-terminated buffer; which isn't guaranteed when blindly trusting the file data. When attempting to fuzz this code path, a variety of other crashes were discovered and fixed. Differential Revision: https://developer.blender.org/D11952 === M source/blender/imbuf/intern/radiance_hdr.c === diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 94b2a62aa26..90972da7da1 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -77,7 +77,7 @@ static const unsigned char *oldreadcolrs(RGBE *scan, scan[0][BLU] = *mem++; scan[0][EXP] = *mem++; if (scan[0][RED] == 1 && scan[0][GRN] == 1 && scan[0][BLU] == 1) { - for (i = scan[0][EXP] << rshift; i > 0; i--) { + for (i = scan[0][EXP] << rshift; i > 0 && len > 0; i--) { COPY_RGBE(scan[-1], scan[0]); scan++; len--; @@ -227,7 +227,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, int found = 0; int width = 0, height = 0; const unsigned char *ptr, *mem_eof = mem + size; - char oriY[80], oriX[80]; + char oriY[3], oriX[3]; if (!imb_is_a_hdr(mem, size)) { return NULL; @@ -244,13 +244,19 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, } } - if ((found && (x < (size + 2))) == 0) { + if ((found && (x < (size - 1))) == 0) { /* Data not found! */ return NULL; } - if (sscanf((const char *)[x + 1], - "%79s %d %79s %d", + x++; + + /* sscanf requires a null-terminated buffer argument */ + char buf[32] = {0}; + memcpy(buf, [x], MIN2(sizeof(buf) - 1, size - x)); + + if (sscanf(buf, + "%2s %d %2s %d", (char *), , (char *), @@ -258,8 +264,18 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, return NULL; } + if (width < 1 || height < 1) { +return NULL; + } + + /* Checking that width x height does not extend past mem_eof is not easily possible + * since the format uses RLE compression. Can cause excessive memory allocation to occur. */ + /* find end of this line, data right behind it */ - ptr = (const unsigned char *)strchr((const char *)[x + 1], '\n'); + ptr = (const unsigned char *)strchr((const char *)[x], '\n'); + if (ptr == NULL || ptr >= mem_eof) { +return NULL; + } ptr++; if (flags & IB_test) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3cfccf11997] blender-v2.93-release: Fix T95137: Spline calc_length not working with just 1 NURB point
Commit: 3cfccf11997e9dc2f07000b9d802f0a6038e8ec1 Author: Jesse Yurkovich Date: Thu Feb 3 22:39:57 2022 +1100 Branches: blender-v2.93-release https://developer.blender.org/rB3cfccf11997e9dc2f07000b9d802f0a6038e8ec1 Fix T95137: Spline calc_length not working with just 1 NURB point The NURB case did not properly handle a curve with only 1 point. Ref D13904 === M source/blender/blenkernel/intern/curve.c === diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 37cd62c3bc8..4fc4f3e0bcd 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -915,7 +915,7 @@ float BKE_nurb_calc_length(const Nurb *nu, int resolution) pntsit = points + 3; } - while (--b) { + while (--b > 0) { length += len_v3v3(prevpntsit, pntsit); prevpntsit = pntsit; pntsit += 3; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7413c2feede] master: Cleanup: Optimize gl query code path
Commit: 7413c2feede68c45f13fa37ebdcbf325d8f32c10 Author: Jesse Yurkovich Date: Sat Feb 12 21:52:24 2022 -0800 Branches: master https://developer.blender.org/rB7413c2feede68c45f13fa37ebdcbf325d8f32c10 Cleanup: Optimize gl query code path Currently whenever gl queries are performed for the viewport, a large 1024 byte array is allocated to store the query results (256 of them). Unfortunately, if any gizmo using a `draw_select` callback is active (e.g. the transform gizmos), these queries (and allocations) will occur during every mouse move event. Change the vector to allow for up to 16 query results before making an allocation. This provides enough space for every built-in gizmo except Scale Cage (which needs 27 queries). It also removes unnecessary allocations from two other related vectors used during query processing. Differential Revision: https://developer.blender.org/D13784 === M source/blender/gpu/intern/gpu_query.hh M source/blender/gpu/intern/gpu_select_sample_query.cc M source/blender/gpu/opengl/gl_query.cc M source/blender/gpu/opengl/gl_query.hh === diff --git a/source/blender/gpu/intern/gpu_query.hh b/source/blender/gpu/intern/gpu_query.hh index e563d208c06..da264c4a98d 100644 --- a/source/blender/gpu/intern/gpu_query.hh +++ b/source/blender/gpu/intern/gpu_query.hh @@ -11,6 +11,8 @@ namespace blender::gpu { +#define QUERY_MIN_LEN 16 + typedef enum GPUQueryType { GPU_QUERY_OCCLUSION = 0, } GPUQueryType; diff --git a/source/blender/gpu/intern/gpu_select_sample_query.cc b/source/blender/gpu/intern/gpu_select_sample_query.cc index ab890b08935..26c9ed79d6c 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.cc +++ b/source/blender/gpu/intern/gpu_select_sample_query.cc @@ -37,7 +37,7 @@ struct GPUSelectQueryState { /** GPU queries abstraction. Contains an array of queries. */ QueryPool *queries; /** Array holding the id corresponding id to each query. */ - Vector *ids; + Vector *ids; /** Cache on initialization. */ GPUSelectResult *buffer; /** The capacity of the `buffer` array. */ @@ -71,7 +71,7 @@ void gpu_select_query_begin(GPUSelectResult *buffer, g_query_state.index = 0; g_query_state.oldhits = oldhits; - g_query_state.ids = new Vector(); + g_query_state.ids = new Vector(); g_query_state.queries = GPUBackend::get()->querypool_alloc(); g_query_state.queries->init(GPU_QUERY_OCCLUSION); @@ -149,7 +149,7 @@ uint gpu_select_query_end() } Span ids = *g_query_state.ids; - Vector result(ids.size()); + Vector result(ids.size()); g_query_state.queries->get_occlusion_result(result); for (int i = 0; i < result.size(); i++) { diff --git a/source/blender/gpu/opengl/gl_query.cc b/source/blender/gpu/opengl/gl_query.cc index 3195ec95ed2..0081efbf1e7 100644 --- a/source/blender/gpu/opengl/gl_query.cc +++ b/source/blender/gpu/opengl/gl_query.cc @@ -37,8 +37,9 @@ void GLQueryPool::begin_query() /* TODO: add assert about expected usage. */ while (query_issued_ >= query_ids_.size()) { int64_t prev_size = query_ids_.size(); -query_ids_.resize(prev_size + QUERY_CHUNCK_LEN); -glGenQueries(QUERY_CHUNCK_LEN, _ids_[prev_size]); +int64_t chunk_size = prev_size == 0 ? query_ids_.capacity() : QUERY_CHUNCK_LEN; +query_ids_.resize(prev_size + chunk_size); +glGenQueries(chunk_size, _ids_[prev_size]); } glBeginQuery(gl_type_, query_ids_[query_issued_++]); } diff --git a/source/blender/gpu/opengl/gl_query.hh b/source/blender/gpu/opengl/gl_query.hh index 0dc4a6b8d51..e15a2584e07 100644 --- a/source/blender/gpu/opengl/gl_query.hh +++ b/source/blender/gpu/opengl/gl_query.hh @@ -18,7 +18,7 @@ namespace blender::gpu { class GLQueryPool : public QueryPool { private: /** Contains queries object handles. */ - Vector query_ids_; + Vector query_ids_; /** Type of this query pool. */ GPUQueryType type_; /** Associated GL type. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [59b777eedd2] blender-v3.1-release: Fix T95137: Spline calc_length not working with just 1 NURB point
Commit: 59b777eedd23d34a7d723a7b73032d463077f1b3 Author: Jesse Yurkovich Date: Thu Feb 3 22:39:57 2022 +1100 Branches: blender-v3.1-release https://developer.blender.org/rB59b777eedd23d34a7d723a7b73032d463077f1b3 Fix T95137: Spline calc_length not working with just 1 NURB point The NURB case did not properly handle a curve with only 1 point. Ref D13904 === M source/blender/blenkernel/intern/curve.cc === diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc index 70edaccb244..dda2b5076a8 100644 --- a/source/blender/blenkernel/intern/curve.cc +++ b/source/blender/blenkernel/intern/curve.cc @@ -899,7 +899,7 @@ float BKE_nurb_calc_length(const Nurb *nu, int resolution) pntsit = points + 3; } - while (--b) { + while (--b > 0) { length += len_v3v3(prevpntsit, pntsit); prevpntsit = pntsit; pntsit += 3; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [46ae0831134] master: Fix: OSL not recognizing UVTILE images
Commit: 46ae083113487d88a8cce8fc3ee38839e2ebd070 Author: Jesse Yurkovich Date: Tue Jan 25 22:00:23 2022 -0800 Branches: master https://developer.blender.org/rB46ae083113487d88a8cce8fc3ee38839e2ebd070 Fix: OSL not recognizing UVTILE images The OSL image compilation step needed to be taught about the new UVTILE format for UDIM textures. A small missing feature from OIIO[1] means this is a bit uglier than it needs to be. Once we update to a version of OIIO with the fix we can remove the string replace part. [1] https://github.com/OpenImageIO/oiio/commit/35cb6a83e28d77bd9eb30e153abd9df4248863c5 Differential Revision: https://developer.blender.org/D13912 === M intern/cycles/scene/shader_nodes.cpp === diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index 7f3625c0c69..34675be8e80 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -32,6 +32,7 @@ #include "util/color.h" #include "util/foreach.h" #include "util/log.h" +#include "util/string.h" #include "util/transform.h" #include "kernel/tables.h" @@ -462,8 +463,12 @@ void ImageTextureNode::compile(OSLCompiler ) const ustring known_colorspace = metadata.colorspace; if (handle.svm_slot() == -1) { +/* OIIO currently does not support substitutions natively. Replace with a format they + * understand. */ +std::string osl_filename = filename.string(); +string_replace(osl_filename, "", "_"); compiler.parameter_texture( -"filename", filename, compress_as_srgb ? u_colorspace_raw : known_colorspace); +"filename", ustring(osl_filename), compress_as_srgb ? u_colorspace_raw : known_colorspace); } else { compiler.parameter_texture("filename", handle.svm_slot()); @@ -472,7 +477,8 @@ void ImageTextureNode::compile(OSLCompiler ) const bool unassociate_alpha = !(ColorSpaceManager::colorspace_is_data(colorspace) || alpha_type == IMAGE_ALPHA_CHANNEL_PACKED || alpha_type == IMAGE_ALPHA_IGNORE); - const bool is_tiled = (filename.find("") != string::npos); + const bool is_tiled = (filename.find("") != string::npos || + filename.find("") != string::npos); compiler.parameter(this, "projection"); compiler.parameter(this, "projection_blend"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [114b06b3cb5] master: Cleanup: Remove unused pixel buffer in read_render_tile
Commit: 114b06b3cb5f8d1588a9065e30eea701586b7f76 Author: Jesse Yurkovich Date: Mon Jan 24 20:53:19 2022 -0800 Branches: master https://developer.blender.org/rB114b06b3cb5f8d1588a9065e30eea701586b7f76 Cleanup: Remove unused pixel buffer in read_render_tile A left over remnant from rB1a134c4c30a643ada1b9a7a037040b5f5c173a28 Differential Revision: https://developer.blender.org/D13901 === M intern/cycles/blender/output_driver.cpp === diff --git a/intern/cycles/blender/output_driver.cpp b/intern/cycles/blender/output_driver.cpp index d5cc0c60bae..f35b48493cb 100644 --- a/intern/cycles/blender/output_driver.cpp +++ b/intern/cycles/blender/output_driver.cpp @@ -51,8 +51,6 @@ bool BlenderOutputDriver::read_render_tile(const Tile ) BL::RenderLayer b_rlay = *b_single_rlay; - vector pixels(static_cast(tile.size.x) * tile.size.y * 4); - /* Copy each pass. * TODO:copy only the required ones for better performance? */ for (BL::RenderPass _pass : b_rlay.passes) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [63fdcbb5889] blender-v2.83-release: Fix T94629: The IMB_flip API would fail with large images
Commit: 63fdcbb5889e31b5f07d8d5c8e923cc57900fe1b Author: Jesse Yurkovich Date: Thu Jan 6 21:35:04 2022 -0800 Branches: blender-v2.83-release https://developer.blender.org/rB63fdcbb5889e31b5f07d8d5c8e923cc57900fe1b Fix T94629: The IMB_flip API would fail with large images Fix IMB_flip[xy] to handle cases where integer overflow might occur when given sufficiently large image dimensions. All of these fixes were of a similar class where the intermediate sub-expression would overflow silently. Widen the types as necessary. Differential Revision: https://developer.blender.org/D13744 === M source/blender/imbuf/intern/rotate.c === diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 17b485b5171..f02f3e37d6a 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -32,7 +32,7 @@ void IMB_flipy(struct ImBuf *ibuf) { - int x, y; + size_t x_size, y_size; if (ibuf == NULL) { return; @@ -41,21 +41,23 @@ void IMB_flipy(struct ImBuf *ibuf) if (ibuf->rect) { unsigned int *top, *bottom, *line; -x = ibuf->x; -y = ibuf->y; +x_size = ibuf->x; +y_size = ibuf->y; + +const size_t stride = x_size * sizeof(int); top = ibuf->rect; -bottom = top + ((y - 1) * x); -line = MEM_mallocN(x * sizeof(int), "linebuf"); +bottom = top + ((y_size - 1) * x_size); +line = MEM_mallocN(stride, "linebuf"); -y >>= 1; +y_size >>= 1; -for (; y > 0; y--) { - memcpy(line, top, x * sizeof(int)); - memcpy(top, bottom, x * sizeof(int)); - memcpy(bottom, line, x * sizeof(int)); - bottom -= x; - top += x; +for (; y_size > 0; y_size--) { + memcpy(line, top, stride); + memcpy(top, bottom, stride); + memcpy(bottom, line, stride); + bottom -= x_size; + top += x_size; } MEM_freeN(line); @@ -64,21 +66,23 @@ void IMB_flipy(struct ImBuf *ibuf) if (ibuf->rect_float) { float *topf = NULL, *bottomf = NULL, *linef = NULL; -x = ibuf->x; -y = ibuf->y; +x_size = ibuf->x; +y_size = ibuf->y; + +const size_t stride = x_size * 4 * sizeof(float); topf = ibuf->rect_float; -bottomf = topf + 4 * ((y - 1) * x); -linef = MEM_mallocN(4 * x * sizeof(float), "linebuff"); +bottomf = topf + 4 * ((y_size - 1) * x_size); +linef = MEM_mallocN(stride, "linebuf"); -y >>= 1; +y_size >>= 1; -for (; y > 0; y--) { - memcpy(linef, topf, 4 * x * sizeof(float)); - memcpy(topf, bottomf, 4 * x * sizeof(float)); - memcpy(bottomf, linef, 4 * x * sizeof(float)); - bottomf -= 4 * x; - topf += 4 * x; +for (; y_size > 0; y_size--) { + memcpy(linef, topf, stride); + memcpy(topf, bottomf, stride); + memcpy(bottomf, linef, stride); + bottomf -= 4 * x_size; + topf += 4 * x_size; } MEM_freeN(linef); @@ -99,20 +103,22 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect) { for (yi = y - 1; yi >= 0; yi--) { + const size_t x_offset = (size_t)x * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { -SWAP(unsigned int, ibuf->rect[(x * yi) + xr], ibuf->rect[(x * yi) + xl]); +SWAP(unsigned int, ibuf->rect[x_offset + xr], ibuf->rect[x_offset + xl]); } } } if (ibuf->rect_float) { for (yi = y - 1; yi >= 0; yi--) { + const size_t x_offset = (size_t)x * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { -memcpy(_f, >rect_float[((x * yi) + xr) * 4], 4 * sizeof(float)); -memcpy(>rect_float[((x * yi) + xr) * 4], - >rect_float[((x * yi) + xl) * 4], - 4 * sizeof(float)); -memcpy(>rect_float[((x * yi) + xl) * 4], _f, 4 * sizeof(float)); +memcpy(_f, >rect_float[(x_offset + xr) * 4], sizeof(float[4])); +memcpy(>rect_float[(x_offset + xr) * 4], + >rect_float[(x_offset + xl) * 4], + sizeof(float[4])); +memcpy(>rect_float[(x_offset + xl) * 4], _f, sizeof(float[4])); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [77616082f44] master: Fix T89542: Crash when loading certain .hdr files
Commit: 77616082f44da5258faf9ec0d53618c721b88c62 Author: Jesse Yurkovich Date: Tue Jan 11 20:48:32 2022 -0800 Branches: master https://developer.blender.org/rB77616082f44da5258faf9ec0d53618c721b88c62 Fix T89542: Crash when loading certain .hdr files The direct cause of the bug in question was passing in the raw memory buffer to sscanf. It should be called with a null-terminated buffer; which isn't guaranteed when blindly trusting the file data. When attempting to fuzz this code path, a variety of other crashes were discovered and fixed. Differential Revision: https://developer.blender.org/D11952 === M source/blender/imbuf/intern/radiance_hdr.c === diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 7f4e4dd31df..0bca68b93bc 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -77,7 +77,7 @@ static const unsigned char *oldreadcolrs(RGBE *scan, scan[0][BLU] = *mem++; scan[0][EXP] = *mem++; if (scan[0][RED] == 1 && scan[0][GRN] == 1 && scan[0][BLU] == 1) { - for (i = scan[0][EXP] << rshift; i > 0; i--) { + for (i = scan[0][EXP] << rshift; i > 0 && len > 0; i--) { COPY_RGBE(scan[-1], scan[0]); scan++; len--; @@ -227,7 +227,7 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, int found = 0; int width = 0, height = 0; const unsigned char *ptr, *mem_eof = mem + size; - char oriY[80], oriX[80]; + char oriY[3], oriX[3]; if (!imb_is_a_hdr(mem, size)) { return NULL; @@ -244,13 +244,19 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, } } - if ((found && (x < (size + 2))) == 0) { + if ((found && (x < (size - 1))) == 0) { /* Data not found! */ return NULL; } - if (sscanf((const char *)[x + 1], - "%79s %d %79s %d", + x++; + + /* sscanf requires a null-terminated buffer argument */ + char buf[32] = {0}; + memcpy(buf, [x], MIN2(sizeof(buf) - 1, size - x)); + + if (sscanf(buf, + "%2s %d %2s %d", (char *), , (char *), @@ -258,8 +264,18 @@ struct ImBuf *imb_loadhdr(const unsigned char *mem, return NULL; } + if (width < 1 || height < 1) { +return NULL; + } + + /* Checking that width x height does not extend past mem_eof is not easily possible + * since the format uses RLE compression. Can cause excessive memory allocation to occur. */ + /* find end of this line, data right behind it */ - ptr = (const unsigned char *)strchr((const char *)[x + 1], '\n'); + ptr = (const unsigned char *)strchr((const char *)[x], '\n'); + if (ptr == NULL || ptr >= mem_eof) { +return NULL; + } ptr++; if (flags & IB_test) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e07f16776bc] blender-v2.93-release: Fix T94629: The IMB_flip API would fail with large images
Commit: e07f16776bca5e9494e6b143170f31d5eeb160ce Author: Jesse Yurkovich Date: Thu Jan 6 21:35:04 2022 -0800 Branches: blender-v2.93-release https://developer.blender.org/rBe07f16776bca5e9494e6b143170f31d5eeb160ce Fix T94629: The IMB_flip API would fail with large images Fix IMB_flip[xy] to handle cases where integer overflow might occur when given sufficiently large image dimensions. All of these fixes were of a similar class where the intermediate sub-expression would overflow silently. Widen the types as necessary. Differential Revision: https://developer.blender.org/D13744 === M source/blender/imbuf/intern/rotate.c === diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index c2fc2190ce5..f02f3e37d6a 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -32,7 +32,7 @@ void IMB_flipy(struct ImBuf *ibuf) { - int x, y; + size_t x_size, y_size; if (ibuf == NULL) { return; @@ -41,21 +41,23 @@ void IMB_flipy(struct ImBuf *ibuf) if (ibuf->rect) { unsigned int *top, *bottom, *line; -x = ibuf->x; -y = ibuf->y; +x_size = ibuf->x; +y_size = ibuf->y; + +const size_t stride = x_size * sizeof(int); top = ibuf->rect; -bottom = top + ((y - 1) * x); -line = MEM_mallocN(x * sizeof(int), "linebuf"); +bottom = top + ((y_size - 1) * x_size); +line = MEM_mallocN(stride, "linebuf"); -y >>= 1; +y_size >>= 1; -for (; y > 0; y--) { - memcpy(line, top, x * sizeof(int)); - memcpy(top, bottom, x * sizeof(int)); - memcpy(bottom, line, x * sizeof(int)); - bottom -= x; - top += x; +for (; y_size > 0; y_size--) { + memcpy(line, top, stride); + memcpy(top, bottom, stride); + memcpy(bottom, line, stride); + bottom -= x_size; + top += x_size; } MEM_freeN(line); @@ -64,21 +66,23 @@ void IMB_flipy(struct ImBuf *ibuf) if (ibuf->rect_float) { float *topf = NULL, *bottomf = NULL, *linef = NULL; -x = ibuf->x; -y = ibuf->y; +x_size = ibuf->x; +y_size = ibuf->y; + +const size_t stride = x_size * 4 * sizeof(float); topf = ibuf->rect_float; -bottomf = topf + 4 * ((y - 1) * x); -linef = MEM_mallocN(4 * x * sizeof(float), "linebuff"); +bottomf = topf + 4 * ((y_size - 1) * x_size); +linef = MEM_mallocN(stride, "linebuf"); -y >>= 1; +y_size >>= 1; -for (; y > 0; y--) { - memcpy(linef, topf, 4 * x * sizeof(float)); - memcpy(topf, bottomf, 4 * x * sizeof(float)); - memcpy(bottomf, linef, 4 * x * sizeof(float)); - bottomf -= 4 * x; - topf += 4 * x; +for (; y_size > 0; y_size--) { + memcpy(linef, topf, stride); + memcpy(topf, bottomf, stride); + memcpy(bottomf, linef, stride); + bottomf -= 4 * x_size; + topf += 4 * x_size; } MEM_freeN(linef); @@ -99,20 +103,22 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect) { for (yi = y - 1; yi >= 0; yi--) { + const size_t x_offset = (size_t)x * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { -SWAP(unsigned int, ibuf->rect[(x * yi) + xr], ibuf->rect[(x * yi) + xl]); +SWAP(unsigned int, ibuf->rect[x_offset + xr], ibuf->rect[x_offset + xl]); } } } if (ibuf->rect_float) { for (yi = y - 1; yi >= 0; yi--) { + const size_t x_offset = (size_t)x * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { -memcpy(_f, >rect_float[((x * yi) + xr) * 4], sizeof(float[4])); -memcpy(>rect_float[((x * yi) + xr) * 4], - >rect_float[((x * yi) + xl) * 4], +memcpy(_f, >rect_float[(x_offset + xr) * 4], sizeof(float[4])); +memcpy(>rect_float[(x_offset + xr) * 4], + >rect_float[(x_offset + xl) * 4], sizeof(float[4])); -memcpy(>rect_float[((x * yi) + xl) * 4], _f, sizeof(float[4])); +memcpy(>rect_float[(x_offset + xl) * 4], _f, sizeof(float[4])); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ff5630b7faf] blender-v3.0-release: Fix T92740: Missing lock around the image CacheLimiter
Commit: ff5630b7fafec56d9b1187ee42e8b786b62cb498 Author: Jesse Yurkovich Date: Thu Nov 4 20:58:32 2021 -0700 Branches: blender-v3.0-release https://developer.blender.org/rBff5630b7fafec56d9b1187ee42e8b786b62cb498 Fix T92740: Missing lock around the image CacheLimiter A recent change exposed this long-standing race. Simply protect the MEM_CacheLimiter with its lock now. Additionally, guard against unmanaging an already destroyed cache handle. Ref T92740, T92838 === M source/blender/imbuf/intern/moviecache.c === diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 4f316150e10..1bc0a4e628d 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -122,7 +122,12 @@ static void moviecache_valfree(void *val) PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf); - MEM_CacheLimiter_unmanage(item->c_handle); + BLI_mutex_lock(_lock); + if (item->c_handle) { +MEM_CacheLimiter_unmanage(item->c_handle); + } + BLI_mutex_unlock(_lock); + if (item->ibuf) { IMB_freeImBuf(item->ibuf); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0564b19ff4d] blender-v3.0-release: Cleanup: Correct order of guard and lock in moviecache_valfree
Commit: 0564b19ff4dd489a45f639bc2d360a0b586317bf Author: Jesse Yurkovich Date: Fri Nov 12 20:47:26 2021 -0800 Branches: blender-v3.0-release https://developer.blender.org/rB0564b19ff4dd489a45f639bc2d360a0b586317bf Cleanup: Correct order of guard and lock in moviecache_valfree Fix own mistake in rB7061d1e39fe In my attempt to quickly address T92838, along with the original bug, I made a nonsensical choice to use the limiter lock to guard the check against the cache item itself. While harmless, it is not necessary and semantically wrong / potentially confusing to future readers of the code. Differential Revision: https://developer.blender.org/D13122 === M source/blender/imbuf/intern/moviecache.c === diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 1bc0a4e628d..8923ba98e08 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -122,11 +122,11 @@ static void moviecache_valfree(void *val) PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf); - BLI_mutex_lock(_lock); if (item->c_handle) { +BLI_mutex_lock(_lock); MEM_CacheLimiter_unmanage(item->c_handle); +BLI_mutex_unlock(_lock); } - BLI_mutex_unlock(_lock); if (item->ibuf) { IMB_freeImBuf(item->ibuf); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c37cd354690] blender-v3.0-release: Fix T93541: Use warning instead of error for exceeding layer limits
Commit: c37cd3546904ce73ad57f9de73427a585c583b12 Author: Jesse Yurkovich Date: Fri Dec 3 17:01:10 2021 +1100 Branches: blender-v3.0-release https://developer.blender.org/rBc37cd3546904ce73ad57f9de73427a585c583b12 Fix T93541: Use warning instead of error for exceeding layer limits Instead of using RPT_ERROR, use RPT_WARNING which will not raise an exception to Python. This broke some scripts (including FBX import) which already check for a None return value. Ref D13458 Reviewed By: campbellbarton === M source/blender/editors/mesh/mesh_data.c === diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 7391451b694..7ce408b571f 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -267,7 +267,7 @@ int ED_mesh_uv_texture_add( layernum_dst = CustomData_number_of_layers(>bm->ldata, CD_MLOOPUV); if (layernum_dst >= MAX_MTFACE) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i UV maps", MAX_MTFACE); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE); return -1; } @@ -287,7 +287,7 @@ int ED_mesh_uv_texture_add( else { layernum_dst = CustomData_number_of_layers(>ldata, CD_MLOOPUV); if (layernum_dst >= MAX_MTFACE) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i UV maps", MAX_MTFACE); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE); return -1; } @@ -393,7 +393,7 @@ int ED_mesh_color_add( layernum = CustomData_number_of_layers(>bm->ldata, CD_MLOOPCOL); if (layernum >= MAX_MCOL) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i vertex color layers", MAX_MCOL); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i vertex color layers", MAX_MCOL); return -1; } @@ -411,7 +411,7 @@ int ED_mesh_color_add( else { layernum = CustomData_number_of_layers(>ldata, CD_MLOOPCOL); if (layernum >= MAX_MCOL) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i vertex color layers", MAX_MCOL); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i vertex color layers", MAX_MCOL); return -1; } @@ -529,7 +529,7 @@ int ED_mesh_sculpt_color_add( layernum = CustomData_number_of_layers(>bm->vdata, CD_PROP_COLOR); if (layernum >= MAX_MCOL) { BKE_reportf( - reports, RPT_ERROR, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); + reports, RPT_WARNING, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); return -1; } @@ -548,7 +548,7 @@ int ED_mesh_sculpt_color_add( layernum = CustomData_number_of_layers(>vdata, CD_PROP_COLOR); if (layernum >= MAX_MCOL) { BKE_reportf( - reports, RPT_ERROR, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); + reports, RPT_WARNING, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); return -1; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [82858ca3f4e] master: Fix T94629: The IMB_flip API would fail with large images
Commit: 82858ca3f4e6dc6f840af9306c350900abd491fc Author: Jesse Yurkovich Date: Thu Jan 6 21:35:04 2022 -0800 Branches: master https://developer.blender.org/rB82858ca3f4e6dc6f840af9306c350900abd491fc Fix T94629: The IMB_flip API would fail with large images Fix IMB_flip[xy] to handle cases where integer overflow might occur when given sufficiently large image dimensions. All of these fixes were of a similar class where the intermediate sub-expression would overflow silently. Widen the types as necessary. Differential Revision: https://developer.blender.org/D13744 === M source/blender/imbuf/intern/rotate.c === diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 83dc29aa107..f02f3e37d6a 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -32,7 +32,7 @@ void IMB_flipy(struct ImBuf *ibuf) { - int x, y; + size_t x_size, y_size; if (ibuf == NULL) { return; @@ -41,21 +41,23 @@ void IMB_flipy(struct ImBuf *ibuf) if (ibuf->rect) { unsigned int *top, *bottom, *line; -x = ibuf->x; -y = ibuf->y; +x_size = ibuf->x; +y_size = ibuf->y; + +const size_t stride = x_size * sizeof(int); top = ibuf->rect; -bottom = top + ((y - 1) * x); -line = MEM_mallocN(x * sizeof(int), "linebuf"); +bottom = top + ((y_size - 1) * x_size); +line = MEM_mallocN(stride, "linebuf"); -y >>= 1; +y_size >>= 1; -for (; y > 0; y--) { - memcpy(line, top, x * sizeof(int)); - memcpy(top, bottom, x * sizeof(int)); - memcpy(bottom, line, x * sizeof(int)); - bottom -= x; - top += x; +for (; y_size > 0; y_size--) { + memcpy(line, top, stride); + memcpy(top, bottom, stride); + memcpy(bottom, line, stride); + bottom -= x_size; + top += x_size; } MEM_freeN(line); @@ -64,21 +66,23 @@ void IMB_flipy(struct ImBuf *ibuf) if (ibuf->rect_float) { float *topf = NULL, *bottomf = NULL, *linef = NULL; -x = ibuf->x; -y = ibuf->y; +x_size = ibuf->x; +y_size = ibuf->y; + +const size_t stride = x_size * 4 * sizeof(float); topf = ibuf->rect_float; -bottomf = topf + 4 * ((y - 1) * x); -linef = MEM_mallocN(4 * x * sizeof(float), "linebuf"); +bottomf = topf + 4 * ((y_size - 1) * x_size); +linef = MEM_mallocN(stride, "linebuf"); -y >>= 1; +y_size >>= 1; -for (; y > 0; y--) { - memcpy(linef, topf, 4 * x * sizeof(float)); - memcpy(topf, bottomf, 4 * x * sizeof(float)); - memcpy(bottomf, linef, 4 * x * sizeof(float)); - bottomf -= 4 * x; - topf += 4 * x; +for (; y_size > 0; y_size--) { + memcpy(linef, topf, stride); + memcpy(topf, bottomf, stride); + memcpy(bottomf, linef, stride); + bottomf -= 4 * x_size; + topf += 4 * x_size; } MEM_freeN(linef); @@ -99,20 +103,22 @@ void IMB_flipx(struct ImBuf *ibuf) if (ibuf->rect) { for (yi = y - 1; yi >= 0; yi--) { + const size_t x_offset = (size_t)x * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { -SWAP(unsigned int, ibuf->rect[(x * yi) + xr], ibuf->rect[(x * yi) + xl]); +SWAP(unsigned int, ibuf->rect[x_offset + xr], ibuf->rect[x_offset + xl]); } } } if (ibuf->rect_float) { for (yi = y - 1; yi >= 0; yi--) { + const size_t x_offset = (size_t)x * yi; for (xr = x - 1, xl = 0; xr >= xl; xr--, xl++) { -memcpy(_f, >rect_float[((x * yi) + xr) * 4], sizeof(float[4])); -memcpy(>rect_float[((x * yi) + xr) * 4], - >rect_float[((x * yi) + xl) * 4], +memcpy(_f, >rect_float[(x_offset + xr) * 4], sizeof(float[4])); +memcpy(>rect_float[(x_offset + xr) * 4], + >rect_float[(x_offset + xl) * 4], sizeof(float[4])); -memcpy(>rect_float[((x * yi) + xl) * 4], _f, sizeof(float[4])); +memcpy(>rect_float[(x_offset + xl) * 4], _f, sizeof(float[4])); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [180b66ae8a1] master: UDIM: Support virtual filenames
Commit: 180b66ae8a1ffc0a1bb7d3993028240b4c7f7246 Author: Jesse Yurkovich Date: Thu Dec 30 22:06:23 2021 -0800 Branches: master https://developer.blender.org/rB180b66ae8a1ffc0a1bb7d3993028240b4c7f7246 UDIM: Support virtual filenames This implements the design detailed in T92696 to support virtual filenames for UDIM textures. Currently, the following 2 substitution tokens are supported: | Token | Meaning | | - | | || 1001 + u-tile + v-tile * 10 | | | Equivalent to u_v | Example for u-tile of 3 and v-tile of 1: filename._ver0023.png --> filename.1014_ver0023.png filename._ver0023.png --> filename.u4_v2_ver0023.png For image loading, the existing workflow is unchanged. A user can select one or more image files, belonging to one or more UDIM tile sets, and have Blender load them all as it does today. Now the format is "guessed" just as the format was guessed before. If guessing fails, the user can simply go into the Image Editor and type the proper substitution in the filename. Once typing is complete, Blender will reload the files and correctly fill the tiles. This workflow is new as attempting to fix the guessing in current versions did not really work, and the user was often stuck with a confusing situation. For image saving, the existing workflow is changed slightly. Currently, when saving, a user has to be sure to type the filename of the first tile (e.g. filename.1001.png) to save the entire UDIM set. The number could differ if they start at a different tile etc. This is confusing. Now, the user should type a filename containing the appropriate substitution token. By default Blender will fill in a default name using the token but the user is free to save out images using if they wish. Differential Revision: https://developer.blender.org/D13057 === M intern/cycles/blender/shader.cpp M intern/cycles/blender/util.h M intern/cycles/scene/image.cpp M source/blender/blenkernel/BKE_bpath.h M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/intern/bpath.c M source/blender/blenkernel/intern/image.c M source/blender/blenkernel/intern/image_save.c M source/blender/blenlib/BLI_path_util.h M source/blender/blenlib/intern/path_util.c M source/blender/blenloader/intern/versioning_300.c M source/blender/editors/space_file/file_ops.c M source/blender/editors/space_file/filesel.c M source/blender/editors/space_image/image_ops.c M source/blender/editors/space_image/image_sequence.c M source/blender/makesdna/DNA_space_types.h === diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cpp index 70acfce6891..5604c2989fd 100644 --- a/intern/cycles/blender/shader.cpp +++ b/intern/cycles/blender/shader.cpp @@ -776,7 +776,7 @@ static ShaderNode *add_node(Scene *scene, } else { ustring filename = ustring( -image_user_file_path(b_image_user, b_image, b_scene.frame_current(), true)); +image_user_file_path(b_image_user, b_image, b_scene.frame_current())); image->set_filename(filename); } } @@ -813,7 +813,7 @@ static ShaderNode *add_node(Scene *scene, } else { env->set_filename( -ustring(image_user_file_path(b_image_user, b_image, b_scene.frame_current(), false))); +ustring(image_user_file_path(b_image_user, b_image, b_scene.frame_current(; } } node = env; diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h index be36bcdaaa8..6c396d39614 100644 --- a/intern/cycles/blender/util.h +++ b/intern/cycles/blender/util.h @@ -33,7 +33,7 @@ extern "C" { void BKE_image_user_frame_calc(void *ima, void *iuser, int cfra); -void BKE_image_user_file_path(void *iuser, void *ima, char *path); +void BKE_image_user_file_path_ex(void *iuser, void *ima, char *path, bool resolve_udim); unsigned char *BKE_image_get_pixels_for_frame(void *image, int frame, int tile); float *BKE_image_get_float_pixels_for_frame(void *image, int frame, int tile); } @@ -290,25 +290,14 @@ static inline int render_resolution_y(BL::RenderSettings _render) return b_render.resolution_y() * b_render.resolution_percentage() / 100; } -static inline string image_user_file_path(BL::ImageUser , - BL::Image , - int cfra, - bool load_tiled) +static inline string image_user_file_path(BL::ImageUser , BL::Image , int cfra) { char filepath[1024]; iuser.tile(0); BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); - BKE_image_user_file_path(iuser.ptr.data, ima.ptr.data, filepath); + BKE_image_user_file_path_ex(iuser.ptr.data, ima.ptr.data, filepath,
[Bf-blender-cvs] [7c4fc5b58d2] master: Fix T93541: Use warning instead of error for exceeding layer limits
Commit: 7c4fc5b58d2e7982aefbba093cb8f1dc36b64884 Author: Jesse Yurkovich Date: Fri Dec 3 17:01:10 2021 +1100 Branches: master https://developer.blender.org/rB7c4fc5b58d2e7982aefbba093cb8f1dc36b64884 Fix T93541: Use warning instead of error for exceeding layer limits Instead of using RPT_ERROR, use RPT_WARNING which will not raise an exception to Python. This broke some scripts (including FBX import) which already check for a None return value. Ref D13458 Reviewed By: campbellbarton === M source/blender/editors/mesh/mesh_data.c === diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 7391451b694..7ce408b571f 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -267,7 +267,7 @@ int ED_mesh_uv_texture_add( layernum_dst = CustomData_number_of_layers(>bm->ldata, CD_MLOOPUV); if (layernum_dst >= MAX_MTFACE) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i UV maps", MAX_MTFACE); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE); return -1; } @@ -287,7 +287,7 @@ int ED_mesh_uv_texture_add( else { layernum_dst = CustomData_number_of_layers(>ldata, CD_MLOOPUV); if (layernum_dst >= MAX_MTFACE) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i UV maps", MAX_MTFACE); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i UV maps", MAX_MTFACE); return -1; } @@ -393,7 +393,7 @@ int ED_mesh_color_add( layernum = CustomData_number_of_layers(>bm->ldata, CD_MLOOPCOL); if (layernum >= MAX_MCOL) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i vertex color layers", MAX_MCOL); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i vertex color layers", MAX_MCOL); return -1; } @@ -411,7 +411,7 @@ int ED_mesh_color_add( else { layernum = CustomData_number_of_layers(>ldata, CD_MLOOPCOL); if (layernum >= MAX_MCOL) { - BKE_reportf(reports, RPT_ERROR, "Cannot add more than %i vertex color layers", MAX_MCOL); + BKE_reportf(reports, RPT_WARNING, "Cannot add more than %i vertex color layers", MAX_MCOL); return -1; } @@ -529,7 +529,7 @@ int ED_mesh_sculpt_color_add( layernum = CustomData_number_of_layers(>bm->vdata, CD_PROP_COLOR); if (layernum >= MAX_MCOL) { BKE_reportf( - reports, RPT_ERROR, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); + reports, RPT_WARNING, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); return -1; } @@ -548,7 +548,7 @@ int ED_mesh_sculpt_color_add( layernum = CustomData_number_of_layers(>vdata, CD_PROP_COLOR); if (layernum >= MAX_MCOL) { BKE_reportf( - reports, RPT_ERROR, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); + reports, RPT_WARNING, "Cannot add more than %i sculpt vertex color layers", MAX_MCOL); return -1; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0cbcddd91e1] master: Merge branch 'blender-v3.0-release'
Commit: 0cbcddd91e156a7a37ecc79f6ea68b481267617e Author: Jesse Yurkovich Date: Mon Nov 29 02:14:05 2021 -0800 Branches: master https://developer.blender.org/rB0cbcddd91e156a7a37ecc79f6ea68b481267617e Merge branch 'blender-v3.0-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b31250feba4] blender-v3.0-release: Fix T93456: Properly translate operator on splash screen
Commit: b31250feba4c89856fd08e62850ddf80b5262ad0 Author: Jesse Yurkovich Date: Mon Nov 29 02:04:32 2021 -0800 Branches: blender-v3.0-release https://developer.blender.org/rBb31250feba4c89856fd08e62850ddf80b5262ad0 Fix T93456: Properly translate operator on splash screen Use the translation API to lookup the string before formatting occurs. Differential Revision: https://developer.blender.org/D13400 === M release/scripts/startup/bl_operators/wm.py === diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 28bb0a58c02..65692062f48 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -2970,7 +2970,7 @@ class WM_MT_splash_quick_setup(Menu): sub = row.row() old_version = bpy.types.PREFERENCES_OT_copy_prev.previous_version() if bpy.types.PREFERENCES_OT_copy_prev.poll(context) and old_version: -sub.operator("preferences.copy_prev", text="Load %d.%d Settings" % old_version) +sub.operator("preferences.copy_prev", text=iface_("Load %d.%d Settings", "Operator") % old_version) sub.operator("wm.save_userpref", text="Save New Settings") else: sub.label() ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [28870a8f890] master: Cleanup: Use new CollectionRef::empty() method
Commit: 28870a8f890b503c7dd5df9f949fc7030d56e8e4 Author: Jesse Yurkovich Date: Mon Nov 22 23:47:26 2021 -0800 Branches: master https://developer.blender.org/rB28870a8f890b503c7dd5df9f949fc7030d56e8e4 Cleanup: Use new CollectionRef::empty() method Use the new CollectionRef::empty() method in all locations where appropriate. Differential Revision: https://developer.blender.org/D13276 === M intern/cycles/blender/curves.cpp M intern/cycles/blender/mesh.cpp M intern/cycles/blender/util.h === diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index ffe0c553738..c96d01a8ffb 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -199,7 +199,7 @@ static bool ObtainCacheParticleUV(Hair *hair, b_mesh->uv_layers.begin(l); float2 uv = zero_float2(); - if (b_mesh->uv_layers.length()) + if (!b_mesh->uv_layers.empty()) b_psys.uv_on_emitter(psmd, *b_pa, pa_no, uv_num, ); CData->curve_uv.push_back_slow(uv); @@ -261,7 +261,7 @@ static bool ObtainCacheParticleVcol(Hair *hair, b_mesh->vertex_colors.begin(l); float4 vcol = make_float4(0.0f, 0.0f, 0.0f, 1.0f); - if (b_mesh->vertex_colors.length()) + if (!b_mesh->vertex_colors.empty()) b_psys.mcol_on_emitter(psmd, *b_pa, pa_no, vcol_num, ); CData->curve_vcol.push_back_slow(vcol); diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index b69bf88c213..bb17cfdcb45 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -555,7 +555,7 @@ static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh _mesh, /* Create uv map attributes. */ static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh _mesh) { - if (b_mesh.uv_layers.length() != 0) { + if (!b_mesh.uv_layers.empty()) { for (BL::MeshUVLoopLayer : b_mesh.uv_layers) { const bool active_render = l.active_render(); AttributeStandard uv_std = (active_render) ? ATTR_STD_UV : ATTR_STD_NONE; @@ -619,7 +619,7 @@ static void attr_create_uv_map(Scene *scene, Mesh *mesh, BL::Mesh _mesh) static void attr_create_subd_uv_map(Scene *scene, Mesh *mesh, BL::Mesh _mesh, bool subdivide_uvs) { - if (b_mesh.uv_layers.length() != 0) { + if (!b_mesh.uv_layers.empty()) { BL::Mesh::uv_layers_iterator l; int i = 0; @@ -951,7 +951,7 @@ static void create_mesh(Scene *scene, N = attr_N->data_float3(); /* create generated coordinates from undeformed coordinates */ - const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.length() == 0) && + const bool need_default_tangent = (subdivision == false) && (b_mesh.uv_layers.empty()) && (mesh->need_attribute(scene, ATTR_STD_UV_TANGENT)); if (mesh->need_attribute(scene, ATTR_STD_GENERATED) || need_default_tangent) { Attribute *attr = attributes.add(ATTR_STD_GENERATED); diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h index 33fd2c416c8..be36bcdaaa8 100644 --- a/intern/cycles/blender/util.h +++ b/intern/cycles/blender/util.h @@ -303,7 +303,7 @@ static inline string image_user_file_path(BL::ImageUser , string filepath_str = string(filepath); if (load_tiled && ima.source() == BL::Image::source_TILED) { string udim; -if (ima.tiles.length() > 0) { +if (!ima.tiles.empty()) { udim = to_string(ima.tiles[0].number()); } string_replace(filepath_str, udim, ""); @@ -647,7 +647,7 @@ static inline Mesh::SubdivisionType object_subdivision_type(BL::Object _ob, { PointerRNA cobj = RNA_pointer_get(_ob.ptr, "cycles"); - if (cobj.data && b_ob.modifiers.length() > 0 && experimental) { + if (cobj.data && !b_ob.modifiers.empty() && experimental) { BL::Modifier mod = b_ob.modifiers[b_ob.modifiers.length() - 1]; bool enabled = preview ? mod.show_viewport() : mod.show_render(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5ed3a5d0237] master: Cleanup: Add an empty() method to RNA's CollectionRef class
Commit: 5ed3a5d0237949411fe403c9a1cbb5a53a685f69 Author: Jesse Yurkovich Date: Thu Nov 18 14:32:56 2021 -0800 Branches: master https://developer.blender.org/rB5ed3a5d0237949411fe403c9a1cbb5a53a685f69 Cleanup: Add an empty() method to RNA's CollectionRef class The existing RNA CollectionRef class only offers a length() operation which is sometimes used for checking if the collection is empty. This is inefficient for certain collection types which do not have a native length member; the entire list is iterated to find the count. This patch creates an explicit empty() method to be used in such cases for better semantics. Additionally, many collection types will behave more efficiently when using the new method instead of checking length. Making use of the new method will follow separately. Differential Revision: https://developer.blender.org/D12314 === M source/blender/makesrna/intern/makesrna.c === diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index f2e87b29c1f..a6732ca1760 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -4698,6 +4698,19 @@ static const char *cpp_classes = "inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n" "{ return sname##_##identifier##_length(ptr); } \n" "\n" +"#define COLLECTION_PROPERTY_EMPTY_false(sname, identifier) \\\n" +"inline static bool sname##_##identifier##_empty_wrap(PointerRNA *ptr) \\\n" +"{ \\\n" +"CollectionPropertyIterator iter; \\\n" +"sname##_##identifier##_begin(, ptr); \\\n" +"bool empty = !iter.valid; \\\n" +"sname##_##identifier##_end(); \\\n" +"return empty; \\\n" +"} \n" +"#define COLLECTION_PROPERTY_EMPTY_true(sname, identifier) \\\n" +"inline static bool sname##_##identifier##_empty_wrap(PointerRNA *ptr) \\\n" +"{ return sname##_##identifier##_length(ptr) == 0; } \n" +"\n" "#define COLLECTION_PROPERTY_LOOKUP_INT_false(sname, identifier) \\\n" "inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, " "PointerRNA *r_ptr) \\\n" @@ -4774,11 +4787,13 @@ static const char *cpp_classes = "typedef CollectionIterator identifier##_iterator; \\\n" "COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n" +"COLLECTION_PROPERTY_EMPTY_##has_length(sname, identifier) \\\n" "COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n" "COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n" "CollectionRef identifier;\n" "\n" @@ -4844,6 +4859,7 @@ static const char *cpp_classes = "typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n" "typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n" "typedef int (*TLengthFunc)(PointerRNA *ptr);\n" +"typedef bool (*TEmptyFunc)(PointerRNA *ptr);\n" "typedef int (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n" "typedef int (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n" "\n" @@ -4882,8 +4898,8 @@ static const char *cpp_classes = "};\n" "\n" "template\n" +" TLengthFunc Tlength, TEmptyFunc Tempty, TLookupIntFunc Tlookup_int,\n" +" TLookupStringFunc Tlookup_string, typename Tcollection_funcs>\n" "class CollectionRef : public Tcollection_funcs {\n" "public:\n" "CollectionRef(const PointerRNA ) : Tcollection_funcs(p), ptr(p) {}\n" @@ -4897,6 +4913,8 @@ static const char *cpp_classes = "" "int length()\n" "{ return Tlength(); }\n" +"bool empty()\n" +"{ return Tempty(); }\n" "T operator[](int key)\n" "{ PointerRNA r_ptr; Tlookup_int(, key, _ptr); return T(r_ptr); }\n" "T operator[](const std::string )\n" ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e8a8bb67fce] master: Cleanup: Correct order of guard and lock in moviecache_valfree
Commit: e8a8bb67fcefa5e935214e1af1ec3da38465dda1 Author: Jesse Yurkovich Date: Fri Nov 12 20:47:26 2021 -0800 Branches: master https://developer.blender.org/rBe8a8bb67fcefa5e935214e1af1ec3da38465dda1 Cleanup: Correct order of guard and lock in moviecache_valfree Fix own mistake in rB7061d1e39fe In my attempt to quickly address T92838, along with the original bug, I made a nonsensical choice to use the limiter lock to guard the check against the cache item itself. While harmless, it is not necessary and semantically wrong / potentially confusing to future readers of the code. Differential Revision: https://developer.blender.org/D13122 === M source/blender/imbuf/intern/moviecache.c === diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 1bc0a4e628d..8923ba98e08 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -122,11 +122,11 @@ static void moviecache_valfree(void *val) PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf); - BLI_mutex_lock(_lock); if (item->c_handle) { +BLI_mutex_lock(_lock); MEM_CacheLimiter_unmanage(item->c_handle); +BLI_mutex_unlock(_lock); } - BLI_mutex_unlock(_lock); if (item->ibuf) { IMB_freeImBuf(item->ibuf); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7061d1e39fe] master: Fix T92740: Missing lock around the image CacheLimiter
Commit: 7061d1e39fea7495e787a071b83757e3dc0d61a7 Author: Jesse Yurkovich Date: Thu Nov 4 20:58:32 2021 -0700 Branches: master https://developer.blender.org/rB7061d1e39fea7495e787a071b83757e3dc0d61a7 Fix T92740: Missing lock around the image CacheLimiter A recent change exposed this long-standing race. Simply protect the MEM_CacheLimiter with its lock now. Additionally, guard against unmanaging an already destroyed cache handle. Ref T92740, T92838 === M source/blender/imbuf/intern/moviecache.c === diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 6e7b85a300a..34c180ba1fb 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -122,7 +122,12 @@ static void moviecache_valfree(void *val) PRINT("%s: cache '%s' free item %p buffer %p\n", __func__, cache->name, item, item->ibuf); - MEM_CacheLimiter_unmanage(item->c_handle); + BLI_mutex_lock(_lock); + if (item->c_handle) { +MEM_CacheLimiter_unmanage(item->c_handle); + } + BLI_mutex_unlock(_lock); + if (item->ibuf) { IMB_freeImBuf(item->ibuf); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [45866883237] master: Fix nonnull-compare warning in DNA_view3d_types.h
Commit: 458668832370d3aa98b0f75c4587534e75d60fe4 Author: Jesse Yurkovich Date: Fri Oct 15 19:17:06 2021 -0700 Branches: master https://developer.blender.org/rB458668832370d3aa98b0f75c4587534e75d60fe4 Fix nonnull-compare warning in DNA_view3d_types.h Was introduced in rB93a8fd1249f === M source/blender/makesdna/DNA_view3d_types.h === diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index d5db72ea85a..9b5ed133feb 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -501,16 +501,14 @@ enum { }; #define V3D_USES_SCENE_LIGHTS(v3d) \ - ((v3d) && \ - v3d)->shading.type == OB_MATERIAL) && ((v3d)->shading.flag & V3D_SHADING_SCENE_LIGHTS)) || \ -(((v3d)->shading.type == OB_RENDER) && \ - ((v3d)->shading.flag & V3D_SHADING_SCENE_LIGHTS_RENDER + v3d)->shading.type == OB_MATERIAL) && ((v3d)->shading.flag & V3D_SHADING_SCENE_LIGHTS)) || \ + (((v3d)->shading.type == OB_RENDER) && \ +((v3d)->shading.flag & V3D_SHADING_SCENE_LIGHTS_RENDER))) #define V3D_USES_SCENE_WORLD(v3d) \ - ((v3d) && \ - v3d)->shading.type == OB_MATERIAL) && ((v3d)->shading.flag & V3D_SHADING_SCENE_WORLD)) || \ -(((v3d)->shading.type == OB_RENDER) && \ - ((v3d)->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER + v3d)->shading.type == OB_MATERIAL) && ((v3d)->shading.flag & V3D_SHADING_SCENE_WORLD)) || \ + (((v3d)->shading.type == OB_RENDER) && \ +((v3d)->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER))) /** #View3DShading.cavity_type */ enum { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [93a8fd1249f] master: Cleanup: Commonize code for checking scene lights/world settings
Commit: 93a8fd1249ffc64ee089b8c3192908dec247fc07 Author: Jesse Yurkovich Date: Fri Oct 15 11:42:21 2021 +0200 Branches: master https://developer.blender.org/rB93a8fd1249ffc64ee089b8c3192908dec247fc07 Cleanup: Commonize code for checking scene lights/world settings There were several places attempting to check to see if scene lights and world were enabled for display. This tries to find a common place for both of these to reduce duplication. Honestly, I couldn't find a really good spot for these and settled on DRW_engine. It's not the best spot since they're not strictly drawing related, but let's start here. Reviewed By: fclem Differential Revision: https://developer.blender.org/D12658 === M release/scripts/addons M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/intern/draw_color_management.cc M source/blender/editors/space_view3d/space_view3d.c M source/blender/makesdna/DNA_view3d_types.h === diff --git a/release/scripts/addons b/release/scripts/addons index f10ca8c1561..67f1fbca148 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit f10ca8c156169b24e70027a43f718f99571d280f +Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230 diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 1078cebdbff..50e32040522 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -120,15 +120,9 @@ void GPENCIL_engine_init(void *ved) bool use_scene_world = false; if (v3d) { -use_scene_lights = ((v3d->shading.type == OB_MATERIAL) && -(v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS)) || - ((v3d->shading.type == OB_RENDER) && -(v3d->shading.flag & V3D_SHADING_SCENE_LIGHTS_RENDER)); - -use_scene_world = ((v3d->shading.type == OB_MATERIAL) && - (v3d->shading.flag & V3D_SHADING_SCENE_WORLD)) || - ((v3d->shading.type == OB_RENDER) && - (v3d->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER)); +use_scene_lights = V3D_USES_SCENE_LIGHTS(v3d); + +use_scene_world = V3D_USES_SCENE_WORLD(v3d); stl->pd->v3d_color_type = (v3d->shading.type == OB_SOLID) ? v3d->shading.color_type : -1; /* Special case: If Vertex Paint mode, use always Vertex mode. */ diff --git a/source/blender/draw/intern/draw_color_management.cc b/source/blender/draw/intern/draw_color_management.cc index 23fa18c83c5..70035c7c6f8 100644 --- a/source/blender/draw/intern/draw_color_management.cc +++ b/source/blender/draw/intern/draw_color_management.cc @@ -30,6 +30,7 @@ #include "GPU_texture.h" #include "DNA_space_types.h" +#include "DNA_view3d_types.h" #include "BKE_colortools.h" @@ -60,14 +61,8 @@ static eDRWColorManagementType drw_color_management_type_for_v3d(const Scene { const bool use_workbench = BKE_scene_uses_blender_workbench(); - const bool use_scene_lights = ((v3d.shading.type == OB_MATERIAL) && - (v3d.shading.flag & V3D_SHADING_SCENE_LIGHTS)) || -((v3d.shading.type == OB_RENDER) && - (v3d.shading.flag & V3D_SHADING_SCENE_LIGHTS_RENDER)); - const bool use_scene_world = ((v3d.shading.type == OB_MATERIAL) && -(v3d.shading.flag & V3D_SHADING_SCENE_WORLD)) || - ((v3d.shading.type == OB_RENDER) && -(v3d.shading.flag & V3D_SHADING_SCENE_WORLD_RENDER)); + const bool use_scene_lights = V3D_USES_SCENE_LIGHTS(); + const bool use_scene_world = V3D_USES_SCENE_WORLD(); if ((use_workbench && v3d.shading.type == OB_RENDER) || use_scene_lights || use_scene_world) { return eDRWColorManagementType::UseRenderSettings; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index bda6fa05a63..787cf529483 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -30,6 +30,7 @@ #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_view3d_types.h" #include "MEM_guardedalloc.h" @@ -1569,10 +1570,7 @@ static void space_view3d_listener(const wmSpaceTypeListenerParams *params) case NC_SCENE: switch (wmn->data) { case ND_WORLD: { -
[Bf-blender-cvs] [92b7bf48560] master: Cleanup: Remove data duplication from SMAA lookup tables
Commit: 92b7bf4856022bc27f21c5c60be717605d47930e Author: Jesse Yurkovich Date: Wed Oct 13 16:12:53 2021 +0200 Branches: master https://developer.blender.org/rB92b7bf4856022bc27f21c5c60be717605d47930e Cleanup: Remove data duplication from SMAA lookup tables These 2 large tables, `areaTexBytes` and `searchTexBytes`, contributed ~176kb worth of duplicate data into the `blender` executable due to the header being used in multiple places. We were lucky that only 2 translation units had included this header so only 1 duplicate copy of each was wasted. Define the tables as `extern` to address this. Reviewed By: fclem Differential Revision: https://developer.blender.org/D12723 === M release/scripts/addons M source/blender/draw/CMakeLists.txt A source/blender/draw/intern/smaa_textures.c M source/blender/draw/intern/smaa_textures.h === diff --git a/release/scripts/addons b/release/scripts/addons index f86f25e6221..67f1fbca148 16 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit f86f25e62217264495d05f116ccb09d575fe9841 +Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230 diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index dd4aa1747e5..62dcf438471 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -108,6 +108,7 @@ set(SRC intern/draw_select_buffer.c intern/draw_texture_pool.cc intern/draw_shader.c + intern/smaa_textures.c intern/draw_view.c engines/basic/basic_engine.c engines/image/image_engine.c diff --git a/source/blender/draw/intern/smaa_textures.h b/source/blender/draw/intern/smaa_textures.c similarity index 99% copy from source/blender/draw/intern/smaa_textures.h copy to source/blender/draw/intern/smaa_textures.c index 8f150c6cd7d..b34a641d838 100644 --- a/source/blender/draw/intern/smaa_textures.h +++ b/source/blender/draw/intern/smaa_textures.c @@ -26,12 +26,7 @@ * SOFTWARE. */ -#pragma once - -#define AREATEX_WIDTH 160 -#define AREATEX_HEIGHT 560 -#define AREATEX_PITCH (AREATEX_WIDTH * 2) -#define AREATEX_SIZE (AREATEX_HEIGHT * AREATEX_PITCH) +#include "smaa_textures.h" /* Don't re-wrap large data definitions. */ /* clang-format off */ @@ -40,7 +35,7 @@ * Stored in R8G8 format. Load it in the following format: * - DX10: DXGI_FORMAT_R8G8_UNORM */ -static const unsigned char areaTexBytes[] = { +const unsigned char areaTexBytes[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, @@ -14977,21 +14972,11 @@ static const unsigned char areaTexBytes[] = { 0x00, 0x00, 0x00, 0x00 }; -/* clang-format on */ - -#define SEARCHTEX_WIDTH 64 -#define SEARCHTEX_HEIGHT 16 -#define SEARCHTEX_PITCH SEARCHTEX_WIDTH -#define SEARCHTEX_SIZE (SEARCHTEX_HEIGHT * SEARCHTEX_PITCH) - -/* Don't re-wrap large data definitions. */ -/* clang-format off */ - /** * Stored in R8 format. Load it in the following format: * - DX10: DXGI_FORMAT_R8_UNORM */ -static const unsigned char searchTexBytes[] = { +const unsigned char searchTexBytes[] = { 0xfe, 0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x7f, 0x7f, 0x00, 0x7f, 0x7f, 0xfe, 0x7f, 0x00, @@ -15080,4 +15065,4 @@ static const unsigned char searchTexBytes[] = { 0x00, 0x00, 0x00, 0x00, }; -/* clang-format off */ +/* clang-format on */ diff --git a/source/blender/draw/intern/smaa_textures.h b/source/blender/draw/intern/smaa_textures.h index 8f150c6cd7d..bb3e3bdfb2f 100644 --- a/source/blender/draw/intern/smaa_textures.h +++ b/source/blender/draw/intern/smaa_textures.h @@ -33,15051 +33,19 @@ #define AREATEX_PITCH (AREATEX_WIDTH * 2) #define AREATEX_SIZE (AREATEX_HEIGHT * AREATEX_PITCH) -/* Don't re-wrap large data definitions. */ -/* clang-format off */ - /** * Stored in R8G8 format. Load it in the following format: * - DX10: DXGI_FORMAT_R8G8_UNORM */ -static const unsigned char areaTexBytes[] = { -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1f,
[Bf-blender-cvs] [76de3ac4ce4] master: Cleanup: Remove data duplication from various lookup tables in Cycles
Commit: 76de3ac4ce436dac4e3354fb7edbb67281ca9b54 Author: Jesse Yurkovich Date: Tue Oct 5 19:09:01 2021 -0700 Branches: master https://developer.blender.org/rB76de3ac4ce436dac4e3354fb7edbb67281ca9b54 Cleanup: Remove data duplication from various lookup tables in Cycles This effectively undoes some of the following commit: rB4537e8558468c71a03bf53f59c60f888b3412de2 The tables in question were duplicated 5-6 times into the blender executable due to the headers being used in multiple translation units. This contributes ~6.3kb worth of duplicate data into the binary. Some further details are in the below revision. Differential Revision: https://developer.blender.org/D12724 === M intern/cycles/kernel/svm/svm_math_util.h M intern/cycles/kernel/svm/svm_wavelength.h === diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h index 9e654f2247f..11b1e8f57f8 100644 --- a/intern/cycles/kernel/svm/svm_math_util.h +++ b/intern/cycles/kernel/svm/svm_math_util.h @@ -200,42 +200,42 @@ ccl_device float svm_math(NodeMathType type, float a, float b, float c) } } -/* Calculate color in range 800..12000 using an approximation - * a/x+bx+c for R and G and ((at + b)t + c)t + d) for B - * Max absolute error for RGB is (0.00095, 0.00077, 0.00057), - * which is enough to get the same 8 bit/channel color. - */ +ccl_device float3 svm_math_blackbody_color(float t) +{ + /* TODO(lukas): Reimplement in XYZ. */ -ccl_static_constant float blackbody_table_r[6][3] = { -{2.52432244e+03f, -1.06185848e-03f, 3.11067539e+00f}, -{3.37763626e+03f, -4.34581697e-04f, 1.64843306e+00f}, -{4.10671449e+03f, -8.61949938e-05f, 6.41423749e-01f}, -{4.66849800e+03f, 2.85655028e-05f, 1.29075375e-01f}, -{4.60124770e+03f, 2.89727618e-05f, 1.48001316e-01f}, -{3.78765709e+03f, 9.36026367e-06f, 3.98995841e-01f}, -}; + /* Calculate color in range 800..12000 using an approximation + * a/x+bx+c for R and G and ((at + b)t + c)t + d) for B + * Max absolute error for RGB is (0.00095, 0.00077, 0.00057), + * which is enough to get the same 8 bit/channel color. + */ -ccl_static_constant float blackbody_table_g[6][3] = { -{-7.50343014e+02f, 3.15679613e-04f, 4.73464526e-01f}, -{-1.00402363e+03f, 1.29189794e-04f, 9.08181524e-01f}, -{-1.22075471e+03f, 2.56245413e-05f, 1.20753416e+00f}, -{-1.42546105e+03f, -4.01730887e-05f, 1.44002695e+00f}, -{-1.18134453e+03f, -2.18913373e-05f, 1.30656109e+00f}, -{-5.00279505e+02f, -4.59745390e-06f, 1.09090465e+00f}, -}; + const float blackbody_table_r[6][3] = { + {2.52432244e+03f, -1.06185848e-03f, 3.11067539e+00f}, + {3.37763626e+03f, -4.34581697e-04f, 1.64843306e+00f}, + {4.10671449e+03f, -8.61949938e-05f, 6.41423749e-01f}, + {4.66849800e+03f, 2.85655028e-05f, 1.29075375e-01f}, + {4.60124770e+03f, 2.89727618e-05f, 1.48001316e-01f}, + {3.78765709e+03f, 9.36026367e-06f, 3.98995841e-01f}, + }; -ccl_static_constant float blackbody_table_b[6][4] = { -{0.0f, 0.0f, 0.0f, 0.0f}, /* zeros should be optimized by compiler */ -{0.0f, 0.0f, 0.0f, 0.0f}, -{0.0f, 0.0f, 0.0f, 0.0f}, -{-2.02524603e-11f, 1.79435860e-07f, -2.60561875e-04f, -1.41761141e-02f}, -{-2.22463426e-13f, -1.55078698e-08f, 3.81675160e-04f, -7.30646033e-01f}, -{6.72595954e-13f, -2.73059993e-08f, 4.24068546e-04f, -7.52204323e-01f}, -}; + const float blackbody_table_g[6][3] = { + {-7.50343014e+02f, 3.15679613e-04f, 4.73464526e-01f}, + {-1.00402363e+03f, 1.29189794e-04f, 9.08181524e-01f}, + {-1.22075471e+03f, 2.56245413e-05f, 1.20753416e+00f}, + {-1.42546105e+03f, -4.01730887e-05f, 1.44002695e+00f}, + {-1.18134453e+03f, -2.18913373e-05f, 1.30656109e+00f}, + {-5.00279505e+02f, -4.59745390e-06f, 1.09090465e+00f}, + }; -ccl_device float3 svm_math_blackbody_color(float t) -{ - /* TODO(lukas): Reimplement in XYZ. */ + const float blackbody_table_b[6][4] = { + {0.0f, 0.0f, 0.0f, 0.0f}, /* zeros should be optimized by compiler */ + {0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 0.0f}, + {-2.02524603e-11f, 1.79435860e-07f, -2.60561875e-04f, -1.41761141e-02f}, + {-2.22463426e-13f, -1.55078698e-08f, 3.81675160e-04f, -7.30646033e-01f}, + {6.72595954e-13f, -2.73059993e-08f, 4.24068546e-04f, -7.52204323e-01f}, + }; if (t >= 12000.0f) { return make_float3(0.826270103f, 0.994478524f, 1.56626022f); diff --git a/intern/cycles/kernel/svm/svm_wavelength.h b/intern/cycles/kernel/svm/svm_wavelength.h index fba8aa63d31..aa291fd2741 100644 --- a/intern/cycles/kernel/svm/svm_wavelength.h +++ b/intern/cycles/kernel/svm/svm_wavelength.h @@ -34,44 +34,44 @@ CCL_NAMESPACE_BEGIN /* Wavelength to RGB */ -// CIE colour matching functions xBar, yBar, and zBar for -// wavelengths from 380 through 780 nanometers, ever
[Bf-blender-cvs] [986d60490c0] master: Asset Browser: Allow World assets to be drag/dropped onto the viewport
Commit: 986d60490c0694941e27c070780c55f07b7b4842 Author: Jesse Yurkovich Date: Mon Sep 27 21:00:17 2021 -0700 Branches: master https://developer.blender.org/rB986d60490c0694941e27c070780c55f07b7b4842 Asset Browser: Allow World assets to be drag/dropped onto the viewport While World data has always been able to be marked as an asset, there was no way to actually use them from the asset browser. This change allows users to drag-drop world assets onto the Viewport and have them appended/linked to their scene. Differential Revision: https://developer.blender.org/D12566 === M source/blender/editors/space_view3d/space_view3d.c M source/blender/editors/space_view3d/view3d_edit.c M source/blender/editors/space_view3d/view3d_intern.h M source/blender/editors/space_view3d/view3d_ops.c === diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 72d0c11e192..4bee9633ece 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -539,6 +539,11 @@ static char *view3d_mat_drop_tooltip(bContext *C, return ED_object_ot_drop_named_material_tooltip(C, drop->ptr, event); } +static bool view3d_world_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) +{ + return view3d_drop_id_in_main_region_poll(C, drag, event, ID_WO); +} + static bool view3d_object_data_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event) { ID_Type id_type = view3d_drop_id_in_main_region_poll_get_id_type(C, drag, event); @@ -732,6 +737,12 @@ static void view3d_dropboxes(void) view3d_id_drop_copy_with_type, WM_drag_free_imported_drag_ID, view3d_object_data_drop_tooltip); + WM_dropbox_add(lb, + "VIEW3D_OT_drop_world", + view3d_world_drop_poll, + view3d_id_drop_copy, + WM_drag_free_imported_drag_ID, + NULL); } static void view3d_widgets(void) @@ -1555,11 +1566,16 @@ static void space_view3d_listener(const wmSpaceTypeListenerParams *params) switch (wmn->category) { case NC_SCENE: switch (wmn->data) { -case ND_WORLD: - if (v3d->flag2 & V3D_HIDE_OVERLAYS) { +case ND_WORLD: { + const bool use_scene_world = ((v3d->shading.type == OB_MATERIAL) && +(v3d->shading.flag & V3D_SHADING_SCENE_WORLD)) || + ((v3d->shading.type == OB_RENDER) && +(v3d->shading.flag & V3D_SHADING_SCENE_WORLD_RENDER)); + if (v3d->flag2 & V3D_HIDE_OVERLAYS || use_scene_world) { ED_area_tag_redraw_regiontype(area, RGN_TYPE_WINDOW); } break; +} } break; case NC_WORLD: diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index d917674194a..15ccf5891d4 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -34,6 +34,7 @@ #include "DNA_gpencil_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_world_types.h" #include "MEM_guardedalloc.h" @@ -4873,6 +4874,59 @@ void VIEW3D_OT_background_image_remove(wmOperatorType *ot) /** \} */ +/* */ +/** \name Drop World Operator + * \{ */ + +static int drop_world_exec(bContext *C, wmOperator *op) +{ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + + char name[MAX_ID_NAME - 2]; + + RNA_string_get(op->ptr, "name", name); + World *world = (World *)BKE_libblock_find_name(bmain, ID_WO, name); + if (world == NULL) { +return OPERATOR_CANCELLED; + } + + id_us_plus(>id); + scene->world = world; + + DEG_id_tag_update(>id, 0); + DEG_relations_tag_update(bmain); + + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, scene); + + return OPERATOR_FINISHED; +} + +static bool drop_world_poll(bContext *C) +{ + return ED_operator_scene_editable(C); +} + +void VIEW3D_OT_drop_world(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Drop World"; + ot->description = "Drop a world into the scene"; + ot->idname = "VIEW3D_OT_drop_world"; + + /* api callbacks */ + ot->exec = drop_world_exec; + ot->poll = drop_world_poll; + + /* flags */ + ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; + + /* properties */ + RNA_def_string(ot->srna, "name", "World", MAX_ID_NAME - 2, "Name", "World to assi
[Bf-blender-cvs] [4fb72170436] master: UDIM: Show the UV grid even when images are loaded
Commit: 4fb7217043627ce952583d99c4b8537e10ee2903 Author: Jesse Yurkovich Date: Fri Sep 3 13:03:28 2021 -0700 Branches: master https://developer.blender.org/rB4fb7217043627ce952583d99c4b8537e10ee2903 UDIM: Show the UV grid even when images are loaded Allow the UDIM grid to be shown and adjusted when there are images loaded in UV edit mode. Right now the grid feature disappears once an image is loaded and many have found this to be confusing. Based on community and artist feedback, there was support to change this behavior[1] This patch does the following: - Allows the grid to be shown even when images are present - The max allowable dimensions for the grid has been increased from 10x10 to 10x100 to match the underlying maximum UDIM range that blender supports Note: This should not affect other Image editor modes like Paint/Mask or the Render Result viewer etc. Future work in this area is currently documented in a dedicated design task[2] [1] https://devtalk.blender.org/t/the-udim-tile-grid-design-and-feedback-thread/20136 [2] https://developer.blender.org/T90913 Differential Revision: https://developer.blender.org/D11860 === M release/scripts/startup/bl_ui/space_image.py M source/blender/draw/CMakeLists.txt M source/blender/draw/engines/overlay/overlay_grid.c M source/blender/draw/engines/overlay/overlay_private.h M source/blender/draw/engines/overlay/overlay_shader.c A source/blender/draw/engines/overlay/shaders/grid_background_frag.glsl M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index dcb0ab2e9e5..3ee66f3 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -1453,7 +1453,7 @@ class IMAGE_PT_udim_grid(Panel): def poll(cls, context): sima = context.space_data -return sima.show_uvedit and sima.image is None +return sima.show_uvedit def draw(self, context): layout = self.layout diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 8bf74dae7f8..71115c5ceb9 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -447,6 +447,7 @@ data_to_c_simple(engines/overlay/shaders/extra_wire_frag.glsl SRC) data_to_c_simple(engines/overlay/shaders/extra_wire_vert.glsl SRC) data_to_c_simple(engines/overlay/shaders/facing_frag.glsl SRC) data_to_c_simple(engines/overlay/shaders/facing_vert.glsl SRC) +data_to_c_simple(engines/overlay/shaders/grid_background_frag.glsl SRC) data_to_c_simple(engines/overlay/shaders/grid_frag.glsl SRC) data_to_c_simple(engines/overlay/shaders/grid_vert.glsl SRC) data_to_c_simple(engines/overlay/shaders/image_vert.glsl SRC) diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.c index 5bb157ed081..60cda9f2d61 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.c +++ b/source/blender/draw/engines/overlay/overlay_grid.c @@ -61,10 +61,19 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) if (pd->space_type == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; -shd->grid_flag = ED_space_image_has_buffer(sima) ? 0 : PLANE_IMAGE | SHOW_GRID; +if (sima->mode == SI_MODE_UV || !ED_space_image_has_buffer(sima)) { + shd->grid_flag = GRID_BACK | PLANE_IMAGE | SHOW_GRID; +} +else { + shd->grid_flag = 0; +} + shd->grid_distance = 1.0f; -copy_v3_fl3( -shd->grid_size, (float)sima->tile_grid_shape[0], (float)sima->tile_grid_shape[1], 1.0f); +copy_v3_fl3(shd->grid_size, 1.0f, 1.0f, 1.0f); +if (sima->mode == SI_MODE_UV) { + shd->grid_size[0] = (float)sima->tile_grid_shape[0]; + shd->grid_size[1] = (float)sima->tile_grid_shape[1]; +} for (int step = 0; step < 8; step++) { shd->grid_steps[step] = powf(4, step) * (1.0f / 16.0f); } @@ -209,11 +218,12 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *vedata) float mat[4][4]; /* add quad background */ -sh = OVERLAY_shader_grid_image(); +sh = OVERLAY_shader_grid_background(); grp = DRW_shgroup_create(sh, psl->grid_ps); float color_back[4]; interp_v4_v4v4(color_back, G_draw.block.colorBackground, G_draw.block.colorGrid, 0.5); DRW_shgroup_uniform_vec4_copy(grp, "color", color_back); +DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", >depth); unit_m4(mat); mat[0][0] = shd->grid_size[0]; mat[1][1] = shd->grid_size[1]; diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index 68f60bee779..23df571e8de 1
[Bf-blender-cvs] [fca6b2780fa] master: Cleanup: clang-format
Commit: fca6b2780fa481a6e5673f9cafc94c8f995d2676 Author: Jesse Yurkovich Date: Thu Aug 19 19:27:49 2021 -0700 Branches: master https://developer.blender.org/rBfca6b2780fa481a6e5673f9cafc94c8f995d2676 Cleanup: clang-format === M source/blender/blenkernel/intern/image_save.c === diff --git a/source/blender/blenkernel/intern/image_save.c b/source/blender/blenkernel/intern/image_save.c index be86da05b57..f93ede517a9 100644 --- a/source/blender/blenkernel/intern/image_save.c +++ b/source/blender/blenkernel/intern/image_save.c @@ -409,7 +409,8 @@ bool BKE_image_save( BKE_reportf(reports, RPT_ERROR, "When saving a tiled image, the path '%s' must contain the UDIM tile number %d", - opts->filepath, first_tile->tile_number); + opts->filepath, + first_tile->tile_number); return false; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [400cb25fc77] master: UDIM: Support tile sets that do not start at 1001
Commit: 400cb25fc77a4131033f69cf328a31cdcf81edb5 Author: Jesse Yurkovich Date: Tue Aug 17 21:42:28 2021 -0700 Branches: master https://developer.blender.org/rB400cb25fc77a4131033f69cf328a31cdcf81edb5 UDIM: Support tile sets that do not start at 1001 Removes the artificial requirement that UDIM tile sets start at 1001. Blender was already capable of handling sparse tile sets (non-contiguous tiles) so the restriction around starting at 1001 was unnecessary in general. This required fixing a few UDIM-related python bugs around manually updating the `tile_number` field on images as well. See the differential for details. No script changes are necessary but they will now work, correctly, in many more cases. Differential Revision: https://developer.blender.org/D11859 === M intern/cycles/blender/blender_util.h M source/blender/blenkernel/BKE_image.h M source/blender/blenkernel/intern/image.c M source/blender/blenkernel/intern/image_gpu.c M source/blender/blenkernel/intern/image_save.c M source/blender/editors/space_image/image_ops.c M source/blender/editors/space_image/image_sequence.c M source/blender/makesrna/intern/rna_image.c === diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 82da3512269..d441575e8af 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -246,7 +246,11 @@ static inline string image_user_file_path(BL::ImageUser , string filepath_str = string(filepath); if (load_tiled && ima.source() == BL::Image::source_TILED) { -string_replace(filepath_str, "1001", ""); +string udim; +if (ima.tiles.length() > 0) { + udim = to_string(ima.tiles[0].number()); +} +string_replace(filepath_str, udim, ""); } return filepath_str; } diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index ac73bd2b595..3cab1a6b755 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -308,6 +308,8 @@ void BKE_image_get_tile_label(struct Image *ima, struct ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *label); bool BKE_image_remove_tile(struct Image *ima, struct ImageTile *tile); +void BKE_image_reassign_tile(struct Image *ima, struct ImageTile *tile, int new_tile_number); +void BKE_image_sort_tiles(struct Image *ima); bool BKE_image_fill_tile(struct Image *ima, struct ImageTile *tile, diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ba54858ba84..d2ab54de697 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -670,24 +670,27 @@ bool BKE_image_has_opengl_texture(Image *ima) return false; } +static int image_get_tile_number_from_iuser(Image *ima, const ImageUser *iuser) +{ + BLI_assert(ima != NULL && ima->tiles.first); + ImageTile *tile = ima->tiles.first; + return (iuser && iuser->tile) ? iuser->tile : tile->tile_number; +} + ImageTile *BKE_image_get_tile(Image *ima, int tile_number) { if (ima == NULL) { return NULL; } - /* Verify valid tile range. */ - if ((tile_number != 0) && (tile_number < 1001 || tile_number > IMA_UDIM_MAX)) { -return NULL; - } - - /* Tile number 0 is a special case and refers to the first tile, typically + /* Tiles 0 and 1001 are a special case and refer to the first tile, typically * coming from non-UDIM-aware code. */ if (ELEM(tile_number, 0, 1001)) { return ima->tiles.first; } - if (ima->source != IMA_SRC_TILED) { + /* Must have a tiled image and a valid tile number at this point. */ + if (ima->source != IMA_SRC_TILED || tile_number < 1001 || tile_number > IMA_UDIM_MAX) { return NULL; } @@ -702,7 +705,7 @@ ImageTile *BKE_image_get_tile(Image *ima, int tile_number) ImageTile *BKE_image_get_tile_from_iuser(Image *ima, const ImageUser *iuser) { - return BKE_image_get_tile(ima, (iuser && iuser->tile) ? iuser->tile : 1001); + return BKE_image_get_tile(ima, image_get_tile_number_from_iuser(ima, iuser)); } int BKE_image_get_tile_from_pos(struct Image *ima, @@ -3803,8 +3806,8 @@ bool BKE_image_remove_tile(struct Image *ima, ImageTile *tile) return false; } - if (tile == ima->tiles.first) { -/* Can't remove first tile. */ + if (BLI_listbase_is_single(>tiles)) { +/* Can't remove the last remaining tile. */ return false; } @@ -3815,6 +3818,64 @@ bool BKE_image_remove_tile(struct Image *ima, ImageTile *tile) return true; } +void BKE_image_reassign_tile(struct Image *ima, ImageTile *tile, int new_tile_number) +{ + if (ima == NUL
[Bf-blender-cvs] [eaa15273852] master: UDIM: Fix tile number calculation when adding a range of image tiles
Commit: eaa152738523bdd2163330fda7ffb1ad62e559cd Author: Jesse Yurkovich Date: Mon Aug 16 21:19:39 2021 -0700 Branches: master https://developer.blender.org/rBeaa152738523bdd2163330fda7ffb1ad62e559cd UDIM: Fix tile number calculation when adding a range of image tiles When adding a range of tiles, the operator could incorrectly calculate the end_tile. It would not account for the start_tile itself and the IMA_UDIM_MAX value was 1 too small. This is most noticeable when attempting to fill the entire supported range of tiles. Differential Revision: https://developer.blender.org/D11857 === M source/blender/blenkernel/BKE_image.h M source/blender/editors/space_image/image_ops.c === diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index d298e5dcf6d..ac73bd2b595 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -45,7 +45,7 @@ struct StampData; struct anim; #define IMA_MAX_SPACE 64 -#define IMA_UDIM_MAX 1999 +#define IMA_UDIM_MAX 2000 void BKE_images_init(void); void BKE_images_exit(void); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 613042a2ab9..999d2956fef 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3922,7 +3922,7 @@ static int tile_add_exec(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); int start_tile = RNA_int_get(op->ptr, "number"); - int end_tile = start_tile + RNA_int_get(op->ptr, "count"); + int end_tile = start_tile + RNA_int_get(op->ptr, "count") - 1; if (start_tile < 1001 || end_tile > IMA_UDIM_MAX) { BKE_report(op->reports, RPT_ERROR, "Invalid UDIM index range was specified"); @@ -3933,7 +3933,7 @@ static int tile_add_exec(bContext *C, wmOperator *op) char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0); bool created_tile = false; - for (int tile_number = start_tile; tile_number < end_tile; tile_number++) { + for (int tile_number = start_tile; tile_number <= end_tile; tile_number++) { ImageTile *tile = BKE_image_add_tile(ima, tile_number, label); if (tile != NULL) { @@ -3949,6 +3949,7 @@ static int tile_add_exec(bContext *C, wmOperator *op) MEM_freeN(label); if (!created_tile) { +BKE_report(op->reports, RPT_WARNING, "No UDIM tiles were created"); return OPERATOR_CANCELLED; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0de54a9cfea] blender-v2.83-release: Fix T89868: Crash showing thumbnail of wide-aspect image
Commit: 0de54a9cfea5a981bfa9fa6ef2fed25a0c0086cc Author: Jesse Yurkovich Date: Sun Jul 18 10:42:52 2021 +1000 Branches: blender-v2.83-release https://developer.blender.org/rB0de54a9cfea5a981bfa9fa6ef2fed25a0c0086cc Fix T89868: Crash showing thumbnail of wide-aspect image Scaling down images could create images with a width or height of zero. Clamp at 1 to prevent a crash, also add an assert to scaling functions. Ref D11956 === M source/blender/editors/render/render_preview.c M source/blender/imbuf/intern/scaling.c === diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 0432057bb47..28cb5ac07a8 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1042,8 +1042,9 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect) scaledy = (float)h; } - ex = (short)scaledx; - ey = (short)scaledy; + /* Scaling down must never assign zero width/height, see: T89868. */ + ex = MAX2(1, (short)scaledx); + ey = MAX2(1, (short)scaledy); dx = (w - ex) / 2; dy = (h - ey) / 2; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 95f720a9d16..bab37f72d79 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1618,6 +1618,8 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy) */ bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert(newx > 0 && newy > 0); + if (ibuf == NULL) { return false; } @@ -1664,6 +1666,8 @@ struct imbufRGBA { */ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert(newx > 0 && newy > 0); + unsigned int *rect, *_newrect, *newrect; struct imbufRGBA *rectf, *_newrectf, *newrectf; int x, y; @@ -1836,6 +1840,8 @@ static void *do_scale_thread(void *data_v) void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert(newx > 0 && newy > 0); + ScaleTreadInitData init_data = {NULL}; /* prepare initialization data */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d097d35be6d] blender-v2.93-release: Fix T89868: Crash showing thumbnail of wide-aspect image
Commit: d097d35be6df2f109839dde4bbc35a31f69faf89 Author: Jesse Yurkovich Date: Sun Jul 18 10:42:52 2021 +1000 Branches: blender-v2.93-release https://developer.blender.org/rBd097d35be6df2f109839dde4bbc35a31f69faf89 Fix T89868: Crash showing thumbnail of wide-aspect image Scaling down images could create images with a width or height of zero. Clamp at 1 to prevent a crash, also add an assert to scaling functions. Ref D11956 === M source/blender/editors/render/render_preview.c M source/blender/imbuf/intern/scaling.c === diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 10e0a143d9b..23b3886ec46 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1254,8 +1254,9 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect) scaledy = (float)h; } - ex = (short)scaledx; - ey = (short)scaledy; + /* Scaling down must never assign zero width/height, see: T89868. */ + ex = MAX2(1, (short)scaledx); + ey = MAX2(1, (short)scaledy); dx = (w - ex) / 2; dy = (h - ey) / 2; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 4a964c64917..72561ef1502 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1620,6 +1620,8 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy) */ bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert(newx > 0 && newy > 0); + if (ibuf == NULL) { return false; } @@ -1666,6 +1668,8 @@ struct imbufRGBA { */ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert(newx > 0 && newy > 0); + unsigned int *rect, *_newrect, *newrect; struct imbufRGBA *rectf, *_newrectf, *newrectf; int x, y; @@ -1838,6 +1842,8 @@ static void *do_scale_thread(void *data_v) void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert(newx > 0 && newy > 0); + ScaleTreadInitData init_data = {NULL}; /* prepare initialization data */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e82c5c66077] master: Fix T89868: Crash showing thumbnail of wide-aspect image
Commit: e82c5c660778b3805f50f3f2901923692c17db2a Author: Jesse Yurkovich Date: Sun Jul 18 10:42:52 2021 +1000 Branches: master https://developer.blender.org/rBe82c5c660778b3805f50f3f2901923692c17db2a Fix T89868: Crash showing thumbnail of wide-aspect image Scaling down images could create images with a width or height of zero. Clamp at 1 to prevent a crash, also add an assert to scaling functions. Ref D11956 === M source/blender/editors/render/render_preview.c M source/blender/imbuf/intern/scaling.c === diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index c7fa2a0ec87..5aa63ac56d8 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1308,8 +1308,9 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect) scaledy = (float)h; } - ex = (short)scaledx; - ey = (short)scaledy; + /* Scaling down must never assign zero width/height, see: T89868. */ + ex = MAX2(1, (short)scaledx); + ey = MAX2(1, (short)scaledy); dx = (w - ex) / 2; dy = (h - ey) / 2; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 757ec5f4b41..79c2583f983 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -1666,6 +1666,8 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy) */ bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!"); + if (ibuf == NULL) { return false; } @@ -1712,6 +1714,8 @@ struct imbufRGBA { */ bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!"); + unsigned int *rect, *_newrect, *newrect; struct imbufRGBA *rectf, *_newrectf, *newrectf; int x, y; @@ -1884,6 +1888,8 @@ static void *do_scale_thread(void *data_v) void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy) { + BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!"); + ScaleTreadInitData init_data = {NULL}; /* prepare initialization data */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [50986783083] master: Cleanup: Use correct _WIN32/64 defines for MSVC
Commit: 5098678308319e9ac2de98928aacffc54c7a9761 Author: Jesse Yurkovich Date: Mon Jul 12 21:01:18 2021 -0700 Branches: master https://developer.blender.org/rB5098678308319e9ac2de98928aacffc54c7a9761 Cleanup: Use correct _WIN32/64 defines for MSVC Docs: https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros Differential Revision: https://developer.blender.org/D11460 === M intern/libmv/libmv/numeric/numeric.h M source/blender/blenlib/intern/path_util.c === diff --git a/intern/libmv/libmv/numeric/numeric.h b/intern/libmv/libmv/numeric/numeric.h index e3d44226338..e3ebdb5a4bb 100644 --- a/intern/libmv/libmv/numeric/numeric.h +++ b/intern/libmv/libmv/numeric/numeric.h @@ -43,7 +43,7 @@ inline void sincos(double x, double* sinx, double* cosx) { # endif #endif // !__MINGW64__ -#if (defined(WIN32) || defined(WIN64)) && !defined(__MINGW32__) +#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) inline long lround(double d) { return (long)(d > 0 ? d + 0.5 : ceil(d - 0.5)); } diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 8969dd4f6b5..4d0dc43ed1e 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1275,7 +1275,7 @@ void BLI_setenv(const char *env, const char *val) { /* free windows */ -#if (defined(WIN32) || defined(WIN64)) +#if (defined(_WIN32) || defined(_WIN64)) uputenv(env, val); #else ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dc679f6247b] master: Cleanup: Use C99 format string for the SIZET_FORMAT macro
Commit: dc679f6247be25f06be14e51a3a1fedf50e6dbbf Author: Jesse Yurkovich Date: Mon Jul 12 20:32:37 2021 -0700 Branches: master https://developer.blender.org/rBdc679f6247be25f06be14e51a3a1fedf50e6dbbf Cleanup: Use C99 format string for the SIZET_FORMAT macro All platforms support the proper format string and it's already used in various other places. Differential Revision: https://developer.blender.org/D11460 === M intern/guardedalloc/intern/mallocn_intern.h === diff --git a/intern/guardedalloc/intern/mallocn_intern.h b/intern/guardedalloc/intern/mallocn_intern.h index aa956150484..e4bd3d533a3 100644 --- a/intern/guardedalloc/intern/mallocn_intern.h +++ b/intern/guardedalloc/intern/mallocn_intern.h @@ -53,14 +53,8 @@ size_t malloc_usable_size(void *ptr); # undef USE_MALLOC_USABLE_SIZE #endif -/* Blame Microsoft for LLP64 and no inttypes.h, quick workaround needed: */ -#if defined(WIN64) -# define SIZET_FORMAT "%I64u" -# define SIZET_ARG(a) ((unsigned long long)(a)) -#else -# define SIZET_FORMAT "%lu" -# define SIZET_ARG(a) ((unsigned long)(a)) -#endif +#define SIZET_FORMAT "%zu" +#define SIZET_ARG(a) ((size_t)(a)) #define SIZET_ALIGN_4(len) ((len + 3) & ~(size_t)3) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs