30void cross_tri_v3(
float n[3],
const float v1[3],
const float v2[3],
const float v3[3])
34 n1[0] = v1[0] -
v2[0];
35 n2[0] =
v2[0] - v3[0];
36 n1[1] = v1[1] -
v2[1];
37 n2[1] =
v2[1] - v3[1];
38 n1[2] = v1[2] -
v2[2];
39 n2[2] =
v2[2] - v3[2];
40 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
41 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
42 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
45float normal_tri_v3(
float n[3],
const float v1[3],
const float v2[3],
const float v3[3])
49 n1[0] = v1[0] -
v2[0];
50 n2[0] =
v2[0] - v3[0];
51 n1[1] = v1[1] -
v2[1];
52 n2[1] =
v2[1] - v3[1];
53 n1[2] = v1[2] -
v2[2];
54 n2[2] =
v2[2] - v3[2];
55 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
56 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
57 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
63 float n[3],
const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
68 n1[0] = v1[0] - v3[0];
69 n1[1] = v1[1] - v3[1];
70 n1[2] = v1[2] - v3[2];
72 n2[0] =
v2[0] - v4[0];
73 n2[1] =
v2[1] - v4[1];
74 n2[2] =
v2[2] - v4[2];
76 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
77 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
78 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
89float area_quad_v3(
const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
122 const float normal[3])
157 const float *co_curr, *co_prev;
160 co_prev = verts[nr - 1];
163 for (a = 0; a < nr; a++) {
164 cross += (co_prev[0] - co_curr[0]) * (co_curr[1] + co_prev[1]);
174 const float *v_prev = verts[nr - 1];
175 const float *v_curr = verts[0];
181 for (i = 0; i < nr; v_prev = v_curr, v_curr = verts[++i]) {
204 float a[3],
b[3], c[3], c_len;
228 r_plane[3] = -
dot_v3v3(r_plane, plane_co);
279 float tetra_volume =
dot_v3v3(v_cross, v3);
322 float r_closest_b[2],
331 float intersection[2];
342 float p1[2], p2[2], p3[2], p4[2];
352 const float min_dist_sq = std::min({dist_sq1, dist_sq2, dist_sq3, dist_sq4});
353 if (min_dist_sq == dist_sq1) {
357 *r_lambda_b = lambda1;
359 else if (min_dist_sq == dist_sq2) {
363 *r_lambda_b = lambda2;
365 else if (min_dist_sq == dist_sq3) {
368 *r_lambda_a = lambda3;
375 *r_lambda_a = lambda4;
391 if (lambda <= 0.0f) {
395 if (lambda >= 1.0f) {
413 if (lambda <= 0.0f) {
417 if (lambda >= 1.0f) {
426 const float ray_direction[3],
437 if (lambda <= 0.0f) {
442 if (lambda >= 1.0f) {
468 const float side =
dot_v3v3(plane, pt);
474 const float side =
dot_v3v3(plane, pt);
483 const float fac = side / len_sq;
484 return copysignf(len_sq * (fac * fac), side);
490 const float fac = side / len_sq;
492 return len_sq * (fac * fac);
498 const float side =
dot_v3v3(plane, p);
499 const float fac = side / len_sq;
500 return copysignf(len_sq * (fac * fac), side);
505 const float side =
dot_v3v3(plane, p);
506 const float fac = side / len_sq;
508 return len_sq * (fac * fac);
515 const float fac = side / len_sq;
516 return sqrtf(len_sq) * fac;
526 const float side =
dot_v3v3(plane, p);
527 const float fac = side / len_sq;
528 return sqrtf(len_sq) * fac;
566 const float axis_ref[3])
568 float dir_a[3], dir_b[3];
569 float plane_a[3], plane_b[3];
570 float dist_a, dist_b;
583 else if (
dot_v3v3(axis, axis_ref) < 0.0f) {
607 return min_ff(dist_a, dist_b);
610 return max_ff(dist_a, dist_b);
614 const float ray_direction[3],
617 float origin_to_co[3];
620 float origin_to_proj[3];
623 float co_projected_on_ray[3];
624 add_v3_v3v3(co_projected_on_ray, ray_origin, origin_to_proj);
630 const float ray_direction[3],
638 if (lambda <= 0.0f) {
641 else if (lambda >= 1.0f) {
656 depth =
dot_v3v3(dvec, ray_direction);
666 const float bbmin[3],
667 const float bbmax[3],
671 if (plane_no[0] < 0.0f) {
672 bb_near[0] = bbmax[0];
673 bb_afar[0] = bbmin[0];
676 bb_near[0] = bbmin[0];
677 bb_afar[0] = bbmax[0];
679 if (plane_no[1] < 0.0f) {
680 bb_near[1] = bbmax[1];
681 bb_afar[1] = bbmin[1];
684 bb_near[1] = bbmin[1];
685 bb_afar[1] = bbmax[1];
687 if (plane_no[2] < 0.0f) {
688 bb_near[2] = bbmax[2];
689 bb_afar[2] = bbmin[2];
692 bb_near[2] = bbmin[2];
693 bb_afar[2] = bbmax[2];
704 const float ray_direction[3])
710 for (
int i = 0; i < 3; i++) {
715 return nearest_precalc;
719 const float bb_min[3],
720 const float bb_max[3],
725 float local_bvmin[3], local_bvmax[3];
730 const float tmin[3] = {
731 (local_bvmin[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
732 (local_bvmin[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
733 (local_bvmin[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
735 const float tmax[3] = {
736 (local_bvmax[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
737 (local_bvmax[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
738 (local_bvmax[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
747 if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
749 va[0] = vb[0] = local_bvmax[0];
753 else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
755 va[1] = vb[1] = local_bvmax[1];
761 va[2] = vb[2] = local_bvmax[2];
767 if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
769 va[0] = vb[0] = local_bvmin[0];
773 else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
775 va[1] = vb[1] = local_bvmin[1];
781 va[2] = vb[2] = local_bvmin[2];
792 if (rtmin <= rtmax) {
802 if (
data->ray_direction[main_axis] >= 0.0f) {
803 va[main_axis] = local_bvmin[main_axis];
804 vb[main_axis] = local_bvmax[main_axis];
807 va[main_axis] = local_bvmax[main_axis];
808 vb[main_axis] = local_bvmin[main_axis];
812 data->ray_origin,
data->ray_direction, va, vb, r_point, r_depth);
816 const float ray_direction[3],
817 const float bb_min[3],
818 const float bb_max[3],
833 const float projmat[4][4],
834 const float winsize[2],
837 float win_half[2], relative_mval[2], px[4], py[4];
842 relative_mval[0] = precalc->
mval[0] / win_half[0];
843 relative_mval[1] = precalc->
mval[1] / win_half[1];
846 for (
int i = 0; i < 4; i++) {
847 px[i] = precalc->
pmat[i][0] - precalc->
pmat[i][3] * relative_mval[0];
848 py[i] = precalc->
pmat[i][1] - precalc->
pmat[i][3] * relative_mval[1];
850 precalc->
pmat[i][0] *= win_half[0];
851 precalc->
pmat[i][1] *= win_half[1];
854 float projmat_trans[4][4];
857 projmat_trans[0], projmat_trans[1], projmat_trans[3], precalc->
ray_origin))
877 for (
int i = 0; i < 3; i++) {
885 const float bbmin[3],
886 const float bbmax[3],
887 bool r_axis_closest[3])
889 float local_bvmin[3], local_bvmax[3];
892 const float tmin[3] = {
893 (local_bvmin[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
894 (local_bvmin[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
895 (local_bvmin[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
897 const float tmax[3] = {
898 (local_bvmax[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
899 (local_bvmax[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
900 (local_bvmax[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
908 r_axis_closest[0] =
false;
909 r_axis_closest[1] =
false;
910 r_axis_closest[2] =
false;
912 if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
914 va[0] = vb[0] = local_bvmax[0];
916 r_axis_closest[0] =
data->ray_direction[0] < 0.0f;
918 else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
920 va[1] = vb[1] = local_bvmax[1];
922 r_axis_closest[1] =
data->ray_direction[1] < 0.0f;
926 va[2] = vb[2] = local_bvmax[2];
928 r_axis_closest[2] =
data->ray_direction[2] < 0.0f;
931 if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
933 va[0] = vb[0] = local_bvmin[0];
935 r_axis_closest[0] =
data->ray_direction[0] >= 0.0f;
937 else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
939 va[1] = vb[1] = local_bvmin[1];
941 r_axis_closest[1] =
data->ray_direction[1] >= 0.0f;
945 va[2] = vb[2] = local_bvmin[2];
947 r_axis_closest[2] =
data->ray_direction[2] >= 0.0f;
954 if (rtmin <= rtmax) {
958 if (
data->ray_direction[main_axis] >= 0.0f) {
959 va[main_axis] = local_bvmin[main_axis];
960 vb[main_axis] = local_bvmax[main_axis];
963 va[main_axis] = local_bvmax[main_axis];
964 vb[main_axis] = local_bvmin[main_axis];
966 float scale =
fabsf(local_bvmax[main_axis] - local_bvmin[main_axis]);
973 (va2d[0] +
data->pmat[main_axis][0] *
scale),
974 (va2d[1] +
data->pmat[main_axis][1] *
scale),
980 float w_b = w_a +
data->pmat[main_axis][3] *
scale;
987 float dvec[2], edge[2], lambda, rdist_sq;
991 if (lambda != 0.0f) {
993 if (lambda <= 0.0f) {
995 r_axis_closest[main_axis] =
true;
997 else if (lambda >= 1.0f) {
999 r_axis_closest[main_axis] =
false;
1004 r_axis_closest[main_axis] = lambda < 0.5f;
1015 const float winsize[2],
1016 const float mval[2],
1017 const float bbmin[3],
1018 const float bbmax[3])
1023 bool dummy[3] = {
true,
true,
true};
1033float dist_seg_seg_v2(
const float a1[3],
const float a2[3],
const float b1[3],
const float b2[3])
1042 return sqrtf(std::min({d1, d2, d3, d4}));
1055 float ab[3], ac[3], ap[3], d1, d2;
1056 float bp[3], d3, d4, vc, cp[3], d5, d6, vb, va;
1065 if (d1 <= 0.0f && d2 <= 0.0f) {
1077 if (d3 >= 0.0f && d4 <= d3) {
1085 vc = d1 * d4 - d3 * d2;
1086 if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
1087 const float ab_squared = d1 - d3;
1088 if (ab_squared == 0.0f) {
1095 v = d1 / ab_squared;
1096 r_bary[0] = 1.0f -
v;
1107 if (d6 >= 0.0f && d5 <= d6) {
1115 vb = d5 * d2 - d1 * d6;
1116 if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
1117 const float ac_squared = d2 - d6;
1118 if (ac_squared == 0.0f) {
1125 w = d2 / ac_squared;
1126 r_bary[0] = 1.0f -
w;
1134 va = d3 * d6 - d5 * d4;
1135 if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
1136 const float bc_squared = (d4 - d3) + (d5 - d6);
1137 if (bc_squared == 0.0f) {
1144 w = (d4 - d3) / bc_squared;
1146 r_bary[1] = 1.0f -
w;
1157 denom = 1.0f / (va + vb + vc);
1163 r_bary[0] = 1.0f -
v -
w;
1175 float r[3],
const float p[3],
const float v1[3],
const float v2[3],
const float v3[3])
1177 float bary_dummy[3];
1189 float div, lambda, mu;
1191 div =
float((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
1196 lambda =
float((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1198 mu =
float((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1200 if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
1201 if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
1210 const float v0[2],
const float v1[2],
const float v2[2],
const float v3[2],
float r_vi[2])
1212 float s10[2], s32[2];
1223 r_vi[0] = ((s32[0] * u) - (s10[0] *
v)) / div;
1224 r_vi[1] = ((s32[1] * u) - (s10[1] *
v)) / div;
1234 float div, lambda, mu;
1236 div = (
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]);
1241 lambda = (
float(v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1243 mu = (
float(v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1245 if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
1246 if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
1262 float a_dir[3], b_dir[3], a0b0[3], crs_ab[3];
1273 float a0b1[3], a1b0[3], len_a, len_b, fac1, fac2;
1282 CLAMP(fac1, 0.0f, len_a);
1283 CLAMP(fac2, 0.0f, len_a);
1284 fac_a = (fac1 + fac2) / (2 * len_a);
1293 CLAMP(fac1, 0.0f, len_b);
1294 CLAMP(fac2, 0.0f, len_b);
1295 fac_b = (fac1 + fac2) / (2 * len_b);
1302 float c[3], cray[3];
1306 fac_a =
dot_v3v3(cray, crs_ab) / nlen;
1309 fac_b =
dot_v3v3(cray, crs_ab) / nlen;
1311 CLAMP(fac_a, 0.0f, 1.0f);
1312 CLAMP(fac_b, 0.0f, 1.0f);
1323 const float endpoint_bias,
1326 float s10[2], s32[2], s30[2], d;
1327 const float eps = 1e-6f;
1328 const float endpoint_min = -endpoint_bias;
1329 const float endpoint_max = endpoint_bias + 1.0f;
1343 if ((u >= endpoint_min && u <= endpoint_max) && (
v >= endpoint_min &&
v <= endpoint_max)) {
1361 if (
v >= endpoint_min &&
v <= endpoint_max) {
1402 std::swap(u_a, u_b);
1405 if (u_a > endpoint_max || u_b < endpoint_min) {
1421 const float v0[2],
const float v1[2],
const float v2[2],
const float v3[2],
float r_vi[2])
1423 const float endpoint_bias = 1e-6f;
1432#define CCW(A, B, C) ((C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0]))
1446 double div, lambda, mu;
1448 div = (
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]);
1449 if (
fabs(div) < DBL_EPSILON) {
1453 lambda = ((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1455 mu = ((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1464 if (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0) {
1465 if (lambda == 0.0 || lambda == 1.0 || mu == 0.0 || mu == 1.0) {
1489 const float ldir[3] = {
1497 const float b = 2.0f * (ldir[0] * (l1[0] - sp[0]) + ldir[1] * (l1[1] - sp[1]) +
1498 ldir[2] * (l1[2] - sp[2]));
1502 const float i =
b *
b - 4.0f * a * c;
1512 mu = -
b / (2.0f * a);
1517 const float i_sqrt =
sqrtf(i);
1520 mu = (-
b + i_sqrt) / (2.0f * a);
1524 mu = (-
b - i_sqrt) / (2.0f * a);
1542 const float ldir[2] = {l2[0] - l1[0], l2[1] - l1[1]};
1544 const float a =
dot_v2v2(ldir, ldir);
1546 const float b = 2.0f * (ldir[0] * (l1[0] - sp[0]) + ldir[1] * (l1[1] - sp[1]));
1550 const float i =
b *
b - 4.0f * a * c;
1560 mu = -
b / (2.0f * a);
1565 const float i_sqrt =
sqrtf(i);
1568 mu = (-
b + i_sqrt) / (2.0f * a);
1572 mu = (-
b - i_sqrt) / (2.0f * a);
1587 for (i = 0, j = nr - 1; i < nr; j = i++) {
1588 if (((verts[i][1] > pt[1]) != (verts[j][1] > pt[1])) &&
1590 (verts[j][0] - verts[i][0]) * (pt[1] - verts[i][1]) / (verts[j][1] - verts[i][1]) +
1604 for (i = 0, j = nr - 1; i < nr; j = i++) {
1605 if (((verts[i][1] > pt[1]) != (verts[j][1] > pt[1])) &&
1607 (verts[j][0] - verts[i][0]) * (pt[1] - verts[i][1]) / (verts[j][1] - verts[i][1]) +
1639 if (side12 >= 0.0f && side23 >= 0.0f && side31 >= 0.0f) {
1642 if (side12 <= 0.0f && side23 <= 0.0f && side31 <= 0.0f) {
1650 const float p[2],
const float v1[2],
const float v2[2],
const float v3[2],
const float v4[2])
1656 if (side12 >= 0.0f && side23 >= 0.0f && side34 >= 0.0f && side41 >= 0.0f) {
1659 if (side12 <= 0.0f && side23 <= 0.0f && side34 <= 0.0f && side41 <= 0.0f) {
1674 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1691 if ((u < 0.0f) || (u > 1.0f)) {
1698 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1703 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
1723 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1740 if ((u < 0.0f) || (u > 1.0f)) {
1747 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1768 const float epsilon)
1771 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1788 if ((u < -epsilon) || (u > 1.0f + epsilon)) {
1795 if ((
v < -epsilon) || ((u +
v) > 1.0f + epsilon)) {
1800 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
1813 const float ray_direction[3],
1822 const float epsilon = 0.00000001f;
1823 float p[3], s[3], e1[3], e2[3], q[3];
1831 if ((a > -epsilon) && (a < epsilon)) {
1839 if ((u < 0.0f) || (u > 1.0f)) {
1846 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1851 if (*r_lambda < 0.0f) {
1864 const float ray_direction[3],
1865 const float plane_co[3],
1866 const float plane_no[3],
1880 const float ray_direction[3],
1881 const float plane[4],
1885 float plane_co[3], plane_no[3];
1890 if (clip && (*r_lambda < 0.0f)) {
1897 const float ray_direction[3],
1903 const float epsilon)
1905 float p[3], s[3], e1[3], e2[3], q[3];
1921 if ((u < -epsilon) || (u > 1.0f + epsilon)) {
1928 if ((
v < -epsilon) || ((u +
v) > 1.0f + epsilon)) {
1933 if (*r_lambda < 0.0f) {
1946 const float ray_direction[3])
1952 int kx = (kz != 2) ? (kz + 1) : 0;
1953 int ky = (kx != 2) ? (kx + 1) : 0;
1956 if (ray_direction[kz] < 0.0f) {
1961 inv_dir_z = 1.0f / ray_direction[kz];
1962 isect_precalc->
sx = ray_direction[kx] * inv_dir_z;
1963 isect_precalc->
sy = ray_direction[ky] * inv_dir_z;
1964 isect_precalc->
sz = inv_dir_z;
1967 isect_precalc->
kx = kx;
1968 isect_precalc->
ky = ky;
1969 isect_precalc->
kz = kz;
1980 const int kx = isect_precalc->
kx;
1981 const int ky = isect_precalc->
ky;
1982 const int kz = isect_precalc->
kz;
1983 const float sx = isect_precalc->
sx;
1984 const float sy = isect_precalc->
sy;
1985 const float sz = isect_precalc->
sz;
1988 const float a[3] = {v0[0] - ray_origin[0], v0[1] - ray_origin[1], v0[2] - ray_origin[2]};
1989 const float b[3] = {v1[0] - ray_origin[0], v1[1] - ray_origin[1], v1[2] - ray_origin[2]};
1990 const float c[3] = {
v2[0] - ray_origin[0],
v2[1] - ray_origin[1],
v2[2] - ray_origin[2]};
1992 const float a_kx = a[kx], a_ky = a[ky], a_kz = a[kz];
1993 const float b_kx =
b[kx], b_ky =
b[ky], b_kz =
b[kz];
1994 const float c_kx = c[kx], c_ky = c[ky], c_kz = c[kz];
1997 const float ax = a_kx - sx * a_kz;
1998 const float ay = a_ky - sy * a_kz;
1999 const float bx = b_kx - sx * b_kz;
2000 const float by = b_ky - sy * b_kz;
2001 const float cx = c_kx - sx * c_kz;
2002 const float cy = c_ky - sy * c_kz;
2005 const float u = cx * by - cy * bx;
2006 const float v = ax * cy - ay * cx;
2007 const float w = bx * ay - by * ax;
2010 if ((u < 0.0f ||
v < 0.0f ||
w < 0.0f) && (u > 0.0f ||
v > 0.0f ||
w > 0.0f)) {
2016 if (det == 0.0f || !isfinite(det)) [[unlikely]] {
2023 const int sign_det = (
float_as_int(det) & int(0x80000000));
2024 const float t = (u * a_kz +
v * b_kz +
w * c_kz) * sz;
2025 const float sign_t =
xor_fl(t, sign_det);
2031 || (sign_T > *r_lambda * xor_signmask(det, sign_mask))
2039 const float inv_det = 1.0f / det;
2041 r_uv[0] = u * inv_det;
2042 r_uv[1] =
v * inv_det;
2044 *r_lambda = t * inv_det;
2049 const float ray_direction[3],
2067 const float ray_direction[3],
2073 const float threshold)
2075 const float epsilon = 0.00000001f;
2076 float p[3], s[3], e1[3], e2[3], q[3];
2085 if ((a > -epsilon) && (a < epsilon)) {
2094 if (*r_lambda < 0.0f) {
2101 if (u > 0 &&
v > 0 && u +
v > 1) {
2102 float t = (u +
v - 1) / 2;
2145 const float ray_direction[2],
2151 float v0_local[2], v1_local[2];
2163 const float p[2] = {(ray_direction[0] *
v) / det, (ray_direction[1] *
v) / det};
2165 const float t = (
dot_v2v2(p, ray_direction) /
dot_v2v2(ray_direction, ray_direction));
2166 if ((t >= 0.0f) == 0) {
2173 if ((u >= 0.0f && u <= 1.0f) == 0) {
2191 const float ray_direction[3],
2196 float a[3], t[3], n[3];
2215 float c[3], cray[3];
2219 *r_lambda =
dot_v3v3(cray, n) / nlen;
2228 for (i = 0; i < totplane; i++) {
2239 for (
int i = 0; i < totplane; i++) {
2251 const float plane_co[3],
2252 const float plane_no[3])
2272 const float plane_b[4],
2273 const float plane_c[4],
2274 float r_isect_co[3])
2305 const float plane_b[4],
2306 float r_isect_co[3],
2307 float r_isect_no[3])
2309 float det, plane_c[3];
2339 const float planes[][4],
2340 const int planes_len,
2341 const float eps_coplanar,
2342 const float eps_isect,
2343 void (*callback_fn)(
const float co[3],
int i,
int j,
int k,
void *user_data),
2348 float n1n2[3], n2n3[3], n3n1[3];
2350 for (
int i = 0; i < planes_len; i++) {
2351 const float *n1 = planes[i];
2352 for (
int j = i + 1; j < planes_len; j++) {
2353 const float *n2 = planes[j];
2358 for (
int k = j + 1; k < planes_len; k++) {
2359 const float *n3 = planes[k];
2369 const float quotient = -
dot_v3v3(n1, n2n3);
2370 if (
fabsf(quotient) < eps_coplanar) {
2373 const float co_test[3] = {
2374 ((n2n3[0] * n1[3]) + (n3n1[0] * n2[3]) + (n1n2[0] * n3[3])) / quotient,
2375 ((n2n3[1] * n1[3]) + (n3n1[1] * n2[3]) + (n1n2[1] * n3[3])) / quotient,
2376 ((n2n3[2] * n1[3]) + (n3n1[2] * n2[3]) + (n1n2[2] * n3[3])) / quotient,
2379 for (i_test = 0; i_test < planes_len; i_test++) {
2380 const float *np_test = planes[i_test];
2381 if ((
dot_v3v3(np_test, co_test) + np_test[3]) > eps_isect) {
2383 if (!
ELEM(i_test, i, j, k)) {
2389 if (i_test == planes_len) {
2390 callback_fn(co_test, i, j, k, user_data);
2401 const float tri_b[3][3],
2404 int *r_tri_a_edge_isect_count)
2415 double ba[3], bc[3], plane_a[4], plane_b[4];
2416 *r_tri_a_edge_isect_count = 0;
2426 if (!side[1][0] && !side[1][1] && !side[1][2]) {
2431 if ((side[1][0] && side[1][1] && side[1][2]) && (side[1][0] < 0.0f) == (side[1][1] < 0.0f) &&
2432 (side[1][0] < 0.0f) == (side[1][2] < 0.0f))
2447 if ((side[0][0] && side[0][1] && side[0][2]) && (side[0][0] < 0.0f) == (side[0][1] < 0.0f) &&
2448 (side[0][0] < 0.0f) == (side[0][2] < 0.0f))
2456 double isect_dir[3];
2458 for (
int i = 0; i < 2; i++) {
2459 const float (*tri)[3] = i == 0 ? tri_a : tri_b;
2463 if ((side[i][0] && side[i][1]) && (side[i][0] < 0.0f) == (side[i][1] < 0.0f)) {
2468 else if ((side[i][1] && side[i][2]) && (side[i][1] < 0.0f) == (side[i][2] < 0.0f)) {
2480 float sidec = side[i][tri_i[1]];
2484 float fac0 = sidec / (sidec - side[i][tri_i[0]]);
2485 float fac1 = sidec / (sidec - side[i][tri_i[2]]);
2486 double offset0 = fac0 * (dot_a - dot_b);
2487 double offset1 = fac1 * (dot_c - dot_b);
2488 if (offset0 > offset1) {
2490 std::swap(offset0, offset1);
2491 std::swap(fac0, fac1);
2492 std::swap(tri_i[0], tri_i[2]);
2495 range[i].min =
float(dot_b + offset0);
2496 range[i].max =
float(dot_b + offset1);
2497 interp_v3_v3v3(range[i].loc[0], tri[tri_i[1]], tri[tri_i[0]], fac0);
2498 interp_v3_v3v3(range[i].loc[1], tri[tri_i[1]], tri[tri_i[2]], fac1);
2501 range[i].min = range[i].max =
float(dot_b);
2507 if ((range[0].
max > range[1].
min) && (range[0].
min < range[1].
max)) {
2511 if (range[0].
min >= range[1].
min) {
2513 if (range[0].
max <= range[1].
max) {
2515 *r_tri_a_edge_isect_count = 2;
2519 *r_tri_a_edge_isect_count = 1;
2523 if (range[0].
max <= range[1].
max) {
2526 *r_tri_a_edge_isect_count = 1;
2540 const float t_a1[3],
2541 const float t_a2[3],
2542 const float t_b0[3],
2543 const float t_b1[3],
2544 const float t_b2[3],
2548 float tri_a[3][3], tri_b[3][3];
2571 const float t_a1[2],
2572 const float t_a2[2],
2573 const float t_b0[2],
2574 const float t_b1[2],
2575 const float t_b2[2])
2634 const float t_a1[2],
2635 const float t_a2[2],
2636 const float t_b0[2],
2637 const float t_b1[2],
2638 const float t_b2[2])
2682 const float t_a1[2],
2683 const float t_a2[2],
2684 const float t_b0[2],
2685 const float t_b1[2],
2686 const float t_b2[2])
2716 const float t_a1[2],
2717 const float t_a2[2],
2718 const float t_b0[2],
2719 const float t_b1[2],
2720 const float t_b2[2])
2747 const float a,
const float b,
const float c,
const float maxR,
float *root)
2757 float r1 = (-
b - sqrtD) / (2.0f * a);
2758 float r2 = (-
b + sqrtD) / (2.0f * a);
2766 if (r1 > 0.0f && r1 < maxR) {
2773 if (r2 > 0.0f && r2 < maxR) {
2784 const float bbmin[3],
2785 const float bbmax[3])
2789 float bb_near[3], bb_far[3];
2790 for (
int i = 0; i < totplane; i++) {
2813 float e1[3], e2[3], e3[3], point[3], vel[3], nor[3], temp[3], bv[3];
2814 float a,
b, c, d,
e,
x,
y,
z, radius2 = radius * radius;
2815 float elen2, edotv, edotbv, nordotv;
2817 bool found_by_sweep =
false;
2835 if (
fabsf(nordotv) < 0.000001f) {
2836 if (
fabsf(a) >= radius) {
2841 float t0 = (-a + radius) / nordotv;
2842 float t1 = (-a - radius) / nordotv;
2848 if (t0 > 1.0f || t1 < 0.0f) {
2853 CLAMP(t0, 0.0f, 1.0f);
2859 point[0] = p1[0] + vel[0] * t0 - nor[0] * radius;
2860 point[1] = p1[1] + vel[1] * t0 - nor[1] * radius;
2861 point[2] = p1[2] + vel[2] * t0 - nor[2] * radius;
2874 z =
x +
y - (a * c -
b *
b);
2876 if (
z <= 0.0f && (
x >= 0.0f &&
y >= 0.0f)) {
2892 c =
dot_v3v3(temp, temp) - radius2;
2896 found_by_sweep =
true;
2902 c =
dot_v3v3(temp, temp) - radius2;
2906 found_by_sweep =
true;
2912 c =
dot_v3v3(temp, temp) - radius2;
2916 found_by_sweep =
true;
2929 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2930 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2931 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2934 e = (edotv * newLambda - edotbv) / elen2;
2936 if (
e >= 0.0f &&
e <= 1.0f) {
2937 *r_lambda = newLambda;
2941 found_by_sweep =
true;
2951 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2952 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2953 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2956 e = (edotv * newLambda - edotbv) / elen2;
2958 if (
e >= 0.0f &&
e <= 1.0f) {
2959 *r_lambda = newLambda;
2963 found_by_sweep =
true;
2978 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2979 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2980 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2983 e = (edotv * newLambda - edotbv) / elen2;
2985 if (
e >= 0.0f &&
e <= 1.0f) {
2986 *r_lambda = newLambda;
2990 found_by_sweep =
true;
2994 return found_by_sweep;
3005 const float epsilon = 0.000001f;
3006 float p[3], e1[3], e2[3];
3008 int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3;
3014 f = (e2[a1] * e1[a2] - e2[a2] * e1[a1]);
3015 if ((f > -epsilon) && (f < epsilon)) {
3019 v = (p[a2] * e1[a1] - p[a1] * e1[a2]) / f;
3020 if ((
v < 0.0f) || (
v > 1.0f)) {
3025 if ((f > -epsilon) && (f < epsilon)) {
3027 if ((f > -epsilon) && (f < epsilon)) {
3030 u = (-p[a2] -
v * e2[a2]) / f;
3033 u = (-p[a1] -
v * e2[a1]) / f;
3036 if ((u < 0.0f) || ((u +
v) > 1.0f)) {
3040 *r_lambda = (p[a0] + u * e1[a0] +
v * e2[a0]) / (p2[a0] - p1[a0]);
3042 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
3055 const float epsilon)
3057 float a[3],
b[3], c[3], ab[3], cb[3];
3070 if (div == 0.0f) [[unlikely]] {
3074 if (
fabsf(d) <= epsilon) [[unlikely]] {
3086 float v3t[3], v4t[3];
3120 const float epsilon = 0.000001f;
3131 const float epsilon = 0.000001f;
3132 float a[3],
b[3], c[3], ab[3], cb[3], ca[3];
3145 if (div == 0.0f) [[unlikely]] {
3149 if (
fabsf(d) < epsilon) [[unlikely]] {
3160 if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
3175 const float ray_direction_a[3],
3176 const float ray_origin_b[3],
3177 const float ray_direction_b[3],
3178 const float epsilon,
3188 if (nlen < epsilon) [[unlikely]] {
3193 float t[3], c[3], cray[3];
3197 if (r_lambda_a !=
nullptr) {
3199 *r_lambda_a =
dot_v3v3(cray, n) / nlen;
3202 if (r_lambda_b !=
nullptr) {
3204 *r_lambda_b =
dot_v3v3(cray, n) / nlen;
3211 const float ray_direction_a[3],
3212 const float ray_origin_b[3],
3213 const float ray_direction_b[3],
3227 const float max1[3],
3228 const float min2[3],
3229 const float max2[3])
3231 return (min1[0] < max2[0] && min1[1] < max2[1] && min1[2] < max2[2] && min2[0] < max1[0] &&
3232 min2[1] < max1[1] && min2[2] < max1[2]);
3236 const float ray_origin[3],
3237 const float ray_direction[3])
3241 data->ray_inv_dir[0] = 1.0f / ray_direction[0];
3242 data->ray_inv_dir[1] = 1.0f / ray_direction[1];
3243 data->ray_inv_dir[2] = 1.0f / ray_direction[2];
3245 data->sign[0] =
data->ray_inv_dir[0] < 0.0f;
3246 data->sign[1] =
data->ray_inv_dir[1] < 0.0f;
3247 data->sign[2] =
data->ray_inv_dir[2] < 0.0f;
3251 const float bb_min[3],
3252 const float bb_max[3],
3262 float tmin = (bbox[
data->sign[0]][0] -
data->ray_origin[0]) *
data->ray_inv_dir[0];
3263 float tmax = (bbox[1 -
data->sign[0]][0] -
data->ray_origin[0]) *
data->ray_inv_dir[0];
3265 const float tymin = (bbox[
data->sign[1]][1] -
data->ray_origin[1]) *
data->ray_inv_dir[1];
3266 const float tymax = (bbox[1 -
data->sign[1]][1] -
data->ray_origin[1]) *
data->ray_inv_dir[1];
3268 if ((tmin > tymax) || (tymin > tmax)) {
3272 tmin = std::max(tymin, tmin);
3273 tmax = std::min(tymax, tmax);
3275 const float tzmin = (bbox[
data->sign[2]][2] -
data->ray_origin[2]) *
data->ray_inv_dir[2];
3276 const float tzmax = (bbox[1 -
data->sign[2]][2] -
data->ray_origin[2]) *
data->ray_inv_dir[2];
3278 if ((tmin > tzmax) || (tzmin > tmax)) {
3282 tmin = std::max(tzmin, tmin);
3297 const float bb_min[3],
3298 const float bb_max[3],
3304 const double invdirx = (dir[0] > 1e-35f || dir[0] < -1e-35f) ? 1.0 /
double(dir[0]) : DBL_MAX;
3305 const double invdiry = (dir[1] > 1e-35f || dir[1] < -1e-35f) ? 1.0 /
double(dir[1]) : DBL_MAX;
3306 const double invdirz = (dir[2] > 1e-35f || dir[2] < -1e-35f) ? 1.0 /
double(dir[2]) : DBL_MAX;
3307 t[0] = double(bb_min[0] - orig[0]) * invdirx;
3308 t[1] = double(bb_max[0] - orig[0]) * invdirx;
3309 t[2] = double(bb_min[1] - orig[1]) * invdiry;
3310 t[3] = double(bb_max[1] - orig[1]) * invdiry;
3311 t[4] = double(bb_min[2] - orig[2]) * invdirz;
3312 t[5] = double(bb_max[2] - orig[2]) * invdirz;
3313 hit_dist[0] =
float(fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5])));
3314 hit_dist[1] =
float(fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5])));
3315 if ((hit_dist[1] < 0.0f) || (hit_dist[0] > hit_dist[1])) {
3320 *tmin = hit_dist[0];
3323 *tmax = hit_dist[1];
3330 const float ray_orig[3],
3331 const float ray_dir[3])
3356 float h[2], u[2], lambda, denom;
3360 if (denom == 0.0f) {
3366 r_close[0] = l1[0] + u[0] * lambda;
3367 r_close[1] = l1[1] + u[1] * lambda;
3376 double h[2], u[2], lambda, denom;
3386 r_close[0] = l1[0] + u[0] * lambda;
3387 r_close[1] = l1[1] + u[1] * lambda;
3392 const float ray_origin[3],
3393 const float ray_direction[3],
3394 const float epsilon,
3395 const float fallback)
3397 float p_relative[3];
3400 return (
dot > epsilon) ? (
dot_v3v3(ray_direction, p_relative) /
dot) : fallback;
3404 const float ray_origin[3],
3405 const float ray_direction[3])
3413 const float epsilon,
3414 const float fallback)
3433 const float epsilon,
3434 const float fallback)
3451 const float plane_no[3],
3467 if (dist_old > dist) {
3470 float fac = (dist / dist_old) * 0.5f;
3481 const int x1,
const int y1,
const int x2,
const int y2,
const int a,
const int b)
3483 float v1[2],
v2[2], v3[2], p[2];
3515 float h, rp[3], cp[3], q[3];
3519 const float q_squared =
dot_v3v3(q, q);
3526 return (h >= 0.0f && h <= 1.0f);
3536 if (h < 0.0f || h > 1.0f) {
3569 const float p[3],
const float v1[3],
const float v2[3],
const float v3[3],
float r_isect_co[3])
3589 const float p1[3],
const float p2[3],
const float plane[4],
float r_p1[3],
float r_p2[3])
3609 const float p1_copy[3] = {
UNPACK3(p1)};
3621 const float p1_copy[3] = {
UNPACK3(p1)};
3629 const float p1_copy[3] = {
UNPACK3(p1)};
3637 const float plane_array[][4],
3638 const int plane_num,
3643 float p1_fac = 0.0f, p2_fac = 1.0f;
3648 for (
int i = 0; i < plane_num; i++) {
3649 const float *plane = plane_array[i];
3650 const float div =
dot_v3v3(dp, plane);
3663 if (p1_fac > p2_fac) {
3669 else if (div < 0.0f) {
3678 if (p1_fac > p2_fac) {
3688 const float p1_copy[3] = {
UNPACK3(p1)};
3742 const float v1[3],
const float v2[3],
const float v3[3],
const int i,
const int j)
3744 return 0.5f * ((v1[i] -
v2[i]) * (
v2[j] - v3[j]) + (v1[j] -
v2[j]) * (v3[i] -
v2[i]));
3766 wtot =
w[0] +
w[1] +
w[2];
3783 float w[3],
const float v1[3],
const float v2[3],
const float v3[3],
const float co[3])
3817 float n1[3], n2[3], n[3];
3825 std::swap(
w[2],
w[3]);
3827 if (!ok || (
w[0] < 0.0f)) {
3857 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3859 const float x = co[0],
y = co[1];
3860 const float x1 = v1[0], y1 = v1[1];
3861 const float x2 =
v2[0], y2 =
v2[1];
3862 const float x3 = v3[0], y3 = v3[1];
3863 const float det = (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3);
3869 w[0] = ((y2 - y3) * (
x - x3) + (x3 - x2) * (
y - y3)) / det;
3870 w[1] = ((y3 - y1) * (
x - x3) + (x1 - x3) * (
y - y3)) / det;
3871 w[2] = 1.0f -
w[0] -
w[1];
3881 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3888 wtot =
w[0] +
w[1] +
w[2];
3904 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3911 wtot =
w[0] +
w[1] +
w[2];
3927 const float v1[4],
const float v2[4],
const float v3[4],
const float co[2],
float w[3])
3934 wtot =
w[0] +
w[1] +
w[2];
3956 const float dirs[4][2] = {
3957 {v1[0] - co[0], v1[1] - co[1]},
3958 {
v2[0] - co[0],
v2[1] - co[1]},
3959 {v3[0] - co[0], v3[1] - co[1]},
3960 {v4[0] - co[0], v4[1] - co[1]},
3963 const float lens[4] = {
3973 w[1] =
w[2] =
w[3] = 0.0f;
3977 w[0] =
w[2] =
w[3] = 0.0f;
3981 w[0] =
w[1] =
w[3] = 0.0f;
3985 w[0] =
w[1] =
w[2] = 0.0f;
3989 const float areas[4] = {
3995 const float dots[4] = {
4001 const float lens_prod[4] = {
4009 for (
int i = 0; i < 4; i++) {
4010 const float area = areas[i];
4012 if (
fabsf(area) < 1.0e-12f * lens_prod[i] && dots[i] <= 0.0f) {
4013 const int j = (i + 1) & 3;
4014 const float sum = lens[i] + lens[j];
4015 w[0] =
w[1] =
w[2] =
w[3] = 0.0f;
4016 w[i] = lens[j] / sum;
4017 w[j] = lens[i] / sum;
4027#define MEAN_VALUE_HALF_TAN_V2(i1) \
4028 (areas[i1] != 0.0f ? fabsf((lens_prod[i1] - dots[i1]) / areas[i1]) : 0.0f)
4029 const float t[4] = {
4035#undef MEAN_VALUE_HALF_TAN_V2
4037 w[0] = (t[3] + t[0]) / lens[0];
4038 w[1] = (t[0] + t[1]) / lens[1];
4039 w[2] = (t[1] + t[2]) / lens[2];
4040 w[3] = (t[2] + t[3]) / lens[3];
4042 float wtot =
w[0] +
w[1] +
w[2] +
w[3];
4059 float const pt_src[3],
4060 const float tri_tar_p1[3],
4061 const float tri_tar_p2[3],
4062 const float tri_tar_p3[3],
4063 const float tri_src_p1[3],
4064 const float tri_src_p2[3],
4065 const float tri_src_p3[3])
4073 float no_tar[3], no_src[3];
4074 float mat_src[3][3];
4076 float tri_xy_src[3][3];
4078 float area_tar, area_src;
4096 area_src =
sqrtf(
area_tri_v2(tri_xy_src[0], tri_xy_src[1], tri_xy_src[2]));
4098 z_ofs_src = pt_src_xy[2] - tri_xy_src[0][2];
4099 madd_v3_v3v3fl(pt_tar, pt_tar, no_tar, (z_ofs_src / area_src) * area_tar);
4103 const float p_src[3],
4104 const float l_dst_p1[3],
4105 const float l_dst_p2[3],
4106 const float l_src_p1[3],
4107 const float l_src_p2[3])
4115 int found_invalid = 0;
4116 int found_valid = 0;
4119 for (i = 0; i < list_size; i++) {
4120 if (
array[i] == skipval) {
4128 if (found_valid == 0) {
4131 if (found_invalid == 0) {
4136 float valid_last = skipval;
4145 for (i = 0; i < list_size; i++) {
4146 if (
array[i] == skipval) {
4147 array_up[i] = valid_last;
4148 ofs_tot_up[i] = ++valid_ofs;
4151 valid_last =
array[i];
4156 valid_last = skipval;
4159 for (i = list_size - 1; i >= 0; i--) {
4160 if (
array[i] == skipval) {
4161 array_down[i] = valid_last;
4162 ofs_tot_down[i] = ++valid_ofs;
4165 valid_last =
array[i];
4171 for (i = 0; i < list_size; i++) {
4172 if (
array[i] == skipval) {
4173 if (array_up[i] != skipval && array_down[i] != skipval) {
4174 array[i] = ((array_up[i] *
float(ofs_tot_down[i])) +
4175 (array_down[i] *
float(ofs_tot_up[i]))) /
4176 float(ofs_tot_down[i] + ofs_tot_up[i]);
4178 else if (array_up[i] != skipval) {
4179 array[i] = array_up[i];
4181 else if (array_down[i] != skipval) {
4182 array[i] = array_down[i];
4196#define IS_POINT_IX (1 << 0)
4197#define IS_SEGMENT_IX (1 << 1)
4199#define DIR_V3_SET(d_len, va, vb) \
4201 sub_v3_v3v3((d_len)->dir, va, vb); \
4202 (d_len)->len = len_v3((d_len)->dir); \
4206#define DIR_V2_SET(d_len, va, vb) \
4208 sub_v2db_v2fl_v2fl((d_len)->dir, va, vb); \
4209 (d_len)->len = len_v2_db((d_len)->dir); \
4229 if (area != 0.0f) [[likely]] {
4231 const float len = d_curr->
len * d_next->
len;
4254 if (area != 0.0) [[likely]] {
4256 const double len = d_curr->
len * d_next->
len;
4269 float max_value = 0;
4271 for (
int i = 0; i < n; i++) {
4280 const float eps_sq =
eps *
eps;
4281 const float *v_curr, *v_next;
4283 float totweight = 0.0f;
4299 while (i_next < n) {
4305 if (d_next.
len <
eps) [[unlikely]] {
4317 w[i_curr] = (ht_prev + ht) / d_curr.
len;
4318 totweight +=
w[i_curr];
4329 memset(
w, 0,
sizeof(*
w) *
size_t(n));
4336 CLAMP(fac, 0.0f, 1.0f);
4337 w[i_curr] = 1.0f - fac;
4342 if (totweight != 0.0f) {
4343 for (i_curr = 0; i_curr < n; i_curr++) {
4344 w[i_curr] /= totweight;
4354 float max_value = 0;
4356 for (
int i = 0; i < n; i++) {
4364 const float eps_sq =
eps *
eps;
4366 const float *v_curr, *v_next;
4368 float totweight = 0.0f;
4384 while (i_next < n) {
4390 if (d_next.
len <
eps) [[unlikely]] {
4402 w[i_curr] = (d_curr.
len == 0.0) ? 0.0f :
float((ht_prev + ht) / d_curr.
len);
4403 totweight +=
w[i_curr];
4414 memset(
w, 0,
sizeof(*
w) *
size_t(n));
4421 CLAMP(fac, 0.0f, 1.0f);
4422 w[i_curr] = 1.0f - fac;
4427 if (totweight != 0.0f) {
4428 for (i_curr = 0; i_curr < n; i_curr++) {
4429 w[i_curr] /= totweight;
4456 const float t2 = t * t;
4457 const float t3 = t2 * t;
4460 a[0] = v1[0] +
v2[0] + 2 * (x1[0] - x2[0]);
4461 a[1] = v1[1] +
v2[1] + 2 * (x1[1] - x2[1]);
4462 a[2] = v1[2] +
v2[2] + 2 * (x1[2] - x2[2]);
4464 b[0] = -2 * v1[0] -
v2[0] - 3 * (x1[0] - x2[0]);
4465 b[1] = -2 * v1[1] -
v2[1] - 3 * (x1[1] - x2[1]);
4466 b[2] = -2 * v1[2] -
v2[2] - 3 * (x1[2] - x2[2]);
4468 x[0] = a[0] * t3 +
b[0] * t2 + v1[0] * t + x1[0];
4469 x[1] = a[1] * t3 +
b[1] * t2 + v1[1] * t + x1[1];
4470 x[2] = a[2] * t3 +
b[2] * t2 + v1[2] * t + x1[2];
4472 v[0] = 3 * a[0] * t2 + 2 *
b[0] * t + v1[0];
4473 v[1] = 3 * a[1] * t2 + 2 *
b[1] * t + v1[1];
4474 v[2] = 3 * a[2] * t2 + 2 *
b[2] * t + v1[2];
4480#define IS_ZERO(x) ((x > (-DBL_EPSILON) && x < DBL_EPSILON) ? 1 : 0)
4483 float r_uv[2],
const float st[2],
const float st0[2],
const float st1[2],
const float st2[2])
4488 const double a = st0[0] - st2[0],
b = st1[0] - st2[0];
4489 const double c = st0[1] - st2[1], d = st1[1] - st2[1];
4490 const double det = a * d - c *
b;
4494 const double x[2] = {st[0] - st2[0], st[1] - st2[1]};
4496 r_uv[0] =
float((d *
x[0] -
b *
x[1]) / det);
4497 r_uv[1] =
float(((-c) *
x[0] + a *
x[1]) / det);
4505 float r_uv[2],
const float st[3],
const float st0[3],
const float st1[3],
const float st2[3])
4507 float v0[3], v1[3],
v2[3];
4508 double d00, d01, d11, d20, d21, det;
4520 det = d00 * d11 - d01 * d01;
4526 w =
float((d00 * d21 - d01 * d20) / det);
4527 r_uv[1] =
float((d11 * d20 - d01 * d21) / det);
4528 r_uv[0] = 1.0f - r_uv[1] -
w;
4546 float r_deriv[2][2],
4553 const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) +
4554 (st1[0] * st2[1] - st1[1] * st2[0]) +
4555 (st2[0] * st3[1] - st2[1] * st3[0]) +
4556 (st3[0] * st0[1] - st3[1] * st0[0]);
4560 const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
4564 0.5 * double(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
4565 ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
4568 const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
4569 double denom = a - 2 *
b + fC;
4575 const double fDen = a - fC;
4577 r_uv[0] =
float(a / fDen);
4581 const double desc_sq =
b *
b - a * fC;
4582 const double desc =
sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
4583 const double s = signed_area > 0 ? (-1.0) : 1.0;
4585 r_uv[0] =
float(((a -
b) + s * desc) / denom);
4591 const double denom_s = (1 - r_uv[0]) * (st0[0] - st3[0]) + r_uv[0] * (st1[0] - st2[0]);
4592 const double denom_t = (1 - r_uv[0]) * (st0[1] - st3[1]) + r_uv[0] * (st1[1] - st2[1]);
4596 if (
fabs(denom_s) <
fabs(denom_t)) {
4602 r_uv[1] =
float(
double((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) /
4608 float tmp1[2], tmp2[2], s[2], t[2];
4621 denom = t[0] * s[1] - t[1] * s[0];
4624 double inv_denom = 1.0 / denom;
4625 r_deriv[0][0] =
float(
double(-t[1]) * inv_denom);
4626 r_deriv[0][1] =
float(
double(t[0]) * inv_denom);
4627 r_deriv[1][0] =
float(
double(s[1]) * inv_denom);
4628 r_deriv[1][1] =
float(
double(-s[0]) * inv_denom);
4639 const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) +
4640 (st1[0] * st2[1] - st1[1] * st2[0]) +
4641 (st2[0] * st3[1] - st2[1] * st3[0]) +
4642 (st3[0] * st0[1] - st3[1] * st0[0]);
4646 const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
4650 0.5 * double(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
4651 ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
4654 const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
4655 double denom = a - 2 *
b + fC;
4658 const double fDen = a - fC;
4660 return float(a / fDen);
4666 const double desc_sq =
b *
b - a * fC;
4667 const double desc =
sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
4668 const double s = signed_area > 0 ? (-1.0) : 1.0;
4670 return float(((a -
b) + s * desc) / denom);
4717 const float nearClip,
4718 const float farClip)
4720 float Xdelta, Ydelta, Zdelta;
4722 Xdelta = right - left;
4723 Ydelta = top - bottom;
4724 Zdelta = farClip - nearClip;
4725 if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
4729 mat[0][0] = 2.0f / Xdelta;
4730 mat[3][0] = -(right + left) / Xdelta;
4731 mat[1][1] = 2.0f / Ydelta;
4732 mat[3][1] = -(top + bottom) / Ydelta;
4733 mat[2][2] = -2.0f / Zdelta;
4734 mat[3][2] = -(farClip + nearClip) / Zdelta;
4742 const float nearClip,
4743 const float farClip)
4745 const float Xdelta = right - left;
4746 const float Ydelta = top - bottom;
4747 const float Zdelta = farClip - nearClip;
4749 if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
4752 mat[0][0] = nearClip * 2.0f / Xdelta;
4753 mat[1][1] = nearClip * 2.0f / Ydelta;
4754 mat[2][0] = (right + left) / Xdelta;
4755 mat[2][1] = (top + bottom) / Ydelta;
4756 mat[2][2] = -(farClip + nearClip) / Zdelta;
4758 mat[3][2] = (-2.0f * nearClip * farClip) / Zdelta;
4759 mat[0][1] = mat[0][2] = mat[0][3] = mat[1][0] = mat[1][2] = mat[1][3] = mat[3][0] = mat[3][1] =
4764 const float angle_left,
4765 const float angle_right,
4766 const float angle_up,
4767 const float angle_down,
4768 const float nearClip,
4769 const float farClip)
4771 const float tan_angle_left =
tanf(angle_left);
4772 const float tan_angle_right =
tanf(angle_right);
4773 const float tan_angle_bottom =
tanf(angle_up);
4774 const float tan_angle_top =
tanf(angle_down);
4777 mat, tan_angle_left, tan_angle_right, tan_angle_top, tan_angle_bottom, nearClip, farClip);
4778 mat[0][0] /= nearClip;
4779 mat[1][1] /= nearClip;
4784 if (winmat[2][3] == -1.0f) {
4790 v1[0] = perspmat[0][0];
4791 v1[1] = perspmat[1][0];
4792 v1[2] = perspmat[2][0];
4794 v2[0] = perspmat[0][1];
4795 v2[1] = perspmat[1][1];
4796 v2[2] = perspmat[2][1];
4798 len1 = (1.0f /
len_v3(v1));
4801 winmat[2][0] -= len1 * winmat[0][0] *
x;
4802 winmat[2][1] -= len2 * winmat[1][1] *
y;
4828 left[i] = mat[i][3] + mat[i][0];
4834 right[i] = mat[i][3] - mat[i][0];
4840 bottom[i] = mat[i][3] + mat[i][1];
4846 top[i] = mat[i][3] - mat[i][1];
4852 near[i] = mat[i][3] + mat[i][2];
4858 far[i] = mat[i][3] - mat[i][2];
4871 const bool is_persp = winmat[3][3] == 0.0f;
4873 const float near = winmat[3][2] / (winmat[2][2] - 1.0f);
4874 *r_left = near * ((winmat[2][0] - 1.0f) / winmat[0][0]);
4875 *r_right = near * ((winmat[2][0] + 1.0f) / winmat[0][0]);
4876 *r_bottom = near * ((winmat[2][1] - 1.0f) / winmat[1][1]);
4877 *r_top = near * ((winmat[2][1] + 1.0f) / winmat[1][1]);
4879 if (winmat[2][2] == -1.0f) {
4881 *r_far = near + 1e9f;
4884 *r_far = winmat[3][2] / (winmat[2][2] + 1.0f);
4888 *r_left = (-winmat[3][0] - 1.0f) / winmat[0][0];
4889 *r_right = (-winmat[3][0] + 1.0f) / winmat[0][0];
4890 *r_bottom = (-winmat[3][1] - 1.0f) / winmat[1][1];
4891 *r_top = (-winmat[3][1] + 1.0f) / winmat[1][1];
4892 *r_near = (winmat[3][2] + 1.0f) / winmat[2][2];
4893 *r_far = (winmat[3][2] - 1.0f) / winmat[2][2];
4905 double winmat[4][4];
4908 const bool is_persp = winmat[3][3] == 0.0f;
4910 const double near = winmat[3][2] / (winmat[2][2] - 1.0);
4911 *r_left = near * ((winmat[2][0] - 1.0) / winmat[0][0]);
4912 *r_right = near * ((winmat[2][0] + 1.0) / winmat[0][0]);
4913 *r_bottom = near * ((winmat[2][1] - 1.0) / winmat[1][1]);
4914 *r_top = near * ((winmat[2][1] + 1.0) / winmat[1][1]);
4916 *r_far = winmat[3][2] / (winmat[2][2] + 1.0);
4919 *r_left = (-winmat[3][0] - 1.0) / winmat[0][0];
4920 *r_right = (-winmat[3][0] + 1.0) / winmat[0][0];
4921 *r_bottom = (-winmat[3][1] - 1.0) / winmat[1][1];
4922 *r_top = (-winmat[3][1] + 1.0) / winmat[1][1];
4923 *r_near = (winmat[3][2] + 1.0) / winmat[2][2];
4924 *r_far = (winmat[3][2] - 1.0) / winmat[2][2];
4929 const int win_size[2],
4934 float r_projmat[4][4])
4936 float rect_width =
float(x_max - x_min);
4937 float rect_height =
float(y_max - y_min);
4939 float x_sca =
float(win_size[0]) / rect_width;
4940 float y_sca =
float(win_size[1]) / rect_height;
4942 float x_fac =
float((x_min + x_max) - win_size[0]) / rect_width;
4943 float y_fac =
float((y_min + y_max) - win_size[1]) / rect_height;
4946 r_projmat[0][0] *= x_sca;
4947 r_projmat[1][1] *= y_sca;
4949 if (projmat[3][3] == 0.0f) {
4950 r_projmat[2][0] = r_projmat[2][0] * x_sca + x_fac;
4951 r_projmat[2][1] = r_projmat[2][1] * y_sca + y_fac;
4954 r_projmat[3][0] = r_projmat[3][0] * x_sca - x_fac;
4955 r_projmat[3][1] = r_projmat[3][1] * y_sca - y_fac;
4964 for (row = 0; row < 4; row++) {
4965 for (col = 0; col < 4; col++) {
4966 temp[row][col] = (icand[row][0] * mat[0][col] + icand[row][1] * mat[1][col] +
4967 icand[row][2] * mat[2][col] + icand[row][3] * mat[3][col]);
4973void polarview_m4(
float mat[4][4],
float dist,
float azimuth,
float incidence,
float twist)
4984 float mat[4][4],
float vx,
float vy,
float vz,
float px,
float py,
float pz,
float twist)
4986 float sine, cosine, hyp, hyp1, dx, dy, dz;
4996 hyp = dx * dx + dz * dz;
4997 hyp1 =
sqrtf(dy * dy + hyp);
5002 cosine = hyp / hyp1;
5008 mat1[1][1] = cosine;
5011 mat1[2][2] = cosine;
5016 mat1[1][1] = mat1[2][2] = 1.0f;
5017 mat1[1][2] = mat1[2][1] = 0.0f;
5028 mat1[0][0] = cosine;
5031 mat1[2][2] = cosine;
5039 float mat[4][4], vec[4];
5040 int a, fl, flag = -1;
5044 for (a = 0; a < 8; a++) {
5045 vec[0] = (a & 1) ? boundbox[0][0] : boundbox[1][0];
5046 vec[1] = (a & 2) ? boundbox[0][1] : boundbox[1][1];
5047 vec[2] = (a & 4) ? boundbox[0][2] : boundbox[1][2];
5053 if (vec[0] >
bounds[1] * vec[3]) {
5056 if (vec[0] <
bounds[0] * vec[3]) {
5059 if (vec[1] >
bounds[3] * vec[3]) {
5062 if (vec[1] <
bounds[2] * vec[3]) {
5067 if (vec[0] < -vec[3]) {
5070 if (vec[0] > vec[3]) {
5073 if (vec[1] < -vec[3]) {
5076 if (vec[1] > vec[3]) {
5080 if (vec[2] < -vec[3]) {
5083 if (vec[2] > vec[3]) {
5098 float mn[3], mx[3], vec[3];
5104 for (a = 0; a < 8; a++) {
5105 vec[0] = (a & 1) ? boundbox[0][0] : boundbox[1][0];
5106 vec[1] = (a & 2) ? boundbox[0][1] : boundbox[1][1];
5107 vec[2] = (a & 4) ? boundbox[0][2] : boundbox[1][2];
5136 const float epsilon = 0.25f / 65536.0f;
5140 if (1.0f - epsilon < u) {
5148 bool regular =
true;
5149 if (
x *
x +
y *
y < 1e-6f * 1e-6f) {
5157 *r_v = (
z + 1.0f) / 2.0f;
5163 bool regular =
true;
5164 const float epsilon = 0.25f / 65536.0f;
5165 const float len_xy =
sqrtf(
x *
x +
y *
y);
5166 if (len_xy <=
fabsf(
z) * epsilon) {
5180 const float target[3] = {0.0f, 0.0f, 1.0f};
5191 const float axis[3],
5210 const float f_no[3],
5216 const int nverts = 3;
5229 float *vn[] = {n1, n2, n3};
5230 const float *prev_edge = vdiffs[nverts - 1];
5233 for (i = 0; i < nverts; i++) {
5234 const float *cur_edge = vdiffs[i];
5239 prev_edge = cur_edge;
5248 const float f_no[3],
5255 const int nverts = (n4 !=
nullptr && co4 !=
nullptr) ? 4 : 3;
5276 float *vn[] = {n1, n2, n3, n4};
5277 const float *prev_edge = vdiffs[nverts - 1];
5280 for (i = 0; i < nverts; i++) {
5281 const float *cur_edge = vdiffs[i];
5286 prev_edge = cur_edge;
5292 const float polyno[3],
5293 const float **vertcos,
5300 for (i = 0; i < nverts; i++) {
5301 sub_v3_v3v3(vdiffs[i], vertcos[(i + 1) % nverts], vertcos[i]);
5307 const float *prev_edge = vdiffs[nverts - 1];
5309 for (i = 0; i < nverts; i++) {
5310 const float *cur_edge = vdiffs[i];
5318 prev_edge = cur_edge;
5338 const float s1 = uv2[0] - uv1[0];
5339 const float s2 = uv3[0] - uv1[0];
5340 const float t1 = uv2[1] - uv1[1];
5341 const float t2 = uv3[1] - uv1[1];
5342 float det = (s1 * t2 - s2 * t1);
5346 float tangv[3], ct[3], e1[3], e2[3];
5353 r_tang[0] = (t2 * e1[0] - t1 * e2[0]) * det;
5354 r_tang[1] = (t2 * e1[1] - t1 * e2[1]) * det;
5355 r_tang[2] = (t2 * e1[2] - t1 * e2[2]) * det;
5356 tangv[0] = (s1 * e2[0] - s2 * e1[0]) * det;
5357 tangv[1] = (s1 * e2[1] - s2 * e1[1]) * det;
5358 tangv[2] = (s1 * e2[2] - s2 * e1[2]) * det;
5380 const float (*pos)[3],
5381 const float *weight,
5382 const float (*rpos)[3],
5383 const float *rweight,
5389 float accu_com[3] = {0.0f, 0.0f, 0.0f}, accu_rcom[3] = {0.0f, 0.0f, 0.0f};
5390 float accu_weight = 0.0f, accu_rweight = 0.0f;
5391 const float eps = 1e-6f;
5408 if (pos && rpos && (list_size > 0)) {
5410 for (a = 0; a < list_size; a++) {
5416 accu_weight += weight[a];
5427 accu_rweight += rweight[a];
5433 if (!weight || !rweight) {
5434 accu_weight = accu_rweight =
float(list_size);
5437 mul_v3_fl(accu_com, 1.0f / accu_weight);
5438 mul_v3_fl(accu_rcom, 1.0f / accu_rweight);
5445 if (lrot || lscale) {
5449 float m[3][3], mr[3][3], q[3][3], qi[3][3];
5450 float va[3], vb[3], stunt[3];
5452 int i = 0, imax = 15;
5457 for (a = 0; a < list_size; a++) {
5462 m[0][0] += va[0] * vb[0];
5463 m[0][1] += va[0] * vb[1];
5464 m[0][2] += va[0] * vb[2];
5466 m[1][0] += va[1] * vb[0];
5467 m[1][1] += va[1] * vb[1];
5468 m[1][2] += va[1] * vb[2];
5470 m[2][0] += va[2] * vb[0];
5471 m[2][1] += va[2] * vb[1];
5472 m[2][2] += va[2] * vb[2];
5477 mr[0][0] += va[0] * va[0];
5478 mr[0][1] += va[0] * va[1];
5479 mr[0][2] += va[0] * va[2];
5481 mr[1][0] += va[1] * va[0];
5482 mr[1][1] += va[1] * va[1];
5483 mr[1][2] += va[1] * va[2];
5485 mr[2][0] += va[2] * va[0];
5486 mr[2][1] += va[2] * va[1];
5487 mr[2][2] += va[2] * va[2];
5500 while ((odet - ndet) * (odet - ndet) >
eps && i < imax) {
5530 const float f1_no[3],
5531 const float f2_no[3])
5559 float v13[3], v24[3];
5569 const float eps_sq =
square_f(1e-8f);
5575 const float *quad_coords[4] = {v1,
v2, v3, v4};
5576 float quad_proj[4][3];
5578 for (
int i = 0; i < 4; i++) {
5582 float quad_dirs[4][3];
5583 for (
int i = 0, j = 3; i < 4; j = i++) {
5584 sub_v3_v3v3(quad_dirs[i], quad_proj[i], quad_proj[j]);
5589#define CROSS_SIGN(dir_a, dir_b) \
5590 ((void)cross_v3_v3v3(test_dir, dir_a, dir_b), (dot_v3v3(plane, test_dir) > 0.0f))
5608 const float *co_curr, *co_prev;
5609 float dir_curr[2], dir_prev[2];
5611 co_prev = verts[nr - 1];
5616 for (a = 0; a < nr; a++) {
5626 else if (
cross > 0.0f) {
5630 if (sign_flag == (1 | 2)) {
5645 float d_12[3], d_23[3], d_34[3], d_41[3];
5646 float cross_a[3], cross_b[3];
5656 ret |= ((
dot_v3v3(cross_a, cross_b) < 0.0f) << 0);
5660 ret |= ((
dot_v3v3(cross_a, cross_b) < 0.0f) << 1);
5673 float d_12[3], d_13[3], d_14[3];
5674 float cross_a[3], cross_b[3];
5680 return dot_v3v3(cross_a, cross_b) > 0.0f;
5689 const float eps = 1e-5f;
5691 const float tan_dot =
dot_v3v3(tan_l, tan_r);
5692 if (tan_dot > 1.0f -
eps) {
5694 return (1.0f / 3.0f) * 0.75f;
5696 if (tan_dot < -1.0f +
eps) {
5698 return (1.0f / 2.0f);
5707 return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
5711 const float v0[3],
const float v1[3],
const float v2[3],
const float dist1,
const float dist2)
5714 float v10[3], v12[3];
5718 if (dist1 != 0.0f && dist2 != 0.0f) {
5720 float u[3],
v[3], n[3];
5723 if (d12 * d12 > 0.0f) {
5733 const float a = 0.5f * (1.0f + (dist1 * dist1 - dist2 * dist2) / (d12 * d12));
5734 const float hh = dist1 * dist1 - a * a * d12 * d12;
5737 const float h =
sqrtf(hh);
5738 const float S_[2] = {a * d12, -h};
5742 const float x_intercept = S_[0] + h * (v0_[0] - S_[0]) / (v0_[1] + h);
5743 if (x_intercept >= 0.0f && x_intercept <= d12) {
5744 const float dist0 =
len_v2v2(S_, v0_);
5749 if (dist0 >= std::min(dist1, dist2)) {
#define BLI_ASSERT_UNIT_EPSILON
#define BLI_ASSERT_UNIT_V3(v)
#define ISECT_AABB_PLANE_IN_FRONT_ALL
#define ISECT_LINE_LINE_NONE
#define ISECT_AABB_PLANE_CROSS_ANY
#define ISECT_AABB_PLANE_BEHIND_ANY
#define ISECT_LINE_LINE_COLINEAR
#define ISECT_LINE_LINE_EXACT
#define ISECT_LINE_LINE_CROSS
#define IN_RANGE(a, b, c)
#define IN_RANGE_INCL(a, b, c)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
bool closest(btVector3 &v)
b[1] b &&[1] b &&[1] b &&[1] b &&[1] b[3] b &&[1] b[3] float determinant(MatBase< C, R >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
float length(VecOp< float, D >) RET
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
#define MEAN_VALUE_HALF_TAN_V2(i1)
#define DIR_V3_SET(d_len, va, vb)
#define DIR_V2_SET(d_len, va, vb)
#define CROSS_SIGN(dir_a, dir_b)
float safe_acos_approx(float x)
float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
bool isect_ray_plane_v3_factor(const float ray_origin[3], const float ray_direction[3], const float plane_co[3], const float plane_no[3], float *r_lambda)
void resolve_quad_uv_v2(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
MINLINE float min_ff(float a, float b)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
float area_squared_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool isect_plane_plane_plane_v3(const float plane_a[4], const float plane_b[4], const float plane_c[4], float r_isect_co[3]) ATTR_WARN_UNUSED_RESULT
bool isect_point_tri_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3], float r_isect_co[3])
bool point_in_slice_seg(float p[3], float l1[3], float l2[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
bool isect_plane_plane_v3(const float plane_a[4], const float plane_b[4], float r_isect_co[3], float r_isect_no[3]) ATTR_WARN_UNUSED_RESULT
double closest_to_line_v2_db(double r_close[2], const double p[2], const double l1[2], const double l2[2])
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
MINLINE float dot_m3_v3_row_z(const float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT
static int isect_tri_tri_impl_ccw_v2(const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
int isect_line_line_epsilon_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3], float epsilon)
int isect_line_sphere_v3(const float l1[3], const float l2[3], const float sp[3], float r, float r_p1[3], float r_p2[3])
float closest_to_ray_v3(float r_close[3], const float p[3], const float ray_orig[3], const float ray_dir[3])
void interp_cubic_v3(float x[3], float v[3], const float x1[3], const float v1[3], const float x2[3], const float v2[3], float t)
MINLINE bool is_finite_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
void rotate_normalized_v3_v3v3fl(float out[3], const float p[3], const float axis[3], float angle)
MINLINE void sub_v2_v2v2_db(double r[2], const double a[2], const double b[2])
bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], float radius, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float ipoint[3])
float line_point_factor_v3_ex(const float p[3], const float l1[3], const float l2[3], float epsilon, float fallback)
bool map_to_tube(float *r_u, float *r_v, float x, float y, float z)
bool isect_ray_aabb_v3(const struct IsectRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float *r_tmin)
bool isect_ray_seg_v2(const float ray_origin[2], const float ray_direction[2], const float v0[2], const float v1[2], float *r_lambda, float *r_u)
void isect_seg_seg_v3(const float a0[3], const float a1[3], const float b0[3], const float b1[3], float r_a[3], float r_b[3])
bool isect_tri_tri_v3(const float t_a0[3], const float t_a1[3], const float t_a2[3], const float t_b0[3], const float t_b1[3], const float t_b2[3], float r_i1[3], float r_i2[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
int interp_sparse_array(float *array, int list_size, float skipval)
void interp_weights_quad_v3(float w[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float co[3])
static bool barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
static bool point_in_slice(const float p[3], const float v1[3], const float l1[3], const float l2[3])
void projmat_dimensions(const float winmat[4][4], float *r_left, float *r_right, float *r_bottom, float *r_top, float *r_near, float *r_far)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
bool isect_ray_tri_watertight_v3(const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
int isect_aabb_planes_v3(const float(*planes)[4], int totplane, const float bbmin[3], const float bbmax[3])
void cross_poly_v3(float n[3], const float verts[][3], unsigned int nr)
float dist_signed_squared_to_plane_v3(const float p[3], const float plane[4])
bool isect_ray_plane_v3(const float ray_origin[3], const float ray_direction[3], const float plane[4], float *r_lambda, bool clip)
void projmat_from_subregion(const float projmat[4][4], const int win_size[2], int x_min, int x_max, int y_min, int y_max, float r_projmat[4][4])
int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b)
bool isect_line_tri_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], unsigned int nr)
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
bool isect_tri_tri_v3_ex(const float tri_a[3][3], const float tri_b[3][3], float r_i1[3], float r_i2[3], int *r_tri_a_edge_isect_count)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2], float r, float r_p1[2], float r_p2[2])
MINLINE void copy_v2_v2(float r[2], const float a[2])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
void perspective_m4_fov(float mat[4][4], float angle_left, float angle_right, float angle_up, float angle_down, float nearClip, float farClip)
bool isect_ray_line_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], float *r_lambda)
float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
float cross_poly_v2(const float verts[][2], unsigned int nr)
MINLINE float mul_project_m4_v3_zfac(const float mat[4][4], const float co[3]) ATTR_WARN_UNUSED_RESULT
float normal_poly_v3(float n[3], const float verts[][3], unsigned int nr)
void planes_from_projmat(const float mat[4][4], float left[4], float right[4], float bottom[4], float top[4], float near[4], float far[4])
int isect_seg_seg_v2_point_ex(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float endpoint_bias, float r_vi[2])
static double mean_value_half_tan_v2_db(const Double2_Len *d_curr, const Double2_Len *d_next)
float dist_squared_to_projected_aabb_simple(const float projmat[4][4], const float winsize[2], const float mval[2], const float bbmin[3], const float bbmax[3])
int isect_seg_seg_v2_int(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
struct DistRayAABB_Precalc dist_squared_ray_to_aabb_v3_precalc(const float ray_origin[3], const float ray_direction[3])
void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3])
int isect_seg_seg_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
void transform_point_by_tri_v3(float pt_tar[3], float const pt_src[3], const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], const float tri_src_p1[3], const float tri_src_p2[3], const float tri_src_p3[3])
void window_translate_m4(float winmat[4][4], float perspmat[4][4], float x, float y)
bool isect_ray_tri_threshold_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], float threshold)
float closest_to_line_segment_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void copy_v4_fl(float r[4], float f)
void resolve_quad_uv_v2_deriv(float r_uv[2], float r_deriv[2][2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
bool isect_axial_line_segment_tri_v3(int axis, const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda)
float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float normal[3])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
bool isect_line_line_strict_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float vi[3], float *r_lambda)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void projmat_dimensions_db(const float winmat_fl[4][4], double *r_left, double *r_right, double *r_bottom, double *r_top, double *r_near, double *r_far)
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
bool map_to_sphere(float *r_u, float *r_v, float x, float y, float z)
void cross_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
bool is_quad_flip_v3_first_third_fast(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
bool isect_ray_aabb_v3_simple(const float orig[3], const float dir[3], const float bb_min[3], const float bb_max[3], float *tmin, float *tmax)
float ray_point_factor_v3(const float p[3], const float ray_origin[3], const float ray_direction[3])
bool isect_planes_v3_fn(const float planes[][4], int planes_len, float eps_coplanar, float eps_isect, void(*callback_fn)(const float co[3], int i, int j, int k, void *user_data), void *user_data)
static bool isect_tri_tri_v2_impl_vert(const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
void plane_to_point_vector_v3_normalized(const float plane[4], float r_plane_co[3], float r_plane_no[3])
void limit_dist_v3(float v1[3], float v2[3], float dist)
float ray_point_factor_v3_ex(const float p[3], const float ray_origin[3], const float ray_direction[3], float epsilon, float fallback)
void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], const float pt[3])
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
float determinant_m3_array(const float m[3][3])
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], const float pt[3])
bool isect_line_segment_tri_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
void perspective_m4(float mat[4][4], float left, float right, float bottom, float top, float nearClip, float farClip)
void dist_squared_to_projected_aabb_precalc(struct DistProjectedAABBPrecalc *precalc, const float projmat[4][4], const float winsize[2], const float mval[2])
float line_point_factor_v2_ex(const float p[2], const float l1[2], const float l2[2], float epsilon, float fallback)
MINLINE void mul_v3_fl(float r[3], float f)
float dist_to_line_v3(const float p[3], const float l1[3], const float l2[3])
float dist_squared_to_line_v3(const float p[3], const float l1[3], const float l2[3])
bool isect_ray_ray_epsilon_v3(const float ray_origin_a[3], const float ray_direction_a[3], const float ray_origin_b[3], const float ray_direction_b[3], float epsilon, float *r_lambda_a, float *r_lambda_b)
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
void barycentric_weights_v2_clamped(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
void orthographic_m4(float mat[4][4], float left, float right, float bottom, float top, float nearClip, float farClip)
MINLINE void zero_v4(float r[4])
void plane_to_point_vector_v3(const float plane[4], float r_plane_co[3], float r_plane_no[3])
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
void vcloud_estimate_transform_v3(int list_size, const float(*pos)[3], const float *weight, const float(*rpos)[3], const float *rweight, float lloc[3], float rloc[3], float lrot[3][3], float lscale[3][3])
float area_poly_v2(const float verts[][2], unsigned int nr)
float volume_tetrahedron_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
static float tri_signed_area(const float v1[3], const float v2[3], const float v3[3], const int i, const int j)
MINLINE float dot_m4_v3_row_x(const float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT
void transform_point_by_seg_v3(float p_dst[3], const float p_src[3], const float l_dst_p1[3], const float l_dst_p2[3], const float l_src_p1[3], const float l_src_p2[3])
void transpose_m3(float R[3][3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void resolve_tri_uv_v2(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2])
static float snap_coordinate(float u)
MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
static float mean_value_half_tan_v3(const Float3_Len *d_curr, const Float3_Len *d_next)
BMesh const char void * data
bool isect_ray_tri_watertight_v3_simple(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2])
MINLINE int axis_dominant_v3_single(const float vec[3])
void interp_weights_tri_v3(float w[3], const float v1[3], const float v2[3], const float v3[3], const float co[3])
bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const float v3[2], const float v4[2], const float co[2], float w[4])
bool isect_point_poly_v2(const float pt[2], const float verts[][2], unsigned int nr)
MINLINE void cross_v3_v3v3_db(double r[3], const double a[3], const double b[3])
float closest_seg_seg_v2(float r_closest_a[2], float r_closest_b[2], float *r_lambda_a, float *r_lambda_b, const float a1[2], const float a2[2], const float b1[2], const float b2[2])
void aabb_get_near_far_from_plane(const float plane_no[3], const float bbmin[3], const float bbmax[3], float bb_near[3], float bb_afar[3])
MINLINE void negate_v3(float r[3])
MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
void accumulate_vertex_normals_poly_v3(float **vertnos, const float polyno[3], const float **vertcos, float vdiffs[][3], int nverts)
void unit_m4(float m[4][4])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat[4][4])
float dist_squared_to_plane3_v3(const float p[3], const float plane[3])
void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc, const float ray_direction[3])
void resolve_tri_uv_v3(float r_uv[2], const float st[3], const float st0[3], const float st1[3], const float st2[3])
int isect_point_quad_v2(const float p[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2])
float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
static void i_multmatrix(const float icand[4][4], float mat[4][4])
void interp_weights_poly_v3(float w[], float v[][3], int n, const float co[3])
int isect_seg_seg_v2_lambda_mu_db(const double v1[2], const double v2[2], const double v3[2], const double v4[2], double *r_lambda, double *r_mu)
float dist_seg_seg_v2(const float a1[3], const float a2[3], const float b1[3], const float b2[3])
float resolve_quad_u_v2(const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
bool isect_ray_tri_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void zero_v3(float r[3])
void mul_m4_v4(const float mat[4][4], float r[4])
static bool isect_tri_tri_v2_impl_edge(const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void interp_weights_poly_v2(float w[], float v[][2], int n, const float co[2])
bool isect_ray_ray_v3(const float ray_origin_a[3], const float ray_direction_a[3], const float ray_origin_b[3], const float ray_direction_b[3], float *r_lambda_a, float *r_lambda_b)
bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
bool isect_line_plane_v3(float r_isect_co[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3]) ATTR_WARN_UNUSED_RESULT
MINLINE double cross_v2v2_db(const double a[2], const double b[2]) ATTR_WARN_UNUSED_RESULT
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
void copy_m4d_m4(double m1[4][4], const float m2[4][4])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
void transpose_m4_m4(float R[4][4], const float M[4][4])
bool isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
MINLINE float normalize_v3(float n[3])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3])
void mul_m3_fl(float R[3][3], float f)
float dist_to_plane_v3(const float p[3], const float plane[4])
void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4])
bool is_poly_convex_v2(const float verts[][2], unsigned int nr)
float area_squared_poly_v2(const float verts[][2], unsigned int nr)
void axis_angle_to_mat4_single(float R[4][4], char axis, float angle)
int barycentric_inside_triangle_v2(const float w[3])
bool isect_line_segment_tri_epsilon_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], float epsilon)
float closest_ray_to_segment_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], float r_close[3])
float dist_squared_to_plane_v3(const float p[3], const float plane[4])
void accumulate_vertex_normals_tri_v3(float n1[3], float n2[3], float n3[3], const float f_no[3], const float co1[3], const float co2[3], const float co3[3])
void rotate_m4(float mat[4][4], char axis, float angle)
MINLINE float dot_m4_v3_row_y(const float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
void unit_m3(float m[3][3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
MINLINE void copy_v3_fl(float r[3], float f)
void polarview_m4(float mat[4][4], float dist, float azimuth, float incidence, float twist)
MINLINE void sub_v3db_v3fl_v3fl(double r[3], const float a[3], const float b[3])
static bool point_in_slice_as(const float p[3], const float origin[3], const float normal[3])
float dist_squared_to_ray_v3_normalized(const float ray_origin[3], const float ray_direction[3], const float co[3])
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], float t)
void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3])
void lookat_m4(float mat[4][4], float vx, float vy, float vz, float px, float py, float pz, float twist)
MINLINE float max_ff(float a, float b)
bool is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3])
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
float dist_to_plane3_v3(const float p[3], const float plane[3])
float dist_signed_to_plane3_v3(const float p[3], const float plane[3])
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3])
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
bool isect_point_planes_v3_negated(const float(*planes)[4], int totplane, const float p[3])
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
bool clip_segment_v3_plane(const float p1[3], const float p2[3], const float plane[4], float r_p1[3], float r_p2[3])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE double dot_v2v2_db(const double a[2], const double b[2]) ATTR_WARN_UNUSED_RESULT
bool isect_point_planes_v3(const float(*planes)[4], int totplane, const float p[3])
float geodesic_distance_propagate_across_triangle(const float v0[3], const float v1[3], const float v2[3], float dist1, float dist2)
float dist_squared_ray_to_aabb_v3_simple(const float ray_origin[3], const float ray_direction[3], const float bb_min[3], const float bb_max[3], float r_point[3], float *r_depth)
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
float area_squared_tri_v3(const float v1[3], const float v2[3], const float v3[3])
void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3])
void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3])
MINLINE float square_f(float a)
bool isect_tri_tri_v2(const float t_a0[2], const float t_a1[2], const float t_a2[2], const float t_b0[2], const float t_b1[2], const float t_b2[2])
MINLINE bool is_finite_v4(const float v[4]) ATTR_WARN_UNUSED_RESULT
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float xor_fl(float x, int y)
void zero_m3(float m[3][3])
void accumulate_vertex_normals_v3(float n1[3], float n2[3], float n3[3], float n4[3], const float f_no[3], const float co1[3], const float co2[3], const float co3[3], const float co4[3])
float area_squared_poly_v3(const float verts[][3], unsigned int nr)
bool is_edge_convex_v3(const float v1[3], const float v2[3], const float f1_no[3], const float f2_no[3])
bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3])
float dist_squared_ray_to_seg_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], float r_point[3], float *r_depth)
bool isect_ray_tri_epsilon_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], float epsilon)
float volume_tri_tetrahedron_signed_v3(const float v1[3], const float v2[3], const float v3[3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
int is_quad_flip_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v4_fl(float r[4], float f)
float dist_squared_to_projected_aabb(struct DistProjectedAABBPrecalc *data, const float bbmin[3], const float bbmax[3], bool r_axis_closest[3])
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
float line_plane_factor_v3(const float plane_co[3], const float plane_no[3], const float l1[3], const float l2[3])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
float dist_squared_to_line_v2(const float p[2], const float l1[2], const float l2[2])
static bool getLowestRoot(const float a, const float b, const float c, const float maxR, float *root)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
float area_poly_v3(const float verts[][3], unsigned int nr)
float volume_tri_tetrahedron_signed_v3_6x(const float v1[3], const float v2[3], const float v3[3])
float dist_signed_squared_to_plane3_v3(const float p[3], const float plane[3])
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
bool clip_segment_v3_plane_n(const float p1[3], const float p2[3], const float plane_array[][4], int plane_num, float r_p1[3], float r_p2[3])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
bool is_negative_m3(const float mat[3][3])
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
float closest_to_line_segment_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
bool isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], const float axis[3], float angle)
MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
void isect_ray_aabb_v3_precalc(struct IsectRayAABB_Precalc *data, const float ray_origin[3], const float ray_direction[3])
float dist_signed_squared_to_corner_v3v3v3(const float p[3], const float v1[3], const float v2[3], const float v3[3], const float axis_ref[3])
float volume_tetrahedron_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
float determinant_m3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
float dist_squared_ray_to_aabb_v3(const struct DistRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float r_point[3], float *r_depth)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
int isect_line_line_v2_point(const float v0[2], const float v1[2], const float v2[2], const float v3[2], float r_vi[2])
void closest_to_plane3_v3(float r_close[3], const float plane[3], const float pt[3])
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
MINLINE int float_as_int(float f)
float area_poly_signed_v2(const float verts[][2], unsigned int nr)
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[3])
int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float r_i1[3], float r_i2[3])
void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
void tangent_from_uv_v3(const float uv1[2], const float uv2[2], const float uv3[2], const float co1[3], const float co2[3], const float co3[3], const float n[3], float r_tang[3])
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float