Commit: 9d04934ed49a349e68488513f74228172cdbfd32 Author: Jeroen Bakker Date: Thu Jan 12 16:03:20 2023 +0100 Branches: temp-T101739-fix-seam-bleeding-non-manifold https://developer.blender.org/rB9d04934ed49a349e68488513f74228172cdbfd32
Fix incorrect bound selection. =================================================================== M source/blender/blenkernel/BKE_pbvh_pixels.hh M source/blender/blenkernel/intern/pbvh_pixels_copy.cc =================================================================== diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh index 06cc75f3bc2..29e94a28835 100644 --- a/source/blender/blenkernel/BKE_pbvh_pixels.hh +++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh @@ -268,6 +268,11 @@ struct PixelCopyItem { char2 delta_source_1; char2 delta_source_2; uint8_t mix_factor; + + PixelCopyItem(char2 delta_source_1, char2 delta_source_2, uint8_t mix_factor) + : delta_source_1(delta_source_1), delta_source_2(delta_source_2), mix_factor(mix_factor) + { + } }; struct PixelCopyGroup { @@ -312,6 +317,13 @@ struct PixelCopyCommand { source_2 = source_1 + int2(item.delta_source_2); mix_factor = float(item.mix_factor) / 255.0f; } + + PixelCopyItem encode_delta(const PixelCopyCommand &next_command) const + { + return PixelCopyItem(char2(next_command.source_1 - source_1), + char2(next_command.source_2 - next_command.source_1), + uint8_t(next_command.mix_factor * 255)); + } }; struct PixelCopyTile { @@ -341,6 +353,13 @@ struct PixelCopyTile { PixelCopyCommand copy_command(group); for (const PixelCopyItem &item : group.items) { copy_command.apply(item); + /* + printf("| %d,%d | %d,%d | %d,%d | %f |\n", + UNPACK2(copy_command.destination), + UNPACK2(copy_command.source_1), + UNPACK2(copy_command.source_2), + copy_command.mix_factor); + */ copy_command.mix_source_and_write_destination<T>(image_buffer); } } diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc index 96887b537fc..0ee8088eb5c 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc @@ -323,8 +323,8 @@ struct Rows { * first_source. */ int2 found_source = first_source; float found_distance = std::numeric_limits<float>().max(); - for (int sy : IndexRange(search_bounds.ymin, BLI_rcti_size_y(&search_bounds))) { - for (int sx : IndexRange(search_bounds.xmin, BLI_rcti_size_x(&search_bounds))) { + for (int sy : IndexRange(search_bounds.ymin, BLI_rcti_size_y(&search_bounds) + 1)) { + for (int sx : IndexRange(search_bounds.xmin, BLI_rcti_size_x(&search_bounds) + 1)) { int2 source(sx, sy); /* Skip first source as it should be the closest and already selected. */ if (source == first_source) { @@ -334,7 +334,7 @@ struct Rows { continue; } - float new_distance = blender::math::distance(destination, source); + float new_distance = blender::math::distance(float2(destination), float2(source)); if (new_distance < found_distance) { found_distance = new_distance; found_source = source; @@ -346,6 +346,9 @@ struct Rows { float determine_mix_factor(int2 destination, int2 source_1, int2 source_2) { + if (source_1 == source_2) { + return 0.0f; + } return dist_to_line_segment_v2(float2(destination), float2(source_1), float2(source_2)); } @@ -413,10 +416,8 @@ struct Rows { static void extend_with(PixelCopyGroup &group, const PixelCopyCommand &command) { PixelCopyCommand last_command = last_copy_command(group); - PixelCopyItem new_item = {char2(command.source_1 - last_command.source_1), - char2(command.source_2 - command.source_1), - uint8_t(command.mix_factor * 255)}; - group.items.append(new_item); + PixelCopyItem delta_command = last_command.encode_delta(command); + group.items.append(delta_command); } static PixelCopyCommand last_copy_command(const PixelCopyGroup &group) _______________________________________________ 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