Simplify barycentric coordinates function

This commit is contained in:
Abdelrahman Said 2024-08-26 18:01:55 +01:00
parent c66b4e4870
commit a144f8ad1e

@ -193,15 +193,10 @@ internal TriangleBBox get_triangle_bbox(const Image *img,
}
internal V3f get_barycentric_coords(V3f a, V3f b, V3f c, V3f p) {
V3f s[2];
V3f x_vec = V3(V3f, f32, c.x, b.x, a.x, a.x, a.x, p.x);
V3f y_vec = V3(V3f, f32, c.y, b.y, a.y, a.y, a.y, p.y);
for (u64 i = 0; i < 2; ++i) {
s[i].x = c.elements[i] - a.elements[i];
s[i].y = b.elements[i] - a.elements[i];
s[i].z = a.elements[i] - p.elements[i];
}
V3f u = cross_product(s[0], s[1]);
V3f u = cross_product(x_vec, y_vec);
if (fabsf(u.z) < 1e-2) {
return (V3f){-1.0f, 1.0f, 1.0f};
}