[Bf-blender-cvs] [8fef9b56317] temp-T101739-fix-seam-bleeding-non-manifold: Renames structs to be more readable.
Jeroen Bakker
noreply at git.blender.org
Fri Jan 13 09:11:59 CET 2023
Commit: 8fef9b56317784e80fce72c9e3a505d8f4f659a0
Author: Jeroen Bakker
Date: Fri Jan 13 08:43:16 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB8fef9b56317784e80fce72c9e3a505d8f4f659a0
Renames structs to be more readable.
===================================================================
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 29e94a28835..0ccb28a6a51 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -244,6 +244,12 @@ struct NodeData {
}
};
+/* -------------------------------------------------------------------- */
+
+/** \name Fix non-manifold edge bleeding.
+ * \{ */
+
+/** TODO: move to image wrappers? */
template<typename T, int Channels = 4> struct ImageBufferAccessor {
ImBuf &image_buffer;
@@ -264,25 +270,25 @@ template<typename T, int Channels = 4> struct ImageBufferAccessor {
}
};
-struct PixelCopyItem {
+struct DeltaCopyPixelCommand {
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)
+ DeltaCopyPixelCommand(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 {
+struct CopyPixelGroup {
int2 destination;
int2 source;
- Vector<PixelCopyItem> items;
+ Vector<DeltaCopyPixelCommand> deltas;
};
/** Pixel copy command to mix 2 source pixels and write to a destination pixel. */
-struct PixelCopyCommand {
+struct CopyPixelCommand {
/** Pixel coordinate to write to. */
int2 destination;
/** Pixel coordinate to read first source from. */
@@ -292,8 +298,8 @@ struct PixelCopyCommand {
/** Factor to mix between first and second source. */
float mix_factor;
- PixelCopyCommand() = default;
- PixelCopyCommand(const PixelCopyGroup &group)
+ CopyPixelCommand() = default;
+ CopyPixelCommand(const CopyPixelGroup &group)
: destination(group.destination),
source_1(group.source),
source_2(group.source),
@@ -310,7 +316,7 @@ struct PixelCopyCommand {
tile_buffer.write_pixel(destination, destination_color);
}
- void apply(const PixelCopyItem &item)
+ void apply(const DeltaCopyPixelCommand &item)
{
destination.x += 1;
source_1 += int2(item.delta_source_1);
@@ -318,19 +324,19 @@ struct PixelCopyCommand {
mix_factor = float(item.mix_factor) / 255.0f;
}
- PixelCopyItem encode_delta(const PixelCopyCommand &next_command) const
+ DeltaCopyPixelCommand encode_delta(const CopyPixelCommand &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));
+ return DeltaCopyPixelCommand(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 {
+struct CopyPixelTile {
image::TileNumber tile_number;
- Vector<PixelCopyGroup> groups;
+ Vector<CopyPixelGroup> groups;
- PixelCopyTile(image::TileNumber tile_number) : tile_number(tile_number)
+ CopyPixelTile(image::TileNumber tile_number) : tile_number(tile_number)
{
}
@@ -349,9 +355,9 @@ struct PixelCopyTile {
private:
template<typename T> void copy_pixels(ImageBufferAccessor<T> &image_buffer) const
{
- for (const PixelCopyGroup &group : groups) {
- PixelCopyCommand copy_command(group);
- for (const PixelCopyItem &item : group.items) {
+ for (const CopyPixelGroup &group : groups) {
+ CopyPixelCommand copy_command(group);
+ for (const DeltaCopyPixelCommand &item : group.deltas) {
copy_command.apply(item);
/*
printf("| %d,%d | %d,%d | %d,%d | %f |\n",
@@ -366,12 +372,12 @@ struct PixelCopyTile {
}
};
-struct PixelCopyTiles {
- Vector<PixelCopyTile> tiles;
+struct CopyPixelTiles {
+ Vector<CopyPixelTile> tiles;
- std::optional<std::reference_wrapper<PixelCopyTile>> find_tile(image::TileNumber tile_number)
+ std::optional<std::reference_wrapper<CopyPixelTile>> find_tile(image::TileNumber tile_number)
{
- for (PixelCopyTile &tile : tiles) {
+ for (CopyPixelTile &tile : tiles) {
if (tile.tile_number == tile_number) {
return tile;
}
@@ -385,12 +391,14 @@ struct PixelCopyTiles {
}
};
+/** \} */
+
struct PBVHData {
/* Per UVPRimitive contains the paint data. */
PaintGeometryPrimitives geom_primitives;
/** Per ImageTile the pixels to copy to fix non-manifold bleeding. */
- PixelCopyTiles tiles_copy_pixels;
+ CopyPixelTiles tiles_copy_pixels;
void clear_data()
{
diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index 0ee8088eb5c..2c3c9aca2cd 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -232,7 +232,7 @@ struct Rows {
struct Pixel {
PixelType type = PixelType::Undecided;
float distance = std::numeric_limits<float>::max();
- PixelCopyCommand copy_command;
+ CopyPixelCommand copy_command;
Pixel() = default;
@@ -397,9 +397,9 @@ struct Rows {
}
}
- static bool can_be_extended_with(const PixelCopyGroup &group, const PixelCopyCommand &command)
+ static bool can_be_extended_with(const CopyPixelGroup &group, const CopyPixelCommand &command)
{
- PixelCopyCommand last_command = last_copy_command(group);
+ CopyPixelCommand last_command = last_copy_command(group);
/* Can only extend when pushing the next pixel. */
if (last_command.destination.x != command.destination.x - 1 ||
last_command.destination.y != command.destination.y) {
@@ -413,28 +413,28 @@ struct Rows {
return true;
}
- static void extend_with(PixelCopyGroup &group, const PixelCopyCommand &command)
+ static void extend_with(CopyPixelGroup &group, const CopyPixelCommand &command)
{
- PixelCopyCommand last_command = last_copy_command(group);
- PixelCopyItem delta_command = last_command.encode_delta(command);
- group.items.append(delta_command);
+ CopyPixelCommand last_command = last_copy_command(group);
+ DeltaCopyPixelCommand delta_command = last_command.encode_delta(command);
+ group.deltas.append(delta_command);
}
- static PixelCopyCommand last_copy_command(const PixelCopyGroup &group)
+ static CopyPixelCommand last_copy_command(const CopyPixelGroup &group)
{
- PixelCopyCommand last_command(group);
- for (const PixelCopyItem &item : group.items) {
+ CopyPixelCommand last_command(group);
+ for (const DeltaCopyPixelCommand &item : group.deltas) {
last_command.apply(item);
}
return last_command;
}
- void pack_into(Vector<PixelCopyGroup> &groups) const
+ void pack_into(Vector<CopyPixelGroup> &groups) const
{
for (const Pixel &elem : pixels) {
if (elem.type == PixelType::CopyFromClosestEdge) {
if (groups.is_empty() || !can_be_extended_with(groups.last(), elem.copy_command)) {
- PixelCopyGroup new_group = {
+ CopyPixelGroup new_group = {
elem.copy_command.destination - int2(1, 0), elem.copy_command.source_1, {}};
groups.append(new_group);
}
@@ -481,7 +481,7 @@ struct Rows {
}
}
- void pack_into(Vector<PixelCopyGroup> &groups) const
+ void pack_into(Vector<CopyPixelGroup> &groups) const
{
for (const Row &row : rows) {
row.pack_into(groups);
@@ -498,7 +498,7 @@ struct Rows {
}; // namespace blender::bke::pbvh::pixels
-static void copy_pixels_reinit(PixelCopyTiles &tiles)
+static void copy_pixels_reinit(CopyPixelTiles &tiles)
{
tiles.clear();
}
@@ -533,7 +533,7 @@ void BKE_pbvh_pixels_copy_update(PBVH &pbvh,
NonManifoldTileEdges tile_edges = non_manifold_edges.extract_tile_edges(image_tile,
tile_resolution);
- PixelCopyTile copy_tile(image_tile.get_tile_number());
+ CopyPixelTile copy_tile(image_tile.get_tile_number());
Rows rows(tile_resolution, image.seam_margin, nodes_tile_pixels);
rows.mark_for_evaluation(tile_edges);
@@ -551,7 +551,7 @@ void BKE_pbvh_pixels_copy_pixels(PBVH &pbvh,
{
// TIMEIT_START(pbvh_pixels_copy_pixels);
PBVHData &pbvh_data = BKE_pbvh_pixels_data_get(pbvh);
- std::optional<std::reference_wrapper<PixelCopyTile>> pixel_tile =
+ std::optional<std::reference_wrapper<CopyPixelTile>> pixel_tile =
pbvh_data.tiles_copy_pixels.find_tile(tile_number);
if (!pixel_tile.has_value()) {
/* No pixels need to be copied. */
More information about the Bf-blender-cvs
mailing list