Fix barycentric coordinates calculation #2

Merged
abdelrahman merged 8 commits from debug-barycentric into main 2024-08-26 17:12:45 +00:00
Showing only changes of commit a144f8ad1e - Show all commits

View File

@ -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};
}