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 /source/blender/blenkernel/intern
parentc627d7ede2543f9ac2c9c32c83c7cf8ddd7f2460 (diff)
Only store 2 components of barycentric coordinates.temp-T96710-pbvh-pixels
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/pbvh_pixels.cc20
1 files changed, 5 insertions, 15 deletions
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);
}