Commit: 4a4701b43c53d1a4946e224821ba398548b22043 Author: Jeroen Bakker Date: Tue Mar 1 09:32:58 2022 +0100 Branches: blender-v3.1-release https://developer.blender.org/rB4a4701b43c53d1a4946e224821ba398548b22043
Fix painting on none 256 aligned images. Internally the update tiles are 256x256. Due to some miscalculations tiles were not generated correctly if the dimension of the image wasn't a multifold of 256. =================================================================== M source/blender/blenkernel/intern/image_partial_update.cc M source/blender/draw/engines/image/image_drawing_mode.hh =================================================================== diff --git a/source/blender/blenkernel/intern/image_partial_update.cc b/source/blender/blenkernel/intern/image_partial_update.cc index 7e187c2014e..bec3c193af5 100644 --- a/source/blender/blenkernel/intern/image_partial_update.cc +++ b/source/blender/blenkernel/intern/image_partial_update.cc @@ -213,8 +213,8 @@ struct TileChangeset { tile_width = image_buffer->x; tile_height = image_buffer->y; - int chunk_x_len = tile_width / CHUNK_SIZE; - int chunk_y_len = tile_height / CHUNK_SIZE; + int chunk_x_len = (tile_width + CHUNK_SIZE - 1) / CHUNK_SIZE; + int chunk_y_len = (tile_height + CHUNK_SIZE - 1) / CHUNK_SIZE; init_chunks(chunk_x_len, chunk_y_len); return true; } diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh b/source/blender/draw/engines/image/image_drawing_mode.hh index 4564ef87025..267b0477a29 100644 --- a/source/blender/draw/engines/image/image_drawing_mode.hh +++ b/source/blender/draw/engines/image/image_drawing_mode.hh @@ -229,7 +229,21 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD BLI_assert(float_buffer->rect == nullptr); BLI_assert(src->rect_float == nullptr); BLI_assert(src->rect != nullptr); - IMB_float_from_rect_ex(float_buffer, src, &iterator.changed_region.region); + + /* Calculate the overlap between the updated region and the buffer size. Partial Update Checker + * always returns a tile (256x256). Which could lay partially outside the buffer when using + * different resolutions. + */ + rcti buffer_rect; + BLI_rcti_init(&buffer_rect, 0, float_buffer->x, 0, float_buffer->y); + rcti clipped_update_region; + const bool has_overlap = BLI_rcti_isect( + &buffer_rect, &iterator.changed_region.region, &clipped_update_region); + if (!has_overlap) { + return; + } + + IMB_float_from_rect_ex(float_buffer, src, &clipped_update_region); } void do_partial_update(PartialUpdateChecker<ImageTileData>::CollectResult &iterator, _______________________________________________ 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