[Bf-blender-cvs] [67e831af28b] temp-T96710-pbvh-pixels: Remove BarycentricWeights.
Jeroen Bakker
noreply at git.blender.org
Tue Apr 12 12:10:43 CEST 2022
Commit: 67e831af28be44c415a2ba1a851181ff557ae4f6
Author: Jeroen Bakker
Date: Tue Apr 12 08:26:24 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB67e831af28be44c415a2ba1a851181ff557ae4f6
Remove BarycentricWeights.
===================================================================
M source/blender/blenkernel/BKE_pbvh_pixels.hh
M source/blender/blenkernel/intern/pbvh_pixels.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index f5eceb56f2b..237f21bb17d 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -18,55 +18,6 @@
namespace blender::bke::pbvh::pixels {
-/** Barycentric weights. */
-class BarycentricWeights {
- private:
- float3 weights;
-
- public:
- explicit BarycentricWeights() noexcept = default;
- explicit BarycentricWeights(const float2 v1, const float2 v2, const float2 v3, const float2 co)
- {
- barycentric_weights_v2(v1, v2, v3, co, weights);
- }
-
- explicit BarycentricWeights(const float3 weights) : weights(weights)
- {
- }
-
- const bool is_inside_triangle() const
- {
- return barycentric_inside_triangle_v2(weights);
- }
-
- float3 operator-(const BarycentricWeights &rhs) const
- {
- return weights - rhs.weights;
- }
-
- BarycentricWeights operator+(const float3 &rhs) const
- {
- return BarycentricWeights(weights + rhs);
- }
-
- BarycentricWeights &operator-=(const float3 &rhs)
- {
- weights -= rhs;
- return *this;
- }
-
- BarycentricWeights &operator+=(const float3 &rhs)
- {
- weights += rhs;
- return *this;
- }
-
- operator const float *() const
- {
- return weights;
- }
-};
-
/**
* Loop incides. Only stores 2 indices, the third one is always `loop_indices[1] + 1`.
* Second could be delta encoded with the first loop index.
@@ -174,7 +125,7 @@ struct Triangles {
*/
struct PixelsPackage {
/** Barycentric coordinate of the first pixel. */
- BarycentricWeights start_barycentric_coord;
+ float3 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 31216b48d85..1443d30240a 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -59,10 +59,11 @@ static float3 calc_barycentric_delta(const float2 uvs[3],
const float2 end_uv)
{
- const BarycentricWeights start_barycentric(uvs[0], uvs[1], uvs[2], start_uv);
- const BarycentricWeights end_barycentric(uvs[0], uvs[1], uvs[2], end_uv);
- const float3 delta_barycentric = end_barycentric - start_barycentric;
- return delta_barycentric;
+ float3 start_barycentric;
+ 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;
}
static float3 calc_barycentric_delta_x(const ImBuf *image_buffer,
@@ -103,12 +104,14 @@ static void extract_barycentric_pixels(TileData &tile_data,
for (x = minx; x < maxx; x++) {
float2 uv(float(x) / image_buffer->x, float(y) / image_buffer->y);
- const BarycentricWeights barycentric(uvs[0], uvs[1], uvs[2], uv);
- const bool is_inside = barycentric.is_inside_triangle();
+ float3 barycentric_weights;
+ barycentric_weights_v2(uvs[0], uvs[1], uvs[2], uv, barycentric_weights);
+
+ const bool is_inside = barycentric_inside_triangle_v2(barycentric_weights);
if (!start_detected && is_inside) {
start_detected = true;
package.start_image_coordinate = ushort2(x, y);
- package.start_barycentric_coord = barycentric;
+ package.start_barycentric_coord = barycentric_weights;
}
else if (start_detected && !is_inside) {
break;
More information about the Bf-blender-cvs
mailing list