31 template<
typename Po
int,
typename Vector >
40 const Vector pos1(pt1[0], pt1[1], pt1[2]);
41 const Vector pos2(pt2[0], pt2[1], pt2[2]);
42 const Vector pos3(pt3[0], pt3[1], pt3[2]);
44 const Vector first_edge = pos2 - pos1;
45 const Vector second_edge = pos3 - pos1;
47 Vector first_uv_diff = uv2 - uv1;
48 Vector second_uv_diff = uv3 - uv1;
52 if(std::abs(first_uv_diff[0]) <= 0.01f && std::abs(first_uv_diff[1]) <= 0.01f)
54 const Vector uv2_fix(uv2[0] + 0.0001, uv2[1], uv2[2]);
55 first_uv_diff = uv2_fix - uv1;
58 if(std::abs(second_uv_diff[0]) <= 0.01f &&
59 std::abs(second_uv_diff[1]) <= 0.01f)
61 const Vector uv3_fix(uv3[0], uv3[1] + 0.0001, uv3[2]);
62 second_uv_diff = uv3_fix - uv1;
66 const float inversion_factor = 1.f / (first_uv_diff[0] * second_uv_diff[1] -
67 second_uv_diff[0] * first_uv_diff[1]);
70 (first_edge * second_uv_diff[1] - second_edge * first_uv_diff[1]) *