Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2022-04-15 13:00:02 +0300
committerJeroen Bakker <jeroen@blender.org>2022-04-15 13:00:02 +0300
commit9852c6cf631567782d3ea018bfe5097accefb3d0 (patch)
tree94f1f2e9ca19499d4d7ea49b8d20cde205afe504
parentc627d7ede2543f9ac2c9c32c83c7cf8ddd7f2460 (diff)
Only store 2 components of barycentric coordinates.temp-T96710-pbvh-pixels
-rw-r--r--source/blender/blenkernel/BKE_pbvh_pixels.hh12
-rw-r--r--source/blender/blenkernel/intern/pbvh_pixels.cc20
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_paint_image.cc7
3 files changed, 14 insertions, 25 deletions
diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index dbfc03dd12a..35eb340d0a1 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -25,20 +25,16 @@ struct TrianglePaintInput {
*
* Only the first two coordinates are stored. The third should be recalculated
*/
- float3 delta_barycentric_coord_u;
- /** Delta barycentric coordinates between 2 neighbouring UV's in the V direction. */
- float3 delta_barycentric_coord_v;
+ float2 delta_barycentric_coord_u;
/**
* Initially only the vert indices are known.
*
- * delta_barycentric_coord_u/v are initialized in a later stage as it requires image tile
+ * delta_barycentric_coord_u is initialized in a later stage as it requires image tile
* dimensions.
*/
TrianglePaintInput(const int3 vert_indices)
- : vert_indices(vert_indices),
- delta_barycentric_coord_u(0.0f, 0.0f, 0.0f),
- delta_barycentric_coord_v(0.0f, 0.0f, 0.0f)
+ : vert_indices(vert_indices), delta_barycentric_coord_u(0.0f, 0.0f)
{
}
};
@@ -90,7 +86,7 @@ struct Triangles {
*/
struct PackedPixelRow {
/** Barycentric coordinate of the first pixel. */
- float3 start_barycentric_coord;
+ float2 start_barycentric_coord;
/** Image coordinate starting of the first pixel. */
ushort2 start_image_coordinate;
/** Number of sequential pixels encoded in this package. */
diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 07da012f619..d8dd2f4b382 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -29,7 +29,7 @@ constexpr bool USE_WATERTIGHT_CHECK = false;
/**
* Calculate the delta of two neighbour uv coordinates in the given image buffer.
*/
-static float3 calc_barycentric_delta(const float2 uvs[3],
+static float2 calc_barycentric_delta(const float2 uvs[3],
const float2 start_uv,
const float2 end_uv)
{
@@ -38,10 +38,11 @@ static float3 calc_barycentric_delta(const float2 uvs[3],
barycentric_weights_v2(uvs[0], uvs[1], uvs[2], start_uv, start_barycentric);
float3 end_barycentric;
barycentric_weights_v2(uvs[0], uvs[1], uvs[2], end_uv, end_barycentric);
- return end_barycentric - start_barycentric;
+ float3 barycentric = end_barycentric - start_barycentric;
+ return float2(barycentric.x, barycentric.y);
}
-static float3 calc_barycentric_delta_x(const ImBuf *image_buffer,
+static float2 calc_barycentric_delta_x(const ImBuf *image_buffer,
const float2 uvs[3],
const int x,
const int y)
@@ -51,16 +52,6 @@ static float3 calc_barycentric_delta_x(const ImBuf *image_buffer,
return calc_barycentric_delta(uvs, start_uv, end_uv);
}
-static float3 calc_barycentric_delta_y(const ImBuf *image_buffer,
- const float2 uvs[3],
- const int x,
- const int y)
-{
- const float2 start_uv(float(x) / image_buffer->x, float(y) / image_buffer->y);
- const float2 end_uv(float(x) / image_buffer->x, float(y + 1) / image_buffer->y);
- return calc_barycentric_delta(uvs, start_uv, end_uv);
-}
-
static void extract_barycentric_pixels(UDIMTilePixels &tile_data,
const ImBuf *image_buffer,
const int triangle_index,
@@ -86,7 +77,7 @@ static void extract_barycentric_pixels(UDIMTilePixels &tile_data,
if (!start_detected && is_inside) {
start_detected = true;
pixel_row.start_image_coordinate = ushort2(x, y);
- pixel_row.start_barycentric_coord = barycentric_weights;
+ pixel_row.start_barycentric_coord = float2(barycentric_weights.x, barycentric_weights.y);
}
else if (start_detected && !is_inside) {
break;
@@ -159,7 +150,6 @@ static void do_encode_pixels(void *__restrict userdata,
TrianglePaintInput &triangle = triangles.get_paint_input(triangle_index);
triangle.delta_barycentric_coord_u = calc_barycentric_delta_x(image_buffer, uvs, minx, miny);
- triangle.delta_barycentric_coord_v = calc_barycentric_delta_y(image_buffer, uvs, minx, miny);
extract_barycentric_pixels(
tile_data, image_buffer, triangle_index, uvs, minx, miny, maxx, maxy);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index da8758b1f20..082ff6260c2 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -247,15 +247,18 @@ template<typename ImageBuffer> class PaintingKernel {
}
float3 init_pixel_pos(const TrianglePaintInput &triangle,
- const float3 &barycentric_weights) const
+ const float2 &barycentric_weights) const
{
const int3 &vert_indices = triangle.vert_indices;
float3 result;
+ const float3 barycentric(barycentric_weights.x,
+ barycentric_weights.y,
+ 1.0f - barycentric_weights.x - barycentric_weights.y);
interp_v3_v3v3v3(result,
mvert[vert_indices[0]].co,
mvert[vert_indices[1]].co,
mvert[vert_indices[2]].co,
- barycentric_weights);
+ barycentric);
return result;
}
};