24void cross_tri_v3(
float n[3],
const float v1[3],
const float v2[3],
const float v3[3])
28 n1[0] = v1[0] -
v2[0];
29 n2[0] =
v2[0] - v3[0];
30 n1[1] = v1[1] -
v2[1];
31 n2[1] =
v2[1] - v3[1];
32 n1[2] = v1[2] -
v2[2];
33 n2[2] =
v2[2] - v3[2];
34 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
35 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
36 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
39float normal_tri_v3(
float n[3],
const float v1[3],
const float v2[3],
const float v3[3])
43 n1[0] = v1[0] -
v2[0];
44 n2[0] =
v2[0] - v3[0];
45 n1[1] = v1[1] -
v2[1];
46 n2[1] =
v2[1] - v3[1];
47 n1[2] = v1[2] -
v2[2];
48 n2[2] =
v2[2] - v3[2];
49 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
50 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
51 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
57 float n[3],
const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
62 n1[0] = v1[0] - v3[0];
63 n1[1] = v1[1] - v3[1];
64 n1[2] = v1[2] - v3[2];
66 n2[0] =
v2[0] - v4[0];
67 n2[1] =
v2[1] - v4[1];
68 n2[2] =
v2[2] - v4[2];
70 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
71 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
72 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
83float area_quad_v3(
const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
98float area_tri_v3(
const float v1[3],
const float v2[3],
const float v3[3])
116 const float normal[3])
151 const float *co_curr, *co_prev;
154 co_prev =
verts[nr - 1];
157 for (a = 0; a < nr; a++) {
158 cross += (co_prev[0] - co_curr[0]) * (co_curr[1] + co_prev[1]);
168 const float *v_prev =
verts[nr - 1];
169 const float *v_curr =
verts[0];
175 for (i = 0; i < nr; v_prev = v_curr, v_curr =
verts[++i]) {
198 float a[3],
b[3], c[3], c_len;
206 if (c_len > FLT_EPSILON) {
218 r_plane[3] = -
dot_v3v3(r_plane, plane_co);
232 mul_v3_v3fl(r_plane_co, r_plane_no, (-plane[3] / length));
265 float tetra_volume =
dot_v3v3(v_cross, v3);
304 float r_closest_b[2],
313 float intersection[2];
324 float p1[2], p2[2], p3[2], p4[2];
334 const float min_dist_sq =
min_ffff(dist_sq1, dist_sq2, dist_sq3, dist_sq4);
335 if (min_dist_sq == dist_sq1) {
339 *r_lambda_b = lambda1;
341 else if (min_dist_sq == dist_sq2) {
345 *r_lambda_b = lambda2;
347 else if (min_dist_sq == dist_sq3) {
350 *r_lambda_a = lambda3;
357 *r_lambda_a = lambda4;
373 if (lambda <= 0.0f) {
377 if (lambda >= 1.0f) {
395 if (lambda <= 0.0f) {
399 if (lambda >= 1.0f) {
408 const float ray_direction[3],
419 if (lambda <= 0.0f) {
424 if (lambda >= 1.0f) {
450 const float side =
dot_v3v3(plane, pt);
456 const float side =
dot_v3v3(plane, pt);
465 const float fac = side / len_sq;
466 return copysignf(len_sq * (fac * fac), side);
472 const float fac = side / len_sq;
474 return len_sq * (fac * fac);
480 const float side =
dot_v3v3(plane, p);
481 const float fac = side / len_sq;
482 return copysignf(len_sq * (fac * fac), side);
487 const float side =
dot_v3v3(plane, p);
488 const float fac = side / len_sq;
490 return len_sq * (fac * fac);
497 const float fac = side / len_sq;
498 return sqrtf(len_sq) * fac;
508 const float side =
dot_v3v3(plane, p);
509 const float fac = side / len_sq;
510 return sqrtf(len_sq) * fac;
548 const float axis_ref[3])
550 float dir_a[3], dir_b[3];
551 float plane_a[3], plane_b[3];
552 float dist_a, dist_b;
565 else if (
dot_v3v3(axis, axis_ref) < 0.0f) {
589 return min_ff(dist_a, dist_b);
592 return max_ff(dist_a, dist_b);
596 const float ray_direction[3],
599 float origin_to_co[3];
602 float origin_to_proj[3];
605 float co_projected_on_ray[3];
606 add_v3_v3v3(co_projected_on_ray, ray_origin, origin_to_proj);
612 const float ray_direction[3],
620 if (lambda <= 0.0f) {
623 else if (lambda >= 1.0f) {
638 depth =
dot_v3v3(dvec, ray_direction);
648 const float bbmin[3],
649 const float bbmax[3],
653 if (plane_no[0] < 0.0f) {
654 bb_near[0] = bbmax[0];
655 bb_afar[0] = bbmin[0];
658 bb_near[0] = bbmin[0];
659 bb_afar[0] = bbmax[0];
661 if (plane_no[1] < 0.0f) {
662 bb_near[1] = bbmax[1];
663 bb_afar[1] = bbmin[1];
666 bb_near[1] = bbmin[1];
667 bb_afar[1] = bbmax[1];
669 if (plane_no[2] < 0.0f) {
670 bb_near[2] = bbmax[2];
671 bb_afar[2] = bbmin[2];
674 bb_near[2] = bbmin[2];
675 bb_afar[2] = bbmax[2];
684 const float ray_direction[3])
687 copy_v3_v3(nearest_precalc.ray_origin, ray_origin);
688 copy_v3_v3(nearest_precalc.ray_direction, ray_direction);
690 for (
int i = 0; i < 3; i++) {
691 nearest_precalc.ray_inv_dir[i] = (nearest_precalc.ray_direction[i] != 0.0f) ?
692 (1.0f / nearest_precalc.ray_direction[i]) :
695 return nearest_precalc;
699 const float bb_min[3],
700 const float bb_max[3],
705 float local_bvmin[3], local_bvmax[3];
708 const float tmin[3] = {
709 (local_bvmin[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
710 (local_bvmin[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
711 (local_bvmin[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
713 const float tmax[3] = {
714 (local_bvmax[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
715 (local_bvmax[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
716 (local_bvmax[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
724 if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
726 va[0] = vb[0] = local_bvmax[0];
730 else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
732 va[1] = vb[1] = local_bvmax[1];
738 va[2] = vb[2] = local_bvmax[2];
743 if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
745 va[0] = vb[0] = local_bvmin[0];
749 else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
751 va[1] = vb[1] = local_bvmin[1];
757 va[2] = vb[2] = local_bvmin[2];
766 if (rtmin <= rtmax) {
770 *r_depth =
dot_v3v3(dvec, data->ray_direction);
774 if (data->ray_direction[main_axis] >= 0.0f) {
775 va[main_axis] = local_bvmin[main_axis];
776 vb[main_axis] = local_bvmax[main_axis];
779 va[main_axis] = local_bvmax[main_axis];
780 vb[main_axis] = local_bvmin[main_axis];
784 data->ray_origin, data->ray_direction, va, vb, r_point, r_depth);
788 const float ray_direction[3],
789 const float bb_min[3],
790 const float bb_max[3],
805 const float projmat[4][4],
806 const float winsize[2],
809 float win_half[2], relative_mval[2], px[4], py[4];
814 relative_mval[0] = precalc->
mval[0] / win_half[0];
815 relative_mval[1] = precalc->
mval[1] / win_half[1];
818 for (
int i = 0; i < 4; i++) {
819 px[i] = precalc->
pmat[i][0] - precalc->
pmat[i][3] * relative_mval[0];
820 py[i] = precalc->
pmat[i][1] - precalc->
pmat[i][3] * relative_mval[1];
822 precalc->
pmat[i][0] *= win_half[0];
823 precalc->
pmat[i][1] *= win_half[1];
826 float projmat_trans[4][4];
829 projmat_trans[0], projmat_trans[1], projmat_trans[3], precalc->
ray_origin))
849 for (
int i = 0; i < 3; i++) {
857 const float bbmin[3],
858 const float bbmax[3],
859 bool r_axis_closest[3])
861 float local_bvmin[3], local_bvmax[3];
864 const float tmin[3] = {
865 (local_bvmin[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
866 (local_bvmin[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
867 (local_bvmin[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
869 const float tmax[3] = {
870 (local_bvmax[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
871 (local_bvmax[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
872 (local_bvmax[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
880 r_axis_closest[0] =
false;
881 r_axis_closest[1] =
false;
882 r_axis_closest[2] =
false;
884 if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
886 va[0] = vb[0] = local_bvmax[0];
888 r_axis_closest[0] = data->ray_direction[0] < 0.0f;
890 else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
892 va[1] = vb[1] = local_bvmax[1];
894 r_axis_closest[1] = data->ray_direction[1] < 0.0f;
898 va[2] = vb[2] = local_bvmax[2];
900 r_axis_closest[2] = data->ray_direction[2] < 0.0f;
903 if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
905 va[0] = vb[0] = local_bvmin[0];
907 r_axis_closest[0] = data->ray_direction[0] >= 0.0f;
909 else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
911 va[1] = vb[1] = local_bvmin[1];
913 r_axis_closest[1] = data->ray_direction[1] >= 0.0f;
917 va[2] = vb[2] = local_bvmin[2];
919 r_axis_closest[2] = data->ray_direction[2] >= 0.0f;
926 if (rtmin <= rtmax) {
930 if (data->ray_direction[main_axis] >= 0.0f) {
931 va[main_axis] = local_bvmin[main_axis];
932 vb[main_axis] = local_bvmax[main_axis];
935 va[main_axis] = local_bvmax[main_axis];
936 vb[main_axis] = local_bvmin[main_axis];
938 float scale =
fabsf(local_bvmax[main_axis] - local_bvmin[main_axis]);
945 (va2d[0] + data->pmat[main_axis][0] * scale),
946 (va2d[1] + data->pmat[main_axis][1] * scale),
952 float w_b = w_a + data->pmat[main_axis][3] * scale;
959 float dvec[2], edge[2], lambda, rdist_sq;
963 if (lambda != 0.0f) {
965 if (lambda <= 0.0f) {
967 r_axis_closest[main_axis] =
true;
969 else if (lambda >= 1.0f) {
971 r_axis_closest[main_axis] =
false;
976 r_axis_closest[main_axis] = lambda < 0.5f;
987 const float winsize[2],
989 const float bbmin[3],
990 const float bbmax[3])
995 bool dummy[3] = {
true,
true,
true};
1001float dist_seg_seg_v2(
const float a1[3],
const float a2[3],
const float b1[3],
const float b2[3])
1014 float r[3],
const float p[3],
const float v1[3],
const float v2[3],
const float v3[3])
1019 float ab[3], ac[3], ap[3], d1, d2;
1020 float bp[3], d3, d4, vc, cp[3], d5, d6, vb, va;
1029 if (d1 <= 0.0f && d2 <= 0.0f) {
1039 if (d3 >= 0.0f && d4 <= d3) {
1045 vc = d1 * d4 - d3 * d2;
1046 if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
1056 if (d6 >= 0.0f && d5 <= d6) {
1062 vb = d5 * d2 - d1 * d6;
1063 if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
1070 va = d3 * d6 - d5 * d4;
1071 if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
1072 w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
1081 denom = 1.0f / (va + vb + vc);
1098 float div, lambda, mu;
1100 div =
float((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
1105 lambda =
float((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1107 mu =
float((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1109 if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
1110 if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
1119 const float v0[2],
const float v1[2],
const float v2[2],
const float v3[2],
float r_vi[2])
1121 float s10[2], s32[2];
1132 r_vi[0] = ((s32[0] * u) - (s10[0] *
v)) / div;
1133 r_vi[1] = ((s32[1] * u) - (s10[1] *
v)) / div;
1143 float div, lambda, mu;
1145 div = (
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]);
1150 lambda = (
float(v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1152 mu = (
float(v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1154 if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
1155 if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
1171 float a_dir[3], b_dir[3], a0b0[3], crs_ab[3];
1182 float a0b1[3], a1b0[3], len_a, len_b, fac1, fac2;
1191 CLAMP(fac1, 0.0f, len_a);
1192 CLAMP(fac2, 0.0f, len_a);
1193 fac_a = (fac1 + fac2) / (2 * len_a);
1202 CLAMP(fac1, 0.0f, len_b);
1203 CLAMP(fac2, 0.0f, len_b);
1204 fac_b = (fac1 + fac2) / (2 * len_b);
1211 float c[3], cray[3];
1215 fac_a =
dot_v3v3(cray, crs_ab) / nlen;
1218 fac_b =
dot_v3v3(cray, crs_ab) / nlen;
1220 CLAMP(fac_a, 0.0f, 1.0f);
1221 CLAMP(fac_b, 0.0f, 1.0f);
1232 const float endpoint_bias,
1235 float s10[2], s32[2], s30[2], d;
1236 const float eps = 1e-6f;
1237 const float endpoint_min = -endpoint_bias;
1238 const float endpoint_max = endpoint_bias + 1.0f;
1252 if ((u >= endpoint_min && u <= endpoint_max) && (
v >= endpoint_min &&
v <= endpoint_max)) {
1270 if (
v >= endpoint_min &&
v <= endpoint_max) {
1311 std::swap(u_a, u_b);
1314 if (u_a > endpoint_max || u_b < endpoint_min) {
1330 const float v0[2],
const float v1[2],
const float v2[2],
const float v3[2],
float r_vi[2])
1332 const float endpoint_bias = 1e-6f;
1341#define CCW(A, B, C) ((C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0]))
1355 double div, lambda, mu;
1357 div = (
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]);
1358 if (
fabs(div) < DBL_EPSILON) {
1362 lambda = ((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1364 mu = ((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1373 if (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0) {
1374 if (lambda == 0.0 || lambda == 1.0 || mu == 0.0 || mu == 1.0) {
1398 const float ldir[3] = {
1406 const float b = 2.0f * (ldir[0] * (l1[0] - sp[0]) + ldir[1] * (l1[1] - sp[1]) +
1407 ldir[2] * (l1[2] - sp[2]));
1411 const float i =
b *
b - 4.0f * a * c;
1421 mu = -
b / (2.0f * a);
1426 const float i_sqrt =
sqrtf(i);
1429 mu = (-
b + i_sqrt) / (2.0f * a);
1433 mu = (-
b - i_sqrt) / (2.0f * a);
1451 const float ldir[2] = {l2[0] - l1[0], l2[1] - l1[1]};
1453 const float a =
dot_v2v2(ldir, ldir);
1455 const float b = 2.0f * (ldir[0] * (l1[0] - sp[0]) + ldir[1] * (l1[1] - sp[1]));
1459 const float i =
b *
b - 4.0f * a * c;
1469 mu = -
b / (2.0f * a);
1474 const float i_sqrt =
sqrtf(i);
1477 mu = (-
b + i_sqrt) / (2.0f * a);
1481 mu = (-
b - i_sqrt) / (2.0f * a);
1496 for (i = 0, j = nr - 1; i < nr; j = i++) {
1497 if (((
verts[i][1] > pt[1]) != (
verts[j][1] > pt[1])) &&
1513 for (i = 0, j = nr - 1; i < nr; j = i++) {
1514 if (((
verts[i][1] > pt[1]) != (
verts[j][1] > pt[1])) &&
1548 if (side12 >= 0.0f && side23 >= 0.0f && side31 >= 0.0f) {
1551 if (side12 <= 0.0f && side23 <= 0.0f && side31 <= 0.0f) {
1559 const float p[2],
const float v1[2],
const float v2[2],
const float v3[2],
const float v4[2])
1565 if (side12 >= 0.0f && side23 >= 0.0f && side34 >= 0.0f && side41 >= 0.0f) {
1568 if (side12 <= 0.0f && side23 <= 0.0f && side34 <= 0.0f && side41 <= 0.0f) {
1583 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1600 if ((u < 0.0f) || (u > 1.0f)) {
1607 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1612 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
1631 const float epsilon)
1634 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1651 if ((u < -epsilon) || (u > 1.0f + epsilon)) {
1658 if ((
v < -epsilon) || ((u +
v) > 1.0f + epsilon)) {
1663 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
1676 const float ray_direction[3],
1685 const float epsilon = 0.00000001f;
1686 float p[3], s[3], e1[3], e2[3], q[3];
1694 if ((a > -epsilon) && (a < epsilon)) {
1702 if ((u < 0.0f) || (u > 1.0f)) {
1709 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1714 if (*r_lambda < 0.0f) {
1727 const float ray_direction[3],
1728 const float plane_co[3],
1729 const float plane_no[3],
1743 const float ray_direction[3],
1744 const float plane[4],
1748 float plane_co[3], plane_no[3];
1753 if (clip && (*r_lambda < 0.0f)) {
1760 const float ray_direction[3],
1766 const float epsilon)
1768 float p[3], s[3], e1[3], e2[3], q[3];
1784 if ((u < -epsilon) || (u > 1.0f + epsilon)) {
1791 if ((
v < -epsilon) || ((u +
v) > 1.0f + epsilon)) {
1796 if (*r_lambda < 0.0f) {
1809 const float ray_direction[3])
1815 int kx = (kz != 2) ? (kz + 1) : 0;
1816 int ky = (kx != 2) ? (kx + 1) : 0;
1819 if (ray_direction[kz] < 0.0f) {
1824 inv_dir_z = 1.0f / ray_direction[kz];
1825 isect_precalc->
sx = ray_direction[kx] * inv_dir_z;
1826 isect_precalc->
sy = ray_direction[ky] * inv_dir_z;
1827 isect_precalc->
sz = inv_dir_z;
1830 isect_precalc->
kx = kx;
1831 isect_precalc->
ky = ky;
1832 isect_precalc->
kz = kz;
1843 const int kx = isect_precalc->
kx;
1844 const int ky = isect_precalc->
ky;
1845 const int kz = isect_precalc->
kz;
1846 const float sx = isect_precalc->
sx;
1847 const float sy = isect_precalc->
sy;
1848 const float sz = isect_precalc->
sz;
1851 const float a[3] = {v0[0] - ray_origin[0], v0[1] - ray_origin[1], v0[2] - ray_origin[2]};
1852 const float b[3] = {v1[0] - ray_origin[0], v1[1] - ray_origin[1], v1[2] - ray_origin[2]};
1853 const float c[3] = {
v2[0] - ray_origin[0],
v2[1] - ray_origin[1],
v2[2] - ray_origin[2]};
1855 const float a_kx = a[kx], a_ky = a[ky], a_kz = a[kz];
1856 const float b_kx =
b[kx], b_ky =
b[ky], b_kz =
b[kz];
1857 const float c_kx = c[kx], c_ky = c[ky], c_kz = c[kz];
1860 const float ax = a_kx - sx * a_kz;
1861 const float ay = a_ky - sy * a_kz;
1862 const float bx = b_kx - sx * b_kz;
1863 const float by = b_ky - sy * b_kz;
1864 const float cx = c_kx - sx * c_kz;
1865 const float cy = c_ky - sy * c_kz;
1868 const float u = cx * by - cy * bx;
1869 const float v = ax * cy - ay * cx;
1870 const float w = bx * ay - by * ax;
1873 if ((u < 0.0f ||
v < 0.0f ||
w < 0.0f) && (u > 0.0f ||
v > 0.0f ||
w > 0.0f)) {
1879 if (
UNLIKELY(det == 0.0f || !isfinite(det))) {
1887 const float t = (u * a_kz +
v * b_kz +
w * c_kz) * sz;
1888 const float sign_t =
xor_fl(t, sign_det);
1902 const float inv_det = 1.0f / det;
1904 r_uv[0] = u * inv_det;
1905 r_uv[1] =
v * inv_det;
1907 *r_lambda = t * inv_det;
1912 const float ray_direction[3],
1930 const float ray_direction[3],
1936 const float threshold)
1938 const float epsilon = 0.00000001f;
1939 float p[3], s[3], e1[3], e2[3], q[3];
1948 if ((a > -epsilon) && (a < epsilon)) {
1957 if (*r_lambda < 0.0f) {
1964 if (u > 0 &&
v > 0 && u +
v > 1) {
1965 float t = (u +
v - 1) / 2;
2008 const float ray_direction[2],
2014 float v0_local[2], v1_local[2];
2026 const float p[2] = {(ray_direction[0] *
v) / det, (ray_direction[1] *
v) / det};
2028 const float t = (
dot_v2v2(p, ray_direction) /
dot_v2v2(ray_direction, ray_direction));
2029 if ((t >= 0.0f) == 0) {
2036 if ((u >= 0.0f && u <= 1.0f) == 0) {
2054 const float ray_direction[3],
2059 float a[3], t[3], n[3];
2070 float c[3], cray[3];
2074 *r_lambda =
dot_v3v3(cray, n) / nlen;
2083 for (i = 0; i < totplane; i++) {
2094 for (
int i = 0; i < totplane; i++) {
2106 const float plane_co[3],
2107 const float plane_no[3])
2127 const float plane_b[4],
2128 const float plane_c[4],
2129 float r_isect_co[3])
2160 const float plane_b[4],
2161 float r_isect_co[3],
2162 float r_isect_no[3])
2164 float det, plane_c[3];
2194 const float planes[][4],
2195 const int planes_len,
2196 const float eps_coplanar,
2197 const float eps_isect,
2198 void (*callback_fn)(
const float co[3],
int i,
int j,
int k,
void *user_data),
2203 float n1n2[3], n2n3[3], n3n1[3];
2205 for (
int i = 0; i < planes_len; i++) {
2206 const float *n1 = planes[i];
2207 for (
int j = i + 1; j < planes_len; j++) {
2208 const float *n2 = planes[j];
2213 for (
int k = j + 1; k < planes_len; k++) {
2214 const float *n3 = planes[k];
2224 const float quotient = -
dot_v3v3(n1, n2n3);
2225 if (
fabsf(quotient) < eps_coplanar) {
2228 const float co_test[3] = {
2229 ((n2n3[0] * n1[3]) + (n3n1[0] * n2[3]) + (n1n2[0] * n3[3])) / quotient,
2230 ((n2n3[1] * n1[3]) + (n3n1[1] * n2[3]) + (n1n2[1] * n3[3])) / quotient,
2231 ((n2n3[2] * n1[3]) + (n3n1[2] * n2[3]) + (n1n2[2] * n3[3])) / quotient,
2234 for (i_test = 0; i_test < planes_len; i_test++) {
2235 const float *np_test = planes[i_test];
2236 if ((
dot_v3v3(np_test, co_test) + np_test[3]) > eps_isect) {
2238 if (!
ELEM(i_test, i, j, k)) {
2244 if (i_test == planes_len) {
2245 callback_fn(co_test, i, j, k, user_data);
2256 const float tri_b[3][3],
2259 int *r_tri_a_edge_isect_count)
2270 double ba[3], bc[3], plane_a[4], plane_b[4];
2271 *r_tri_a_edge_isect_count = 0;
2281 if (!side[1][0] && !side[1][1] && !side[1][2]) {
2286 if ((side[1][0] && side[1][1] && side[1][2]) && (side[1][0] < 0.0f) == (side[1][1] < 0.0f) &&
2287 (side[1][0] < 0.0f) == (side[1][2] < 0.0f))
2302 if ((side[0][0] && side[0][1] && side[0][2]) && (side[0][0] < 0.0f) == (side[0][1] < 0.0f) &&
2303 (side[0][0] < 0.0f) == (side[0][2] < 0.0f))
2311 double isect_dir[3];
2313 for (
int i = 0; i < 2; i++) {
2314 const float(*tri)[3] = i == 0 ? tri_a : tri_b;
2318 if ((side[i][0] && side[i][1]) && (side[i][0] < 0.0f) == (side[i][1] < 0.0f)) {
2323 else if ((side[i][1] && side[i][2]) && (side[i][1] < 0.0f) == (side[i][2] < 0.0f)) {
2335 float sidec = side[i][tri_i[1]];
2339 float fac0 = sidec / (sidec - side[i][tri_i[0]]);
2340 float fac1 = sidec / (sidec - side[i][tri_i[2]]);
2341 double offset0 = fac0 * (dot_a - dot_b);
2342 double offset1 = fac1 * (dot_c - dot_b);
2343 if (offset0 > offset1) {
2345 std::swap(offset0, offset1);
2346 std::swap(fac0, fac1);
2347 std::swap(tri_i[0], tri_i[2]);
2350 range[i].min =
float(dot_b + offset0);
2351 range[i].max =
float(dot_b + offset1);
2352 interp_v3_v3v3(range[i].loc[0], tri[tri_i[1]], tri[tri_i[0]], fac0);
2353 interp_v3_v3v3(range[i].loc[1], tri[tri_i[1]], tri[tri_i[2]], fac1);
2356 range[i].min = range[i].max =
float(dot_b);
2362 if ((range[0].max > range[1].
min) && (range[0].
min < range[1].max)) {
2366 if (range[0].
min >= range[1].
min) {
2368 if (range[0].max <= range[1].max) {
2370 *r_tri_a_edge_isect_count = 2;
2374 *r_tri_a_edge_isect_count = 1;
2378 if (range[0].max <= range[1].max) {
2381 *r_tri_a_edge_isect_count = 1;
2395 const float t_a1[3],
2396 const float t_a2[3],
2397 const float t_b0[3],
2398 const float t_b1[3],
2399 const float t_b2[3],
2403 float tri_a[3][3], tri_b[3][3];
2424 const float t_a1[2],
2425 const float t_a2[2],
2426 const float t_b0[2],
2427 const float t_b1[2],
2428 const float t_b2[2])
2487 const float t_a1[2],
2488 const float t_a2[2],
2489 const float t_b0[2],
2490 const float t_b1[2],
2491 const float t_b2[2])
2535 const float t_a1[2],
2536 const float t_a2[2],
2537 const float t_b0[2],
2538 const float t_b1[2],
2539 const float t_b2[2])
2569 const float t_a1[2],
2570 const float t_a2[2],
2571 const float t_b0[2],
2572 const float t_b1[2],
2573 const float t_b2[2])
2596 const float a,
const float b,
const float c,
const float maxR,
float *root)
2606 float r1 = (-
b - sqrtD) / (2.0f * a);
2607 float r2 = (-
b + sqrtD) / (2.0f * a);
2615 if (r1 > 0.0f && r1 < maxR) {
2622 if (r2 > 0.0f && r2 < maxR) {
2633 const float bbmin[3],
2634 const float bbmax[3])
2638 float bb_near[3], bb_far[3];
2639 for (
int i = 0; i < totplane; i++) {
2662 float e1[3], e2[3], e3[3], point[3], vel[3],
nor[3], temp[3], bv[3];
2663 float a,
b, c, d,
e,
x,
y,
z, radius2 = radius * radius;
2664 float elen2, edotv, edotbv, nordotv;
2666 bool found_by_sweep =
false;
2684 if (
fabsf(nordotv) < 0.000001f) {
2685 if (
fabsf(a) >= radius) {
2690 float t0 = (-a + radius) / nordotv;
2691 float t1 = (-a - radius) / nordotv;
2697 if (t0 > 1.0f || t1 < 0.0f) {
2702 CLAMP(t0, 0.0f, 1.0f);
2708 point[0] = p1[0] + vel[0] * t0 -
nor[0] * radius;
2709 point[1] = p1[1] + vel[1] * t0 -
nor[1] * radius;
2710 point[2] = p1[2] + vel[2] * t0 -
nor[2] * radius;
2723 z = x + y - (a * c -
b *
b);
2725 if (
z <= 0.0f && (x >= 0.0f && y >= 0.0f)) {
2741 c =
dot_v3v3(temp, temp) - radius2;
2745 found_by_sweep =
true;
2751 c =
dot_v3v3(temp, temp) - radius2;
2755 found_by_sweep =
true;
2761 c =
dot_v3v3(temp, temp) - radius2;
2765 found_by_sweep =
true;
2778 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2779 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2780 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2783 e = (edotv * newLambda - edotbv) / elen2;
2785 if (
e >= 0.0f &&
e <= 1.0f) {
2786 *r_lambda = newLambda;
2790 found_by_sweep =
true;
2800 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2801 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2802 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2805 e = (edotv * newLambda - edotbv) / elen2;
2807 if (
e >= 0.0f &&
e <= 1.0f) {
2808 *r_lambda = newLambda;
2812 found_by_sweep =
true;
2827 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2828 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2829 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2832 e = (edotv * newLambda - edotbv) / elen2;
2834 if (
e >= 0.0f &&
e <= 1.0f) {
2835 *r_lambda = newLambda;
2839 found_by_sweep =
true;
2843 return found_by_sweep;
2854 const float epsilon = 0.000001f;
2855 float p[3], e1[3], e2[3];
2857 int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3;
2863 f = (e2[a1] * e1[a2] - e2[a2] * e1[a1]);
2864 if ((f > -epsilon) && (f < epsilon)) {
2868 v = (p[a2] * e1[a1] - p[a1] * e1[a2]) / f;
2869 if ((
v < 0.0f) || (
v > 1.0f)) {
2874 if ((f > -epsilon) && (f < epsilon)) {
2876 if ((f > -epsilon) && (f < epsilon)) {
2879 u = (-p[a2] -
v * e2[a2]) / f;
2882 u = (-p[a1] -
v * e2[a1]) / f;
2885 if ((u < 0.0f) || ((u +
v) > 1.0f)) {
2889 *r_lambda = (p[a0] + u * e1[a0] +
v * e2[a0]) / (p2[a0] - p1[a0]);
2891 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
2904 const float epsilon)
2906 float a[3],
b[3], c[3], ab[3], cb[3];
2935 float v3t[3], v4t[3];
2969 const float epsilon = 0.000001f;
2980 const float epsilon = 0.000001f;
2981 float a[3],
b[3], c[3], ab[3], cb[3], ca[3];
3009 if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
3024 const float ray_direction_a[3],
3025 const float ray_origin_b[3],
3026 const float ray_direction_b[3],
3027 const float epsilon,
3042 float t[3], c[3], cray[3];
3046 if (r_lambda_a !=
nullptr) {
3048 *r_lambda_a =
dot_v3v3(cray, n) / nlen;
3051 if (r_lambda_b !=
nullptr) {
3053 *r_lambda_b =
dot_v3v3(cray, n) / nlen;
3060 const float ray_direction_a[3],
3061 const float ray_origin_b[3],
3062 const float ray_direction_b[3],
3076 const float max1[3],
3077 const float min2[3],
3078 const float max2[3])
3080 return (min1[0] < max2[0] && min1[1] < max2[1] && min1[2] < max2[2] && min2[0] < max1[0] &&
3081 min2[1] < max1[1] && min2[2] < max1[2]);
3085 const float ray_origin[3],
3086 const float ray_direction[3])
3090 data->ray_inv_dir[0] = 1.0f / ray_direction[0];
3091 data->ray_inv_dir[1] = 1.0f / ray_direction[1];
3092 data->ray_inv_dir[2] = 1.0f / ray_direction[2];
3094 data->sign[0] = data->ray_inv_dir[0] < 0.0f;
3095 data->sign[1] = data->ray_inv_dir[1] < 0.0f;
3096 data->sign[2] = data->ray_inv_dir[2] < 0.0f;
3100 const float bb_min[3],
3101 const float bb_max[3],
3111 float tmin = (bbox[data->sign[0]][0] - data->ray_origin[0]) * data->ray_inv_dir[0];
3112 float tmax = (bbox[1 - data->sign[0]][0] - data->ray_origin[0]) * data->ray_inv_dir[0];
3114 const float tymin = (bbox[data->sign[1]][1] - data->ray_origin[1]) * data->ray_inv_dir[1];
3115 const float tymax = (bbox[1 - data->sign[1]][1] - data->ray_origin[1]) * data->ray_inv_dir[1];
3117 if ((tmin > tymax) || (tymin > tmax)) {
3129 const float tzmin = (bbox[data->sign[2]][2] - data->ray_origin[2]) * data->ray_inv_dir[2];
3130 const float tzmax = (bbox[1 - data->sign[2]][2] - data->ray_origin[2]) * data->ray_inv_dir[2];
3132 if ((tmin > tzmax) || (tzmin > tmax)) {
3153 const float bb_min[3],
3154 const float bb_max[3],
3160 const double invdirx = (dir[0] > 1e-35f || dir[0] < -1e-35f) ? 1.0 /
double(dir[0]) : DBL_MAX;
3161 const double invdiry = (dir[1] > 1e-35f || dir[1] < -1e-35f) ? 1.0 /
double(dir[1]) : DBL_MAX;
3162 const double invdirz = (dir[2] > 1e-35f || dir[2] < -1e-35f) ? 1.0 /
double(dir[2]) : DBL_MAX;
3163 t[0] =
double(bb_min[0] - orig[0]) * invdirx;
3164 t[1] =
double(bb_max[0] - orig[0]) * invdirx;
3165 t[2] =
double(bb_min[1] - orig[1]) * invdiry;
3166 t[3] =
double(bb_max[1] - orig[1]) * invdiry;
3167 t[4] =
double(bb_min[2] - orig[2]) * invdirz;
3168 t[5] =
double(bb_max[2] - orig[2]) * invdirz;
3169 hit_dist[0] =
float(fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5])));
3170 hit_dist[1] =
float(fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5])));
3171 if ((hit_dist[1] < 0.0f) || (hit_dist[0] > hit_dist[1])) {
3176 *tmin = hit_dist[0];
3179 *tmax = hit_dist[1];
3186 const float ray_orig[3],
3187 const float ray_dir[3])
3212 float h[2], u[2], lambda, denom;
3216 if (denom == 0.0f) {
3222 r_close[0] = l1[0] + u[0] * lambda;
3223 r_close[1] = l1[1] + u[1] * lambda;
3232 double h[2], u[2], lambda, denom;
3242 r_close[0] = l1[0] + u[0] * lambda;
3243 r_close[1] = l1[1] + u[1] * lambda;
3248 const float ray_origin[3],
3249 const float ray_direction[3],
3250 const float epsilon,
3251 const float fallback)
3253 float p_relative[3];
3256 return (
dot > epsilon) ? (
dot_v3v3(ray_direction, p_relative) /
dot) : fallback;
3260 const float ray_origin[3],
3261 const float ray_direction[3])
3269 const float epsilon,
3270 const float fallback)
3289 const float epsilon,
3290 const float fallback)
3307 const float plane_no[3],
3323 if (dist_old > dist) {
3326 float fac = (dist / dist_old) * 0.5f;
3337 const int x1,
const int y1,
const int x2,
const int y2,
const int a,
const int b)
3339 float v1[2],
v2[2], v3[2], p[2];
3371 float h, rp[3], cp[3], q[3];
3380 return (h >= 0.0f && h <= 1.0f);
3390 if (h < 0.0f || h > 1.0f) {
3423 const float p[3],
const float v1[3],
const float v2[3],
const float v3[3],
float r_isect_co[3])
3443 const float p1[3],
const float p2[3],
const float plane[4],
float r_p1[3],
float r_p2[3])
3463 const float p1_copy[3] = {
UNPACK3(p1)};
3475 const float p1_copy[3] = {
UNPACK3(p1)};
3483 const float p1_copy[3] = {
UNPACK3(p1)};
3491 const float plane_array[][4],
3492 const int plane_num,
3497 float p1_fac = 0.0f, p2_fac = 1.0f;
3502 for (
int i = 0; i < plane_num; i++) {
3503 const float *plane = plane_array[i];
3504 const float div =
dot_v3v3(dp, plane);
3517 if (p1_fac > p2_fac) {
3523 else if (div < 0.0f) {
3532 if (p1_fac > p2_fac) {
3542 const float p1_copy[3] = {
UNPACK3(p1)};
3588 const float v1[3],
const float v2[3],
const float v3[3],
const int i,
const int j)
3590 return 0.5f * ((v1[i] -
v2[i]) * (
v2[j] - v3[j]) + (v1[j] -
v2[j]) * (v3[i] -
v2[i]));
3612 wtot =
w[0] +
w[1] +
w[2];
3629 float w[3],
const float v1[3],
const float v2[3],
const float v3[3],
const float co[3])
3663 float n1[3], n2[3], n[3];
3671 std::swap(
w[2],
w[3]);
3673 if (!ok || (
w[0] < 0.0f)) {
3703 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3705 const float x = co[0], y = co[1];
3706 const float x1 = v1[0], y1 = v1[1];
3707 const float x2 =
v2[0], y2 =
v2[1];
3708 const float x3 = v3[0], y3 = v3[1];
3709 const float det = (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3);
3715 w[0] = ((y2 - y3) * (x - x3) + (x3 - x2) * (y - y3)) / det;
3716 w[1] = ((y3 - y1) * (x - x3) + (x1 - x3) * (y - y3)) / det;
3717 w[2] = 1.0f -
w[0] -
w[1];
3727 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3734 wtot =
w[0] +
w[1] +
w[2];
3750 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3757 wtot =
w[0] +
w[1] +
w[2];
3773 const float v1[4],
const float v2[4],
const float v3[4],
const float co[2],
float w[3])
3780 wtot =
w[0] +
w[1] +
w[2];
3807#define MEAN_VALUE_HALF_TAN_V2(_area, i1, i2) \
3808 ((_area = cross_v2v2(dirs[i1], dirs[i2])) != 0.0f ? \
3809 fabsf(((lens[i1] * lens[i2]) - dot_v2v2(dirs[i1], dirs[i2])) / _area) : \
3812 const float dirs[4][2] = {
3813 {v1[0] - co[0], v1[1] - co[1]},
3814 {
v2[0] - co[0],
v2[1] - co[1]},
3815 {v3[0] - co[0], v3[1] - co[1]},
3816 {v4[0] - co[0], v4[1] - co[1]},
3819 const float lens[4] = {
3827 if (
UNLIKELY(lens[0] < FLT_EPSILON)) {
3829 w[1] =
w[2] =
w[3] = 0.0f;
3831 else if (
UNLIKELY(lens[1] < FLT_EPSILON)) {
3833 w[0] =
w[2] =
w[3] = 0.0f;
3835 else if (
UNLIKELY(lens[2] < FLT_EPSILON)) {
3837 w[0] =
w[1] =
w[3] = 0.0f;
3839 else if (
UNLIKELY(lens[3] < FLT_EPSILON)) {
3841 w[0] =
w[1] =
w[2] = 0.0f;
3849# pragma clang diagnostic push
3850# pragma clang diagnostic ignored "-Wunsequenced"
3854 const float t[4] = {
3862# pragma clang diagnostic pop
3865#undef MEAN_VALUE_HALF_TAN_V2
3867 w[0] = (t[3] + t[0]) / lens[0];
3868 w[1] = (t[0] + t[1]) / lens[1];
3869 w[2] = (t[1] + t[2]) / lens[2];
3870 w[3] = (t[2] + t[3]) / lens[3];
3872 wtot =
w[0] +
w[1] +
w[2] +
w[3];
3889 float const pt_src[3],
3890 const float tri_tar_p1[3],
3891 const float tri_tar_p2[3],
3892 const float tri_tar_p3[3],
3893 const float tri_src_p1[3],
3894 const float tri_src_p2[3],
3895 const float tri_src_p3[3])
3903 float no_tar[3], no_src[3];
3904 float mat_src[3][3];
3906 float tri_xy_src[3][3];
3908 float area_tar, area_src;
3926 area_src =
sqrtf(
area_tri_v2(tri_xy_src[0], tri_xy_src[1], tri_xy_src[2]));
3928 z_ofs_src = pt_src_xy[2] - tri_xy_src[0][2];
3929 madd_v3_v3v3fl(pt_tar, pt_tar, no_tar, (z_ofs_src / area_src) * area_tar);
3933 const float p_src[3],
3934 const float l_dst_p1[3],
3935 const float l_dst_p2[3],
3936 const float l_src_p1[3],
3937 const float l_src_p2[3])
3945 int found_invalid = 0;
3946 int found_valid = 0;
3949 for (i = 0; i < list_size; i++) {
3950 if (
array[i] == skipval) {
3958 if (found_valid == 0) {
3961 if (found_invalid == 0) {
3966 float valid_last = skipval;
3975 for (i = 0; i < list_size; i++) {
3976 if (
array[i] == skipval) {
3977 array_up[i] = valid_last;
3978 ofs_tot_up[i] = ++valid_ofs;
3981 valid_last =
array[i];
3986 valid_last = skipval;
3989 for (i = list_size - 1; i >= 0; i--) {
3990 if (
array[i] == skipval) {
3991 array_down[i] = valid_last;
3992 ofs_tot_down[i] = ++valid_ofs;
3995 valid_last =
array[i];
4001 for (i = 0; i < list_size; i++) {
4002 if (
array[i] == skipval) {
4003 if (array_up[i] != skipval && array_down[i] != skipval) {
4004 array[i] = ((array_up[i] *
float(ofs_tot_down[i])) +
4005 (array_down[i] *
float(ofs_tot_up[i]))) /
4006 float(ofs_tot_down[i] + ofs_tot_up[i]);
4008 else if (array_up[i] != skipval) {
4009 array[i] = array_up[i];
4011 else if (array_down[i] != skipval) {
4012 array[i] = array_down[i];
4024#define IS_POINT_IX (1 << 0)
4025#define IS_SEGMENT_IX (1 << 1)
4027#define DIR_V3_SET(d_len, va, vb) \
4029 sub_v3_v3v3((d_len)->dir, va, vb); \
4030 (d_len)->len = len_v3((d_len)->dir); \
4034#define DIR_V2_SET(d_len, va, vb) \
4036 sub_v2db_v2fl_v2fl((d_len)->dir, va, vb); \
4037 (d_len)->len = len_v2_db((d_len)->dir); \
4057 if (
LIKELY(area != 0.0f)) {
4059 const float len = d_curr->
len * d_next->
len;
4060 const float result = (
len -
dot) / area;
4061 if (isfinite(result)) {
4082 if (
LIKELY(area != 0.0)) {
4084 const double len = d_curr->
len * d_next->
len;
4085 const double result = (
len -
dot) / area;
4086 if (isfinite(result)) {
4097 float max_value = 0;
4099 for (
int i = 0; i < n; i++) {
4107 const float eps = 16.0f * FLT_EPSILON * max_value;
4108 const float eps_sq =
eps *
eps;
4109 const float *v_curr, *v_next;
4111 float totweight = 0.0f;
4127 while (i_next < n) {
4145 w[i_curr] = (ht_prev + ht) / d_curr.
len;
4146 totweight +=
w[i_curr];
4157 memset(
w, 0,
sizeof(*
w) *
size_t(n));
4164 CLAMP(fac, 0.0f, 1.0f);
4165 w[i_curr] = 1.0f - fac;
4170 if (totweight != 0.0f) {
4171 for (i_curr = 0; i_curr < n; i_curr++) {
4172 w[i_curr] /= totweight;
4182 float max_value = 0;
4184 for (
int i = 0; i < n; i++) {
4191 const float eps = 16.0f * FLT_EPSILON * max_value;
4192 const float eps_sq =
eps *
eps;
4194 const float *v_curr, *v_next;
4196 float totweight = 0.0f;
4212 while (i_next < n) {
4230 w[i_curr] = (d_curr.
len == 0.0) ? 0.0f :
float((ht_prev + ht) / d_curr.
len);
4231 totweight +=
w[i_curr];
4242 memset(
w, 0,
sizeof(*
w) *
size_t(n));
4249 CLAMP(fac, 0.0f, 1.0f);
4250 w[i_curr] = 1.0f - fac;
4255 if (totweight != 0.0f) {
4256 for (i_curr = 0; i_curr < n; i_curr++) {
4257 w[i_curr] /= totweight;
4280 const float t2 = t * t;
4281 const float t3 = t2 * t;
4284 a[0] = v1[0] +
v2[0] + 2 * (x1[0] - x2[0]);
4285 a[1] = v1[1] +
v2[1] + 2 * (x1[1] - x2[1]);
4286 a[2] = v1[2] +
v2[2] + 2 * (x1[2] - x2[2]);
4288 b[0] = -2 * v1[0] -
v2[0] - 3 * (x1[0] - x2[0]);
4289 b[1] = -2 * v1[1] -
v2[1] - 3 * (x1[1] - x2[1]);
4290 b[2] = -2 * v1[2] -
v2[2] - 3 * (x1[2] - x2[2]);
4292 x[0] = a[0] * t3 +
b[0] * t2 + v1[0] * t + x1[0];
4293 x[1] = a[1] * t3 +
b[1] * t2 + v1[1] * t + x1[1];
4294 x[2] = a[2] * t3 +
b[2] * t2 + v1[2] * t + x1[2];
4296 v[0] = 3 * a[0] * t2 + 2 *
b[0] * t + v1[0];
4297 v[1] = 3 * a[1] * t2 + 2 *
b[1] * t + v1[1];
4298 v[2] = 3 * a[2] * t2 + 2 *
b[2] * t + v1[2];
4304#define IS_ZERO(x) ((x > (-DBL_EPSILON) && x < DBL_EPSILON) ? 1 : 0)
4307 float r_uv[2],
const float st[2],
const float st0[2],
const float st1[2],
const float st2[2])
4312 const double a = st0[0] - st2[0],
b = st1[0] - st2[0];
4313 const double c = st0[1] - st2[1], d = st1[1] - st2[1];
4314 const double det = a * d - c *
b;
4318 const double x[2] = {st[0] - st2[0], st[1] - st2[1]};
4320 r_uv[0] =
float((d * x[0] -
b * x[1]) / det);
4321 r_uv[1] =
float(((-c) * x[0] + a * x[1]) / det);
4329 float r_uv[2],
const float st[3],
const float st0[3],
const float st1[3],
const float st2[3])
4331 float v0[3], v1[3],
v2[3];
4332 double d00, d01, d11, d20, d21, det;
4344 det = d00 * d11 - d01 * d01;
4350 w =
float((d00 * d21 - d01 * d20) / det);
4351 r_uv[1] =
float((d11 * d20 - d01 * d21) / det);
4352 r_uv[0] = 1.0f - r_uv[1] -
w;
4370 float r_deriv[2][2],
4377 const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) +
4378 (st1[0] * st2[1] - st1[1] * st2[0]) +
4379 (st2[0] * st3[1] - st2[1] * st3[0]) +
4380 (st3[0] * st0[1] - st3[1] * st0[0]);
4384 const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
4388 0.5 *
double(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
4389 ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
4392 const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
4393 double denom = a - 2 *
b + fC;
4399 const double fDen = a - fC;
4401 r_uv[0] =
float(a / fDen);
4405 const double desc_sq =
b *
b - a * fC;
4406 const double desc =
sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
4407 const double s = signed_area > 0 ? (-1.0) : 1.0;
4409 r_uv[0] =
float(((a -
b) + s * desc) / denom);
4415 const double denom_s = (1 - r_uv[0]) * (st0[0] - st3[0]) + r_uv[0] * (st1[0] - st2[0]);
4416 const double denom_t = (1 - r_uv[0]) * (st0[1] - st3[1]) + r_uv[0] * (st1[1] - st2[1]);
4420 if (
fabs(denom_s) <
fabs(denom_t)) {
4426 r_uv[1] =
float(
double((1.0f - r_uv[0]) * (st0[i] - st[i]) + r_uv[0] * (st1[i] - st[i])) /
4432 float tmp1[2], tmp2[2], s[2], t[2];
4445 denom = t[0] * s[1] - t[1] * s[0];
4448 double inv_denom = 1.0 / denom;
4449 r_deriv[0][0] =
float(
double(-t[1]) * inv_denom);
4450 r_deriv[0][1] =
float(
double(t[0]) * inv_denom);
4451 r_deriv[1][0] =
float(
double(s[1]) * inv_denom);
4452 r_deriv[1][1] =
float(
double(-s[0]) * inv_denom);
4463 const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) +
4464 (st1[0] * st2[1] - st1[1] * st2[0]) +
4465 (st2[0] * st3[1] - st2[1] * st3[0]) +
4466 (st3[0] * st0[1] - st3[1] * st0[0]);
4470 const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
4474 0.5 *
double(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
4475 ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
4478 const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
4479 double denom = a - 2 *
b + fC;
4482 const double fDen = a - fC;
4484 return float(a / fDen);
4490 const double desc_sq =
b *
b - a * fC;
4491 const double desc =
sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
4492 const double s = signed_area > 0 ? (-1.0) : 1.0;
4494 return float(((a -
b) + s * desc) / denom);
4537 const float nearClip,
4538 const float farClip)
4540 float Xdelta, Ydelta, Zdelta;
4542 Xdelta = right -
left;
4543 Ydelta = top - bottom;
4544 Zdelta = farClip - nearClip;
4545 if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
4549 mat[0][0] = 2.0f / Xdelta;
4550 mat[3][0] = -(right +
left) / Xdelta;
4551 mat[1][1] = 2.0f / Ydelta;
4552 mat[3][1] = -(top + bottom) / Ydelta;
4553 mat[2][2] = -2.0f / Zdelta;
4554 mat[3][2] = -(farClip + nearClip) / Zdelta;
4562 const float nearClip,
4563 const float farClip)
4565 const float Xdelta = right -
left;
4566 const float Ydelta = top - bottom;
4567 const float Zdelta = farClip - nearClip;
4569 if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
4572 mat[0][0] = nearClip * 2.0f / Xdelta;
4573 mat[1][1] = nearClip * 2.0f / Ydelta;
4574 mat[2][0] = (right +
left) / Xdelta;
4575 mat[2][1] = (top + bottom) / Ydelta;
4576 mat[2][2] = -(farClip + nearClip) / Zdelta;
4578 mat[3][2] = (-2.0f * nearClip * farClip) / Zdelta;
4579 mat[0][1] = mat[0][2] = mat[0][3] = mat[1][0] = mat[1][2] = mat[1][3] = mat[3][0] = mat[3][1] =
4584 const float angle_left,
4585 const float angle_right,
4586 const float angle_up,
4587 const float angle_down,
4588 const float nearClip,
4589 const float farClip)
4591 const float tan_angle_left =
tanf(angle_left);
4592 const float tan_angle_right =
tanf(angle_right);
4593 const float tan_angle_bottom =
tanf(angle_up);
4594 const float tan_angle_top =
tanf(angle_down);
4597 mat, tan_angle_left, tan_angle_right, tan_angle_top, tan_angle_bottom, nearClip, farClip);
4598 mat[0][0] /= nearClip;
4599 mat[1][1] /= nearClip;
4604 if (winmat[2][3] == -1.0f) {
4610 v1[0] = perspmat[0][0];
4611 v1[1] = perspmat[1][0];
4612 v1[2] = perspmat[2][0];
4614 v2[0] = perspmat[0][1];
4615 v2[1] = perspmat[1][1];
4616 v2[2] = perspmat[2][1];
4618 len1 = (1.0f /
len_v3(v1));
4621 winmat[2][0] -= len1 * winmat[0][0] *
x;
4622 winmat[2][1] -= len2 * winmat[1][1] *
y;
4648 left[i] = mat[i][3] + mat[i][0];
4654 right[i] = mat[i][3] - mat[i][0];
4660 bottom[i] = mat[i][3] + mat[i][1];
4666 top[i] = mat[i][3] - mat[i][1];
4672 near[i] = mat[i][3] + mat[i][2];
4678 far[i] = mat[i][3] - mat[i][2];
4691 const bool is_persp = winmat[3][3] == 0.0f;
4693 const float near = winmat[3][2] / (winmat[2][2] - 1.0f);
4694 *r_left = near * ((winmat[2][0] - 1.0f) / winmat[0][0]);
4695 *r_right = near * ((winmat[2][0] + 1.0f) / winmat[0][0]);
4696 *r_bottom = near * ((winmat[2][1] - 1.0f) / winmat[1][1]);
4697 *r_top = near * ((winmat[2][1] + 1.0f) / winmat[1][1]);
4699 *r_far = winmat[3][2] / (winmat[2][2] + 1.0f);
4702 *r_left = (-winmat[3][0] - 1.0f) / winmat[0][0];
4703 *r_right = (-winmat[3][0] + 1.0f) / winmat[0][0];
4704 *r_bottom = (-winmat[3][1] - 1.0f) / winmat[1][1];
4705 *r_top = (-winmat[3][1] + 1.0f) / winmat[1][1];
4706 *r_near = (winmat[3][2] + 1.0f) / winmat[2][2];
4707 *r_far = (winmat[3][2] - 1.0f) / winmat[2][2];
4719 double winmat[4][4];
4722 const bool is_persp = winmat[3][3] == 0.0f;
4724 const double near = winmat[3][2] / (winmat[2][2] - 1.0);
4725 *r_left = near * ((winmat[2][0] - 1.0) / winmat[0][0]);
4726 *r_right = near * ((winmat[2][0] + 1.0) / winmat[0][0]);
4727 *r_bottom = near * ((winmat[2][1] - 1.0) / winmat[1][1]);
4728 *r_top = near * ((winmat[2][1] + 1.0) / winmat[1][1]);
4730 *r_far = winmat[3][2] / (winmat[2][2] + 1.0);
4733 *r_left = (-winmat[3][0] - 1.0) / winmat[0][0];
4734 *r_right = (-winmat[3][0] + 1.0) / winmat[0][0];
4735 *r_bottom = (-winmat[3][1] - 1.0) / winmat[1][1];
4736 *r_top = (-winmat[3][1] + 1.0) / winmat[1][1];
4737 *r_near = (winmat[3][2] + 1.0) / winmat[2][2];
4738 *r_far = (winmat[3][2] - 1.0) / winmat[2][2];
4743 const int win_size[2],
4748 float r_projmat[4][4])
4760 r_projmat[0][0] *= x_sca;
4761 r_projmat[1][1] *= y_sca;
4763 if (projmat[3][3] == 0.0f) {
4764 r_projmat[2][0] = r_projmat[2][0] * x_sca + x_fac;
4765 r_projmat[2][1] = r_projmat[2][1] * y_sca + y_fac;
4768 r_projmat[3][0] = r_projmat[3][0] * x_sca - x_fac;
4769 r_projmat[3][1] = r_projmat[3][1] * y_sca - y_fac;
4778 for (row = 0; row < 4; row++) {
4780 temp[row][
col] = (icand[row][0] * mat[0][
col] + icand[row][1] * mat[1][
col] +
4781 icand[row][2] * mat[2][
col] + icand[row][3] * mat[3][
col]);
4787void polarview_m4(
float mat[4][4],
float dist,
float azimuth,
float incidence,
float twist)
4798 float mat[4][4],
float vx,
float vy,
float vz,
float px,
float py,
float pz,
float twist)
4800 float sine, cosine, hyp, hyp1, dx, dy, dz;
4810 hyp = dx * dx + dz * dz;
4811 hyp1 =
sqrtf(dy * dy + hyp);
4816 cosine = hyp / hyp1;
4822 mat1[1][1] = cosine;
4825 mat1[2][2] = cosine;
4830 mat1[1][1] = mat1[2][2] = 1.0f;
4831 mat1[1][2] = mat1[2][1] = 0.0f;
4842 mat1[0][0] = cosine;
4845 mat1[2][2] = cosine;
4853 float mat[4][4], vec[4];
4854 int a, fl,
flag = -1;
4858 for (a = 0; a < 8; a++) {
4859 vec[0] = (a & 1) ? boundbox[0][0] : boundbox[1][0];
4860 vec[1] = (a & 2) ? boundbox[0][1] : boundbox[1][1];
4861 vec[2] = (a & 4) ? boundbox[0][2] : boundbox[1][2];
4867 if (vec[0] >
bounds[1] * vec[3]) {
4870 if (vec[0] <
bounds[0] * vec[3]) {
4873 if (vec[1] >
bounds[3] * vec[3]) {
4876 if (vec[1] <
bounds[2] * vec[3]) {
4881 if (vec[0] < -vec[3]) {
4884 if (vec[0] > vec[3]) {
4887 if (vec[1] < -vec[3]) {
4890 if (vec[1] > vec[3]) {
4894 if (vec[2] < -vec[3]) {
4897 if (vec[2] > vec[3]) {
4912 float mn[3], mx[3], vec[3];
4918 for (a = 0; a < 8; a++) {
4919 vec[0] = (a & 1) ? boundbox[0][0] : boundbox[1][0];
4920 vec[1] = (a & 2) ? boundbox[0][1] : boundbox[1][1];
4921 vec[2] = (a & 4) ? boundbox[0][2] : boundbox[1][2];
4946 const float epsilon = 0.25f / 65536.0f;
4950 if (1.0f - epsilon < u) {
4956bool map_to_tube(
float *r_u,
float *r_v,
const float x,
const float y,
const float z)
4958 bool regular =
true;
4959 if (x * x + y * y < 1e-6f * 1e-6f) {
4967 *r_v = (
z + 1.0f) / 2.0f;
4971bool map_to_sphere(
float *r_u,
float *r_v,
const float x,
const float y,
const float z)
4973 bool regular =
true;
4974 const float epsilon = 0.25f / 65536.0f;
4975 const float len_xy =
sqrtf(x * x + y * y);
4976 if (len_xy <=
fabsf(
z) * epsilon) {
4990 const float target[3] = {0.0f, 0.0f, 1.0f};
5001 const float axis[3],
5016 const float f_no[3],
5022 const int nverts = 3;
5035 float *vn[] = {n1, n2, n3};
5036 const float *prev_edge = vdiffs[nverts - 1];
5039 for (i = 0; i < nverts; i++) {
5040 const float *cur_edge = vdiffs[i];
5045 prev_edge = cur_edge;
5054 const float f_no[3],
5061 const int nverts = (n4 !=
nullptr && co4 !=
nullptr) ? 4 : 3;
5082 float *vn[] = {n1, n2, n3, n4};
5083 const float *prev_edge = vdiffs[nverts - 1];
5086 for (i = 0; i < nverts; i++) {
5087 const float *cur_edge = vdiffs[i];
5092 prev_edge = cur_edge;
5098 const float polyno[3],
5099 const float **vertcos,
5106 for (i = 0; i < nverts; i++) {
5107 sub_v3_v3v3(vdiffs[i], vertcos[(i + 1) % nverts], vertcos[i]);
5113 const float *prev_edge = vdiffs[nverts - 1];
5115 for (i = 0; i < nverts; i++) {
5116 const float *cur_edge = vdiffs[i];
5124 prev_edge = cur_edge;
5140 const float s1 = uv2[0] - uv1[0];
5141 const float s2 = uv3[0] - uv1[0];
5142 const float t1 = uv2[1] - uv1[1];
5143 const float t2 = uv3[1] - uv1[1];
5144 float det = (s1 * t2 - s2 * t1);
5148 float tangv[3], ct[3], e1[3], e2[3];
5155 r_tang[0] = (t2 * e1[0] - t1 * e2[0]) * det;
5156 r_tang[1] = (t2 * e1[1] - t1 * e2[1]) * det;
5157 r_tang[2] = (t2 * e1[2] - t1 * e2[2]) * det;
5158 tangv[0] = (s1 * e2[0] - s2 * e1[0]) * det;
5159 tangv[1] = (s1 * e2[1] - s2 * e1[1]) * det;
5160 tangv[2] = (s1 * e2[2] - s2 * e1[2]) * det;
5178 const float (*
pos)[3],
5179 const float *weight,
5180 const float (*rpos)[3],
5181 const float *rweight,
5187 float accu_com[3] = {0.0f, 0.0f, 0.0f}, accu_rcom[3] = {0.0f, 0.0f, 0.0f};
5188 float accu_weight = 0.0f, accu_rweight = 0.0f;
5189 const float eps = 1e-6f;
5206 if (
pos && rpos && (list_size > 0)) {
5208 for (a = 0; a < list_size; a++) {
5214 accu_weight += weight[a];
5225 accu_rweight += rweight[a];
5231 if (!weight || !rweight) {
5232 accu_weight = accu_rweight =
float(list_size);
5235 mul_v3_fl(accu_com, 1.0f / accu_weight);
5236 mul_v3_fl(accu_rcom, 1.0f / accu_rweight);
5243 if (lrot || lscale) {
5247 float m[3][3], mr[3][3], q[3][3], qi[3][3];
5248 float va[3], vb[3], stunt[3];
5250 int i = 0, imax = 15;
5255 for (a = 0; a < list_size; a++) {
5260 m[0][0] += va[0] * vb[0];
5261 m[0][1] += va[0] * vb[1];
5262 m[0][2] += va[0] * vb[2];
5264 m[1][0] += va[1] * vb[0];
5265 m[1][1] += va[1] * vb[1];
5266 m[1][2] += va[1] * vb[2];
5268 m[2][0] += va[2] * vb[0];
5269 m[2][1] += va[2] * vb[1];
5270 m[2][2] += va[2] * vb[2];
5275 mr[0][0] += va[0] * va[0];
5276 mr[0][1] += va[0] * va[1];
5277 mr[0][2] += va[0] * va[2];
5279 mr[1][0] += va[1] * va[0];
5280 mr[1][1] += va[1] * va[1];
5281 mr[1][2] += va[1] * va[2];
5283 mr[2][0] += va[2] * va[0];
5284 mr[2][1] += va[2] * va[1];
5285 mr[2][2] += va[2] * va[2];
5298 while ((odet - ndet) * (odet - ndet) >
eps && i < imax) {
5328 const float f1_no[3],
5329 const float f2_no[3])
5357 float v13[3], v24[3];
5369 const float *quad_coords[4] = {v1,
v2, v3, v4};
5370 float quad_proj[4][3];
5372 for (
int i = 0; i < 4; i++) {
5376 float quad_dirs[4][3];
5377 for (
int i = 0, j = 3; i < 4; j = i++) {
5378 sub_v3_v3v3(quad_dirs[i], quad_proj[i], quad_proj[j]);
5383#define CROSS_SIGN(dir_a, dir_b) \
5384 ((void)cross_v3_v3v3(test_dir, dir_a, dir_b), (dot_v3v3(plane, test_dir) > 0.0f))
5402 const float *co_curr, *co_prev;
5403 float dir_curr[2], dir_prev[2];
5405 co_prev =
verts[nr - 1];
5410 for (a = 0; a < nr; a++) {
5420 else if (
cross > 0.0f) {
5424 if (sign_flag == (1 | 2)) {
5439 float d_12[3], d_23[3], d_34[3], d_41[3];
5440 float cross_a[3], cross_b[3];
5450 ret |= ((
dot_v3v3(cross_a, cross_b) < 0.0f) << 0);
5454 ret |= ((
dot_v3v3(cross_a, cross_b) < 0.0f) << 1);
5467 float d_12[3], d_13[3], d_14[3];
5468 float cross_a[3], cross_b[3];
5474 return dot_v3v3(cross_a, cross_b) > 0.0f;
5483 const float eps = 1e-5f;
5485 const float tan_dot =
dot_v3v3(tan_l, tan_r);
5486 if (tan_dot > 1.0f -
eps) {
5488 return (1.0f / 3.0f) * 0.75f;
5490 if (tan_dot < -1.0f +
eps) {
5492 return (1.0f / 2.0f);
5496 const float angle =
acosf(tan_dot) / 2.0f;
5499 const float angle_sin =
sinf(angle);
5500 const float angle_cos =
cosf(angle);
5501 return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
5505 const float v0[3],
const float v1[3],
const float v2[3],
const float dist1,
const float dist2)
5508 float v10[3], v12[3];
5512 if (dist1 != 0.0f && dist2 != 0.0f) {
5514 float u[3],
v[3], n[3];
5517 if (d12 * d12 > 0.0f) {
5527 const float a = 0.5f * (1.0f + (dist1 * dist1 - dist2 * dist2) / (d12 * d12));
5528 const float hh = dist1 * dist1 - a * a * d12 * d12;
5531 const float h =
sqrtf(hh);
5532 const float S_[2] = {a * d12, -h};
5536 const float x_intercept = S_[0] + h * (v0_[0] - S_[0]) / (v0_[1] + h);
5537 if (x_intercept >= 0.0f && x_intercept <= d12) {
MINLINE float max_ff(float a, float b)
MINLINE float min_ffff(float a, float b, float c, float d)
#define BLI_ASSERT_UNIT_EPSILON
MINLINE float min_ff(float a, float b)
MINLINE float square_f(float a)
#define BLI_ASSERT_UNIT_V3(v)
MINLINE int float_as_int(float f)
MINLINE float xor_fl(float x, int 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)
MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
#define ISECT_AABB_PLANE_IN_FRONT_ALL
MINLINE int axis_dominant_v3_single(const float vec[3])
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
#define ISECT_LINE_LINE_NONE
MINLINE float plane_point_side_v3(const float plane[4], const float co[3])
#define ISECT_AABB_PLANE_CROSS_ANY
#define ISECT_AABB_PLANE_BEHIND_ANY
#define ISECT_LINE_LINE_COLINEAR
#define ISECT_LINE_LINE_EXACT
MINLINE void axis_dominant_v3(int *r_axis_a, int *r_axis_b, const float axis[3])
#define ISECT_LINE_LINE_CROSS
bool is_negative_m3(const float mat[3][3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void unit_m3(float m[3][3])
void transpose_m4_m4(float R[4][4], const float M[4][4])
void mul_m3_fl(float R[3][3], float f)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void unit_m4(float m[4][4])
void add_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void zero_m3(float m[3][3])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void copy_m4d_m4(double m1[4][4], const float m2[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
float determinant_m3_array(const float m[3][3])
void mul_m4_v4(const float mat[4][4], float r[4])
void rotate_m4(float mat[4][4], char axis, float angle)
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void transpose_m3(float R[3][3])
float determinant_m3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3)
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
void axis_angle_to_mat4_single(float R[4][4], char axis, float angle)
MINLINE void sub_v3db_v3fl_v3fl(double r[3], const float a[3], const float b[3])
MINLINE void mul_v4_fl(float r[4], float f)
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE double dot_v2v2_db(const double a[2], const double b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float w[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_newell_cross_v3_v3v3(float n[3], const float v_prev[3], const float v_curr[3])
bool is_finite_v4(const float v[4]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], float t)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void rotate_normalized_v3_v3v3fl(float out[3], const float p[3], const float axis[3], float angle)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
bool is_finite_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void negate_v3(float r[3])
MINLINE float dot_m3_v3_row_z(const float M[3][3], const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v4(float r[4])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v2(float r[2])
MINLINE float mul_project_m4_v3_zfac(const float mat[4][4], const float co[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void cross_v3_v3v3_db(double r[3], const double a[3], const double b[3])
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float dot_m4_v3_row_x(const float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void copy_v4_fl(float r[4], float f)
MINLINE float dot_m4_v3_row_y(const float M[4][4], const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float n[3])
MINLINE double cross_v2v2_db(const double a[2], const double b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2_db(double r[2], const double a[2], const double b[2])
#define IN_RANGE(a, b, c)
#define IN_RANGE_INCL(a, b, c)
int rect_width(int rect[2][2])
int rect_height(int rect[2][2])
typedef double(DMatrix)[4][4]
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
btScalar determinant() const
Return the determinant of the matrix.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
local_group_size(16, 16) .push_constant(Type b
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float cross(const float2 a, const float2 b)
ccl_device_inline float2 fabs(const float2 a)
float area_poly_v2(const float verts[][2], uint nr)
int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
bool isect_point_planes_v3(const float(*planes)[4], int totplane, const float p[3])
static double mean_value_half_tan_v2_db(const Double2_Len *d_curr, const Double2_Len *d_next)
bool map_to_sphere(float *r_u, float *r_v, const float x, const float y, const float z)
bool isect_ray_aabb_v3(const IsectRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float *r_tmin)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
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)
float dist_signed_to_plane3_v3(const float p[3], const float plane[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 cross_poly_v2(const float verts[][2], uint nr)
float closest_to_ray_v3(float r_close[3], const float p[3], const float ray_orig[3], const float ray_dir[3])
void window_translate_m4(float winmat[4][4], float perspmat[4][4], const float x, const float y)
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])
float dist_squared_to_line_v3(const float p[3], const float l1[3], const float l2[3])
float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[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])
float line_point_factor_v2_ex(const float p[2], const float l1[2], const float l2[2], const float epsilon, const float fallback)
static bool getLowestRoot(const float a, const float b, const float c, const float maxR, float *root)
float dist_squared_to_plane_v3(const float p[3], const float plane[4])
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)
int barycentric_inside_triangle_v2(const float w[3])
int is_quad_flip_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
float dist_squared_to_plane3_v3(const float p[3], const float plane[3])
bool is_poly_convex_v2(const float verts[][2], uint nr)
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])
bool isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float ipoint[3])
float area_poly_v3(const float verts[][3], uint nr)
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])
float dist_to_plane3_v3(const float p[3], const float plane[3])
void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
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])
float closest_to_line_segment_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
float ray_point_factor_v3(const float p[3], const float ray_origin[3], const float ray_direction[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 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])
double closest_to_line_v2_db(double r_close[2], const double p[2], const double l1[2], const double l2[2])
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], const float epsilon)
void cross_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
bool point_in_slice_seg(float p[3], float l1[3], float l2[3])
static float mean_value_half_tan_v3(const Float3_Len *d_curr, const Float3_Len *d_next)
float dist_to_plane_v3(const float p[3], const float plane[4])
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])
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 polarview_m4(float mat[4][4], float dist, float azimuth, float incidence, float twist)
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)
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])
float area_tri_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float normal[3])
float area_poly_signed_v2(const float verts[][2], uint nr)
float volume_tri_tetrahedron_signed_v3_6x(const float v1[3], const float v2[3], const float v3[3])
void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], const float pt[3])
bool isect_seg_seg_v2_simple(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
#define DIR_V3_SET(d_len, va, vb)
void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], const float pt[3])
int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b)
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)
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])
void interp_weights_tri_v3(float w[3], const float v1[3], const float v2[3], const float v3[3], const float co[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])
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 line_point_factor_v3_ex(const float p[3], const float l1[3], const float l2[3], const float epsilon, const float fallback)
void cross_poly_v3(float n[3], const float verts[][3], uint nr)
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 dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
bool isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3])
void vcloud_estimate_transform_v3(const 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])
static void i_multmatrix(const float icand[4][4], float mat[4][4])
void projmat_from_subregion(const float projmat[4][4], const int win_size[2], const int x_min, const int x_max, const int y_min, const int y_max, float r_projmat[4][4])
float volume_tri_tetrahedron_signed_v3(const float v1[3], const float v2[3], const float v3[3])
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])
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)
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])
void accumulate_vertex_normals_poly_v3(float **vertnos, const float polyno[3], const float **vertcos, float vdiffs[][3], const int nverts)
float normal_poly_v3(float n[3], const float verts[][3], uint nr)
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)
static bool point_in_slice(const float p[3], const float v1[3], const float l1[3], const float l2[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])
#define DIR_V2_SET(d_len, va, vb)
#define MEAN_VALUE_HALF_TAN_V2(_area, i1, i2)
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])
void closest_to_plane3_v3(float r_close[3], const float plane[3], const float pt[3])
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])
void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[2])
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])
float line_point_factor_v2(const float p[2], const float l1[2], const float l2[2])
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)
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])
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])
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])
bool map_to_tube(float *r_u, float *r_v, const float x, const float y, const float z)
void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
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 lookat_m4(float mat[4][4], float vx, float vy, float vz, float px, float py, float pz, float twist)
void axis_dominant_v3_to_m3_negate(float r_mat[3][3], const float normal[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 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])
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])
float line_plane_factor_v3(const float plane_co[3], const float plane_no[3], const float l1[3], const float l2[3])
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])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
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])
bool isect_ray_tri_watertight_v3(const float ray_origin[3], const IsectRayPrecalc *isect_precalc, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
void isect_ray_aabb_v3_precalc(IsectRayAABB_Precalc *data, const float ray_origin[3], const float ray_direction[3])
float dist_seg_seg_v2(const float a1[3], const float a2[3], const float b1[3], const float b2[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])
bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const uint nr)
bool isect_point_poly_v2(const float pt[2], const float verts[][2], const uint nr)
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])
float area_tri_v3(const float v1[3], const float v2[3], const float v3[3])
bool isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
DistRayAABB_Precalc dist_squared_ray_to_aabb_v3_precalc(const float ray_origin[3], const float ray_direction[3])
int isect_line_sphere_v3(const float l1[3], const float l2[3], const float sp[3], const float r, float r_p1[3], float r_p2[3])
bool is_quad_convex_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void dist_squared_to_projected_aabb_precalc(DistProjectedAABBPrecalc *precalc, const float projmat[4][4], const float winsize[2], const float mval[2])
bool is_edge_convex_v3(const float v1[3], const float v2[3], const float f1_no[3], const float f2_no[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])
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
void interp_barycentric_tri_v3(float data[3][3], float u, float v, float res[3])
float volume_tetrahedron_signed_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void perspective_m4_fov(float mat[4][4], const float angle_left, const float angle_right, const float angle_up, const float angle_down, const float nearClip, const float farClip)
float closest_to_line_segment_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
static bool point_in_slice_as(const float p[3], const float origin[3], const float normal[3])
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)
float dist_squared_to_projected_aabb(DistProjectedAABBPrecalc *data, const float bbmin[3], const float bbmax[3], bool r_axis_closest[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], const float t)
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])
float area_squared_tri_v3(const float v1[3], const float v2[3], const float v3[3])
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)
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)
float area_squared_poly_v3(const float verts[][3], uint nr)
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])
int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2], const float r, float r_p1[2], float r_p2[2])
float geodesic_distance_propagate_across_triangle(const float v0[3], const float v1[3], const float v2[3], const float dist1, const float dist2)
int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat[4][4])
bool isect_planes_v3_fn(const float planes[][4], const int planes_len, const float eps_coplanar, const float eps_isect, void(*callback_fn)(const float co[3], int i, int j, int k, void *user_data), void *user_data)
float cubic_tangent_factor_circle_v3(const float tan_l[3], const float tan_r[3])
float dist_squared_ray_to_aabb_v3(const DistRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float r_point[3], float *r_depth)
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
float dist_squared_to_ray_v3_normalized(const float ray_origin[3], const float ray_direction[3], const float co[3])
float area_squared_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
void limit_dist_v3(float v1[3], float v2[3], const float dist)
bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3])
bool clip_segment_v3_plane_n(const float p1[3], const float p2[3], const float plane_array[][4], const int plane_num, float r_p1[3], float r_p2[3])
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_plane_v3(float r_close[3], const float plane[4], const float pt[3])
void plane_to_point_vector_v3(const float plane[4], float r_plane_co[3], float r_plane_no[3])
int isect_seg_seg_v2_point_ex(const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float endpoint_bias, float r_vi[2])
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
void isect_ray_tri_watertight_v3_precalc(IsectRayPrecalc *isect_precalc, const float ray_direction[3])
float area_squared_poly_v2(const float verts[][2], uint nr)
float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
#define CROSS_SIGN(dir_a, dir_b)
float closest_to_line_v3(float r_close[3], const float p[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)
void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3])
bool is_quad_convex_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2])
float cotangent_tri_weight_v3(const float v1[3], const float v2[3], const float v3[3])
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_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], const float epsilon, float *r_lambda_a, float *r_lambda_b)
void barycentric_weights_v2_persp(const float v1[4], const float v2[4], const float v3[4], const float co[2], float w[3])
float dist_to_line_v3(const float p[3], const float l1[3], const float l2[3])
float ray_point_factor_v3_ex(const float p[3], const float ray_origin[3], const float ray_direction[3], const float epsilon, const float fallback)
static float tri_signed_area(const float v1[3], const float v2[3], const float v3[3], const int i, const int j)
float dist_signed_squared_to_plane_v3(const float p[3], const float plane[4])
int interp_sparse_array(float *array, const int list_size, const float skipval)
void orthographic_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
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], const float epsilon)
float dist_squared_to_line_v2(const float p[2], const float l1[2], const float l2[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], const float epsilon)
int isect_seg_seg_v2_int(const int v1[2], const int v2[2], const int v3[2], const int v4[2])
int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2])
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])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
bool isect_axial_line_segment_tri_v3(const 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)
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])
float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
float dist_signed_squared_to_plane3_v3(const float p[3], const float plane[3])
void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[3])
float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2])
void plane_to_point_vector_v3_normalized(const float plane[4], float r_plane_co[3], float r_plane_no[3])
int isect_aabb_planes_v3(const float(*planes)[4], const int totplane, const float bbmin[3], const float bbmax[3])
void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3])
bool isect_point_planes_v3_negated(const float(*planes)[4], const int totplane, const float p[3])
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])
bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3])
void map_to_plane_axis_angle_v2_v3v3fl(float r_co[2], const float co[3], const float axis[3], const float angle)
bool isect_ray_plane_v3(const float ray_origin[3], const float ray_direction[3], const float plane[4], float *r_lambda, const bool clip)
float volume_tetrahedron_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3])
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4])
static float snap_coordinate(float u)
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])
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.
float safe_acos_approx(float x)
Frequency::GEOMETRY nor[]
ccl_device_inline float xor_signmask(float x, int y)