26void cross_tri_v3(
float n[3],
const float v1[3],
const float v2[3],
const float v3[3])
30 n1[0] = v1[0] -
v2[0];
31 n2[0] =
v2[0] - v3[0];
32 n1[1] = v1[1] -
v2[1];
33 n2[1] =
v2[1] - v3[1];
34 n1[2] = v1[2] -
v2[2];
35 n2[2] =
v2[2] - v3[2];
36 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
37 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
38 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
41float normal_tri_v3(
float n[3],
const float v1[3],
const float v2[3],
const float v3[3])
45 n1[0] = v1[0] -
v2[0];
46 n2[0] =
v2[0] - v3[0];
47 n1[1] = v1[1] -
v2[1];
48 n2[1] =
v2[1] - v3[1];
49 n1[2] = v1[2] -
v2[2];
50 n2[2] =
v2[2] - v3[2];
51 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
52 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
53 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
59 float n[3],
const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
64 n1[0] = v1[0] - v3[0];
65 n1[1] = v1[1] - v3[1];
66 n1[2] = v1[2] - v3[2];
68 n2[0] =
v2[0] - v4[0];
69 n2[1] =
v2[1] - v4[1];
70 n2[2] =
v2[2] - v4[2];
72 n[0] = n1[1] * n2[2] - n1[2] * n2[1];
73 n[1] = n1[2] * n2[0] - n1[0] * n2[2];
74 n[2] = n1[0] * n2[1] - n1[1] * n2[0];
85float area_quad_v3(
const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
118 const float normal[3])
153 const float *co_curr, *co_prev;
156 co_prev =
verts[nr - 1];
159 for (a = 0; a < nr; a++) {
160 cross += (co_prev[0] - co_curr[0]) * (co_curr[1] + co_prev[1]);
170 const float *v_prev =
verts[nr - 1];
171 const float *v_curr =
verts[0];
177 for (
i = 0;
i < nr; v_prev = v_curr, v_curr =
verts[++
i]) {
200 float a[3],
b[3], c[3], c_len;
208 if (c_len > FLT_EPSILON) {
220 r_plane[3] = -
dot_v3v3(r_plane, plane_co);
267 float tetra_volume =
dot_v3v3(v_cross, v3);
306 float r_closest_b[2],
315 float intersection[2];
326 float p1[2], p2[2], p3[2], p4[2];
336 const float min_dist_sq =
min_ffff(dist_sq1, dist_sq2, dist_sq3, dist_sq4);
337 if (min_dist_sq == dist_sq1) {
341 *r_lambda_b = lambda1;
343 else if (min_dist_sq == dist_sq2) {
347 *r_lambda_b = lambda2;
349 else if (min_dist_sq == dist_sq3) {
352 *r_lambda_a = lambda3;
359 *r_lambda_a = lambda4;
375 if (lambda <= 0.0f) {
379 if (lambda >= 1.0f) {
397 if (lambda <= 0.0f) {
401 if (lambda >= 1.0f) {
410 const float ray_direction[3],
421 if (lambda <= 0.0f) {
426 if (lambda >= 1.0f) {
452 const float side =
dot_v3v3(plane, pt);
458 const float side =
dot_v3v3(plane, pt);
467 const float fac = side / len_sq;
468 return copysignf(len_sq * (fac * fac), side);
474 const float fac = side / len_sq;
476 return len_sq * (fac * fac);
482 const float side =
dot_v3v3(plane, p);
483 const float fac = side / len_sq;
484 return copysignf(len_sq * (fac * fac), side);
489 const float side =
dot_v3v3(plane, p);
490 const float fac = side / len_sq;
492 return len_sq * (fac * fac);
499 const float fac = side / len_sq;
500 return sqrtf(len_sq) * fac;
510 const float side =
dot_v3v3(plane, p);
511 const float fac = side / len_sq;
512 return sqrtf(len_sq) * fac;
550 const float axis_ref[3])
552 float dir_a[3], dir_b[3];
553 float plane_a[3], plane_b[3];
554 float dist_a, dist_b;
567 else if (
dot_v3v3(axis, axis_ref) < 0.0f) {
591 return min_ff(dist_a, dist_b);
594 return max_ff(dist_a, dist_b);
598 const float ray_direction[3],
601 float origin_to_co[3];
604 float origin_to_proj[3];
607 float co_projected_on_ray[3];
608 add_v3_v3v3(co_projected_on_ray, ray_origin, origin_to_proj);
614 const float ray_direction[3],
622 if (lambda <= 0.0f) {
625 else if (lambda >= 1.0f) {
640 depth =
dot_v3v3(dvec, ray_direction);
650 const float bbmin[3],
651 const float bbmax[3],
655 if (plane_no[0] < 0.0f) {
656 bb_near[0] = bbmax[0];
657 bb_afar[0] = bbmin[0];
660 bb_near[0] = bbmin[0];
661 bb_afar[0] = bbmax[0];
663 if (plane_no[1] < 0.0f) {
664 bb_near[1] = bbmax[1];
665 bb_afar[1] = bbmin[1];
668 bb_near[1] = bbmin[1];
669 bb_afar[1] = bbmax[1];
671 if (plane_no[2] < 0.0f) {
672 bb_near[2] = bbmax[2];
673 bb_afar[2] = bbmin[2];
676 bb_near[2] = bbmin[2];
677 bb_afar[2] = bbmax[2];
686 const float ray_direction[3])
692 for (
int i = 0;
i < 3;
i++) {
697 return nearest_precalc;
701 const float bb_min[3],
702 const float bb_max[3],
707 float local_bvmin[3], local_bvmax[3];
710 const float tmin[3] = {
711 (local_bvmin[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
712 (local_bvmin[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
713 (local_bvmin[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
715 const float tmax[3] = {
716 (local_bvmax[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
717 (local_bvmax[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
718 (local_bvmax[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
726 if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
728 va[0] = vb[0] = local_bvmax[0];
732 else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
734 va[1] = vb[1] = local_bvmax[1];
740 va[2] = vb[2] = local_bvmax[2];
745 if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
747 va[0] = vb[0] = local_bvmin[0];
751 else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
753 va[1] = vb[1] = local_bvmin[1];
759 va[2] = vb[2] = local_bvmin[2];
768 if (rtmin <= rtmax) {
776 if (
data->ray_direction[main_axis] >= 0.0f) {
777 va[main_axis] = local_bvmin[main_axis];
778 vb[main_axis] = local_bvmax[main_axis];
781 va[main_axis] = local_bvmax[main_axis];
782 vb[main_axis] = local_bvmin[main_axis];
786 data->ray_origin,
data->ray_direction, va, vb, r_point, r_depth);
790 const float ray_direction[3],
791 const float bb_min[3],
792 const float bb_max[3],
807 const float projmat[4][4],
808 const float winsize[2],
811 float win_half[2], relative_mval[2], px[4], py[4];
816 relative_mval[0] = precalc->
mval[0] / win_half[0];
817 relative_mval[1] = precalc->
mval[1] / win_half[1];
820 for (
int i = 0;
i < 4;
i++) {
821 px[
i] = precalc->
pmat[
i][0] - precalc->
pmat[
i][3] * relative_mval[0];
822 py[
i] = precalc->
pmat[
i][1] - precalc->
pmat[
i][3] * relative_mval[1];
824 precalc->
pmat[
i][0] *= win_half[0];
825 precalc->
pmat[
i][1] *= win_half[1];
828 float projmat_trans[4][4];
831 projmat_trans[0], projmat_trans[1], projmat_trans[3], precalc->
ray_origin))
851 for (
int i = 0;
i < 3;
i++) {
859 const float bbmin[3],
860 const float bbmax[3],
861 bool r_axis_closest[3])
863 float local_bvmin[3], local_bvmax[3];
866 const float tmin[3] = {
867 (local_bvmin[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
868 (local_bvmin[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
869 (local_bvmin[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
871 const float tmax[3] = {
872 (local_bvmax[0] -
data->ray_origin[0]) *
data->ray_inv_dir[0],
873 (local_bvmax[1] -
data->ray_origin[1]) *
data->ray_inv_dir[1],
874 (local_bvmax[2] -
data->ray_origin[2]) *
data->ray_inv_dir[2],
882 r_axis_closest[0] =
false;
883 r_axis_closest[1] =
false;
884 r_axis_closest[2] =
false;
886 if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
888 va[0] = vb[0] = local_bvmax[0];
890 r_axis_closest[0] =
data->ray_direction[0] < 0.0f;
892 else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
894 va[1] = vb[1] = local_bvmax[1];
896 r_axis_closest[1] =
data->ray_direction[1] < 0.0f;
900 va[2] = vb[2] = local_bvmax[2];
902 r_axis_closest[2] =
data->ray_direction[2] < 0.0f;
905 if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
907 va[0] = vb[0] = local_bvmin[0];
909 r_axis_closest[0] =
data->ray_direction[0] >= 0.0f;
911 else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
913 va[1] = vb[1] = local_bvmin[1];
915 r_axis_closest[1] =
data->ray_direction[1] >= 0.0f;
919 va[2] = vb[2] = local_bvmin[2];
921 r_axis_closest[2] =
data->ray_direction[2] >= 0.0f;
928 if (rtmin <= rtmax) {
932 if (
data->ray_direction[main_axis] >= 0.0f) {
933 va[main_axis] = local_bvmin[main_axis];
934 vb[main_axis] = local_bvmax[main_axis];
937 va[main_axis] = local_bvmax[main_axis];
938 vb[main_axis] = local_bvmin[main_axis];
940 float scale =
fabsf(local_bvmax[main_axis] - local_bvmin[main_axis]);
947 (va2d[0] +
data->pmat[main_axis][0] * scale),
948 (va2d[1] +
data->pmat[main_axis][1] * scale),
954 float w_b = w_a +
data->pmat[main_axis][3] * scale;
961 float dvec[2], edge[2], lambda, rdist_sq;
965 if (lambda != 0.0f) {
967 if (lambda <= 0.0f) {
969 r_axis_closest[main_axis] =
true;
971 else if (lambda >= 1.0f) {
973 r_axis_closest[main_axis] =
false;
978 r_axis_closest[main_axis] = lambda < 0.5f;
989 const float winsize[2],
991 const float bbmin[3],
992 const float bbmax[3])
997 bool dummy[3] = {
true,
true,
true};
1003float dist_seg_seg_v2(
const float a1[3],
const float a2[3],
const float b1[3],
const float b2[3])
1016 float r[3],
const float p[3],
const float v1[3],
const float v2[3],
const float v3[3])
1021 float ab[3], ac[3], ap[3], d1, d2;
1022 float bp[3], d3, d4, vc, cp[3], d5, d6, vb, va;
1031 if (d1 <= 0.0f && d2 <= 0.0f) {
1041 if (d3 >= 0.0f && d4 <= d3) {
1047 vc = d1 * d4 - d3 * d2;
1048 if (vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) {
1058 if (d6 >= 0.0f && d5 <= d6) {
1064 vb = d5 * d2 - d1 * d6;
1065 if (vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) {
1072 va = d3 * d6 - d5 * d4;
1073 if (va <= 0.0f && (d4 - d3) >= 0.0f && (d5 - d6) >= 0.0f) {
1074 w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
1083 denom = 1.0f / (va + vb + vc);
1100 float div, lambda, mu;
1102 div =
float((
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]));
1107 lambda =
float((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1109 mu =
float((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1111 if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
1112 if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
1121 const float v0[2],
const float v1[2],
const float v2[2],
const float v3[2],
float r_vi[2])
1123 float s10[2], s32[2];
1134 r_vi[0] = ((s32[0] * u) - (s10[0] *
v)) / div;
1135 r_vi[1] = ((s32[1] * u) - (s10[1] *
v)) / div;
1145 float div, lambda, mu;
1147 div = (
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]);
1152 lambda = (
float(v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1154 mu = (
float(v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1156 if (lambda >= 0.0f && lambda <= 1.0f && mu >= 0.0f && mu <= 1.0f) {
1157 if (lambda == 0.0f || lambda == 1.0f || mu == 0.0f || mu == 1.0f) {
1173 float a_dir[3], b_dir[3], a0b0[3], crs_ab[3];
1184 float a0b1[3], a1b0[3], len_a, len_b, fac1, fac2;
1193 CLAMP(fac1, 0.0f, len_a);
1194 CLAMP(fac2, 0.0f, len_a);
1195 fac_a = (fac1 + fac2) / (2 * len_a);
1204 CLAMP(fac1, 0.0f, len_b);
1205 CLAMP(fac2, 0.0f, len_b);
1206 fac_b = (fac1 + fac2) / (2 * len_b);
1213 float c[3], cray[3];
1217 fac_a =
dot_v3v3(cray, crs_ab) / nlen;
1220 fac_b =
dot_v3v3(cray, crs_ab) / nlen;
1222 CLAMP(fac_a, 0.0f, 1.0f);
1223 CLAMP(fac_b, 0.0f, 1.0f);
1234 const float endpoint_bias,
1237 float s10[2], s32[2], s30[2], d;
1238 const float eps = 1e-6f;
1239 const float endpoint_min = -endpoint_bias;
1240 const float endpoint_max = endpoint_bias + 1.0f;
1254 if ((u >= endpoint_min && u <= endpoint_max) && (
v >= endpoint_min &&
v <= endpoint_max)) {
1272 if (
v >= endpoint_min &&
v <= endpoint_max) {
1313 std::swap(u_a, u_b);
1316 if (u_a > endpoint_max || u_b < endpoint_min) {
1332 const float v0[2],
const float v1[2],
const float v2[2],
const float v3[2],
float r_vi[2])
1334 const float endpoint_bias = 1e-6f;
1343#define CCW(A, B, C) ((C[1] - A[1]) * (B[0] - A[0]) > (B[1] - A[1]) * (C[0] - A[0]))
1357 double div, lambda, mu;
1359 div = (
v2[0] - v1[0]) * (v4[1] - v3[1]) - (
v2[1] - v1[1]) * (v4[0] - v3[0]);
1360 if (
fabs(div) < DBL_EPSILON) {
1364 lambda = ((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
1366 mu = ((v1[1] - v3[1]) * (
v2[0] - v1[0]) - (v1[0] - v3[0]) * (
v2[1] - v1[1])) / div;
1375 if (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0) {
1376 if (lambda == 0.0 || lambda == 1.0 || mu == 0.0 || mu == 1.0) {
1400 const float ldir[3] = {
1408 const float b = 2.0f * (ldir[0] * (l1[0] - sp[0]) + ldir[1] * (l1[1] - sp[1]) +
1409 ldir[2] * (l1[2] - sp[2]));
1413 const float i =
b *
b - 4.0f * a * c;
1423 mu = -
b / (2.0f * a);
1428 const float i_sqrt =
sqrtf(
i);
1431 mu = (-
b + i_sqrt) / (2.0f * a);
1435 mu = (-
b - i_sqrt) / (2.0f * a);
1453 const float ldir[2] = {l2[0] - l1[0], l2[1] - l1[1]};
1455 const float a =
dot_v2v2(ldir, ldir);
1457 const float b = 2.0f * (ldir[0] * (l1[0] - sp[0]) + ldir[1] * (l1[1] - sp[1]));
1461 const float i =
b *
b - 4.0f * a * c;
1471 mu = -
b / (2.0f * a);
1476 const float i_sqrt =
sqrtf(
i);
1479 mu = (-
b + i_sqrt) / (2.0f * a);
1483 mu = (-
b - i_sqrt) / (2.0f * a);
1498 for (
i = 0, j = nr - 1;
i < nr; j =
i++) {
1499 if (((
verts[
i][1] > pt[1]) != (
verts[j][1] > pt[1])) &&
1515 for (
i = 0, j = nr - 1;
i < nr; j =
i++) {
1516 if (((
verts[
i][1] > pt[1]) != (
verts[j][1] > pt[1])) &&
1550 if (side12 >= 0.0f && side23 >= 0.0f && side31 >= 0.0f) {
1553 if (side12 <= 0.0f && side23 <= 0.0f && side31 <= 0.0f) {
1561 const float p[2],
const float v1[2],
const float v2[2],
const float v3[2],
const float v4[2])
1567 if (side12 >= 0.0f && side23 >= 0.0f && side34 >= 0.0f && side41 >= 0.0f) {
1570 if (side12 <= 0.0f && side23 <= 0.0f && side34 <= 0.0f && side41 <= 0.0f) {
1585 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1602 if ((u < 0.0f) || (u > 1.0f)) {
1609 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1614 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
1633 const float epsilon)
1636 float p[3], s[3], d[3], e1[3], e2[3], q[3];
1653 if ((u < -epsilon) || (u > 1.0f + epsilon)) {
1660 if ((
v < -epsilon) || ((u +
v) > 1.0f + epsilon)) {
1665 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
1678 const float ray_direction[3],
1687 const float epsilon = 0.00000001f;
1688 float p[3], s[3], e1[3], e2[3], q[3];
1696 if ((a > -epsilon) && (a < epsilon)) {
1704 if ((u < 0.0f) || (u > 1.0f)) {
1711 if ((
v < 0.0f) || ((u +
v) > 1.0f)) {
1716 if (*r_lambda < 0.0f) {
1729 const float ray_direction[3],
1730 const float plane_co[3],
1731 const float plane_no[3],
1745 const float ray_direction[3],
1746 const float plane[4],
1750 float plane_co[3], plane_no[3];
1755 if (clip && (*r_lambda < 0.0f)) {
1762 const float ray_direction[3],
1768 const float epsilon)
1770 float p[3], s[3], e1[3], e2[3], q[3];
1786 if ((u < -epsilon) || (u > 1.0f + epsilon)) {
1793 if ((
v < -epsilon) || ((u +
v) > 1.0f + epsilon)) {
1798 if (*r_lambda < 0.0f) {
1811 const float ray_direction[3])
1817 int kx = (kz != 2) ? (kz + 1) : 0;
1818 int ky = (kx != 2) ? (kx + 1) : 0;
1821 if (ray_direction[kz] < 0.0f) {
1826 inv_dir_z = 1.0f / ray_direction[kz];
1827 isect_precalc->
sx = ray_direction[kx] * inv_dir_z;
1828 isect_precalc->
sy = ray_direction[ky] * inv_dir_z;
1829 isect_precalc->
sz = inv_dir_z;
1832 isect_precalc->
kx = kx;
1833 isect_precalc->
ky = ky;
1834 isect_precalc->
kz = kz;
1845 const int kx = isect_precalc->
kx;
1846 const int ky = isect_precalc->
ky;
1847 const int kz = isect_precalc->
kz;
1848 const float sx = isect_precalc->
sx;
1849 const float sy = isect_precalc->
sy;
1850 const float sz = isect_precalc->
sz;
1853 const float a[3] = {v0[0] - ray_origin[0], v0[1] - ray_origin[1], v0[2] - ray_origin[2]};
1854 const float b[3] = {v1[0] - ray_origin[0], v1[1] - ray_origin[1], v1[2] - ray_origin[2]};
1855 const float c[3] = {
v2[0] - ray_origin[0],
v2[1] - ray_origin[1],
v2[2] - ray_origin[2]};
1857 const float a_kx = a[kx], a_ky = a[ky], a_kz = a[kz];
1858 const float b_kx =
b[kx], b_ky =
b[ky], b_kz =
b[kz];
1859 const float c_kx = c[kx], c_ky = c[ky], c_kz = c[kz];
1862 const float ax = a_kx - sx * a_kz;
1863 const float ay = a_ky - sy * a_kz;
1864 const float bx = b_kx - sx * b_kz;
1865 const float by = b_ky - sy * b_kz;
1866 const float cx = c_kx - sx * c_kz;
1867 const float cy = c_ky - sy * c_kz;
1870 const float u = cx * by - cy * bx;
1871 const float v = ax * cy - ay * cx;
1872 const float w = bx * ay - by * ax;
1875 if ((u < 0.0f ||
v < 0.0f ||
w < 0.0f) && (u > 0.0f ||
v > 0.0f ||
w > 0.0f)) {
1881 if (
UNLIKELY(det == 0.0f || !isfinite(det))) {
1888 const int sign_det = (
float_as_int(det) & int(0x80000000));
1889 const float t = (u * a_kz +
v * b_kz +
w * c_kz) * sz;
1890 const float sign_t =
xor_fl(t, sign_det);
1896 || (sign_T > *r_lambda * xor_signmask(det, sign_mask))
1904 const float inv_det = 1.0f / det;
1906 r_uv[0] = u * inv_det;
1907 r_uv[1] =
v * inv_det;
1909 *r_lambda = t * inv_det;
1914 const float ray_direction[3],
1932 const float ray_direction[3],
1938 const float threshold)
1940 const float epsilon = 0.00000001f;
1941 float p[3], s[3], e1[3], e2[3], q[3];
1950 if ((a > -epsilon) && (a < epsilon)) {
1959 if (*r_lambda < 0.0f) {
1966 if (u > 0 &&
v > 0 && u +
v > 1) {
1967 float t = (u +
v - 1) / 2;
2010 const float ray_direction[2],
2016 float v0_local[2], v1_local[2];
2028 const float p[2] = {(ray_direction[0] *
v) / det, (ray_direction[1] *
v) / det};
2030 const float t = (
dot_v2v2(p, ray_direction) /
dot_v2v2(ray_direction, ray_direction));
2031 if ((t >= 0.0f) == 0) {
2038 if ((u >= 0.0f && u <= 1.0f) == 0) {
2056 const float ray_direction[3],
2061 float a[3], t[3], n[3];
2072 float c[3], cray[3];
2076 *r_lambda =
dot_v3v3(cray, n) / nlen;
2085 for (
i = 0;
i < totplane;
i++) {
2096 for (
int i = 0;
i < totplane;
i++) {
2108 const float plane_co[3],
2109 const float plane_no[3])
2129 const float plane_b[4],
2130 const float plane_c[4],
2131 float r_isect_co[3])
2162 const float plane_b[4],
2163 float r_isect_co[3],
2164 float r_isect_no[3])
2166 float det, plane_c[3];
2196 const float planes[][4],
2197 const int planes_len,
2198 const float eps_coplanar,
2199 const float eps_isect,
2200 void (*callback_fn)(
const float co[3],
int i,
int j,
int k,
void *user_data),
2205 float n1n2[3], n2n3[3], n3n1[3];
2207 for (
int i = 0;
i < planes_len;
i++) {
2208 const float *n1 = planes[
i];
2209 for (
int j =
i + 1; j < planes_len; j++) {
2210 const float *n2 = planes[j];
2215 for (
int k = j + 1; k < planes_len; k++) {
2216 const float *n3 = planes[k];
2226 const float quotient = -
dot_v3v3(n1, n2n3);
2227 if (
fabsf(quotient) < eps_coplanar) {
2230 const float co_test[3] = {
2231 ((n2n3[0] * n1[3]) + (n3n1[0] * n2[3]) + (n1n2[0] * n3[3])) / quotient,
2232 ((n2n3[1] * n1[3]) + (n3n1[1] * n2[3]) + (n1n2[1] * n3[3])) / quotient,
2233 ((n2n3[2] * n1[3]) + (n3n1[2] * n2[3]) + (n1n2[2] * n3[3])) / quotient,
2236 for (i_test = 0; i_test < planes_len; i_test++) {
2237 const float *np_test = planes[i_test];
2238 if ((
dot_v3v3(np_test, co_test) + np_test[3]) > eps_isect) {
2240 if (!
ELEM(i_test,
i, j, k)) {
2246 if (i_test == planes_len) {
2247 callback_fn(co_test,
i, j, k, user_data);
2258 const float tri_b[3][3],
2261 int *r_tri_a_edge_isect_count)
2272 double ba[3], bc[3], plane_a[4], plane_b[4];
2273 *r_tri_a_edge_isect_count = 0;
2283 if (!side[1][0] && !side[1][1] && !side[1][2]) {
2288 if ((side[1][0] && side[1][1] && side[1][2]) && (side[1][0] < 0.0f) == (side[1][1] < 0.0f) &&
2289 (side[1][0] < 0.0f) == (side[1][2] < 0.0f))
2304 if ((side[0][0] && side[0][1] && side[0][2]) && (side[0][0] < 0.0f) == (side[0][1] < 0.0f) &&
2305 (side[0][0] < 0.0f) == (side[0][2] < 0.0f))
2313 double isect_dir[3];
2315 for (
int i = 0;
i < 2;
i++) {
2316 const float (*tri)[3] =
i == 0 ? tri_a : tri_b;
2320 if ((side[
i][0] && side[
i][1]) && (side[
i][0] < 0.0f) == (side[
i][1] < 0.0f)) {
2325 else if ((side[
i][1] && side[
i][2]) && (side[
i][1] < 0.0f) == (side[
i][2] < 0.0f)) {
2337 float sidec = side[
i][tri_i[1]];
2341 float fac0 = sidec / (sidec - side[
i][tri_i[0]]);
2342 float fac1 = sidec / (sidec - side[
i][tri_i[2]]);
2343 double offset0 = fac0 * (dot_a - dot_b);
2344 double offset1 = fac1 * (dot_c - dot_b);
2345 if (offset0 > offset1) {
2347 std::swap(offset0, offset1);
2348 std::swap(fac0, fac1);
2349 std::swap(tri_i[0], tri_i[2]);
2352 range[
i].min =
float(dot_b + offset0);
2353 range[
i].max =
float(dot_b + offset1);
2358 range[
i].min = range[
i].max =
float(dot_b);
2364 if ((range[0].
max > range[1].
min) && (range[0].
min < range[1].
max)) {
2368 if (range[0].
min >= range[1].
min) {
2370 if (range[0].
max <= range[1].
max) {
2372 *r_tri_a_edge_isect_count = 2;
2376 *r_tri_a_edge_isect_count = 1;
2380 if (range[0].
max <= range[1].
max) {
2383 *r_tri_a_edge_isect_count = 1;
2397 const float t_a1[3],
2398 const float t_a2[3],
2399 const float t_b0[3],
2400 const float t_b1[3],
2401 const float t_b2[3],
2405 float tri_a[3][3], tri_b[3][3];
2426 const float t_a1[2],
2427 const float t_a2[2],
2428 const float t_b0[2],
2429 const float t_b1[2],
2430 const float t_b2[2])
2489 const float t_a1[2],
2490 const float t_a2[2],
2491 const float t_b0[2],
2492 const float t_b1[2],
2493 const float t_b2[2])
2537 const float t_a1[2],
2538 const float t_a2[2],
2539 const float t_b0[2],
2540 const float t_b1[2],
2541 const float t_b2[2])
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])
2598 const float a,
const float b,
const float c,
const float maxR,
float *root)
2608 float r1 = (-
b - sqrtD) / (2.0f * a);
2609 float r2 = (-
b + sqrtD) / (2.0f * a);
2617 if (r1 > 0.0f && r1 < maxR) {
2624 if (r2 > 0.0f && r2 < maxR) {
2635 const float bbmin[3],
2636 const float bbmax[3])
2640 float bb_near[3], bb_far[3];
2641 for (
int i = 0;
i < totplane;
i++) {
2664 float e1[3], e2[3], e3[3], point[3], vel[3],
nor[3], temp[3], bv[3];
2665 float a,
b, c, d,
e,
x,
y,
z, radius2 = radius * radius;
2666 float elen2, edotv, edotbv, nordotv;
2668 bool found_by_sweep =
false;
2686 if (
fabsf(nordotv) < 0.000001f) {
2687 if (
fabsf(a) >= radius) {
2692 float t0 = (-a + radius) / nordotv;
2693 float t1 = (-a - radius) / nordotv;
2699 if (t0 > 1.0f || t1 < 0.0f) {
2704 CLAMP(t0, 0.0f, 1.0f);
2710 point[0] = p1[0] + vel[0] * t0 -
nor[0] * radius;
2711 point[1] = p1[1] + vel[1] * t0 -
nor[1] * radius;
2712 point[2] = p1[2] + vel[2] * t0 -
nor[2] * radius;
2725 z =
x +
y - (a * c -
b *
b);
2727 if (
z <= 0.0f && (
x >= 0.0f &&
y >= 0.0f)) {
2743 c =
dot_v3v3(temp, temp) - radius2;
2747 found_by_sweep =
true;
2753 c =
dot_v3v3(temp, temp) - radius2;
2757 found_by_sweep =
true;
2763 c =
dot_v3v3(temp, temp) - radius2;
2767 found_by_sweep =
true;
2780 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2781 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2782 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2785 e = (edotv * newLambda - edotbv) / elen2;
2787 if (
e >= 0.0f &&
e <= 1.0f) {
2788 *r_lambda = newLambda;
2792 found_by_sweep =
true;
2802 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2803 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2804 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2807 e = (edotv * newLambda - edotbv) / elen2;
2809 if (
e >= 0.0f &&
e <= 1.0f) {
2810 *r_lambda = newLambda;
2814 found_by_sweep =
true;
2829 a = elen2 * -
dot_v3v3(vel, vel) + edotv * edotv;
2830 b = 2.0f * (elen2 *
dot_v3v3(vel, bv) - edotv * edotbv);
2831 c = elen2 * (radius2 -
dot_v3v3(bv, bv)) + edotbv * edotbv;
2834 e = (edotv * newLambda - edotbv) / elen2;
2836 if (
e >= 0.0f &&
e <= 1.0f) {
2837 *r_lambda = newLambda;
2841 found_by_sweep =
true;
2845 return found_by_sweep;
2856 const float epsilon = 0.000001f;
2857 float p[3], e1[3], e2[3];
2859 int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3;
2865 f = (e2[a1] * e1[a2] - e2[a2] * e1[a1]);
2866 if ((f > -epsilon) && (f < epsilon)) {
2870 v = (p[a2] * e1[a1] - p[a1] * e1[a2]) / f;
2871 if ((
v < 0.0f) || (
v > 1.0f)) {
2876 if ((f > -epsilon) && (f < epsilon)) {
2878 if ((f > -epsilon) && (f < epsilon)) {
2881 u = (-p[a2] -
v * e2[a2]) / f;
2884 u = (-p[a1] -
v * e2[a1]) / f;
2887 if ((u < 0.0f) || ((u +
v) > 1.0f)) {
2891 *r_lambda = (p[a0] + u * e1[a0] +
v * e2[a0]) / (p2[a0] - p1[a0]);
2893 if ((*r_lambda < 0.0f) || (*r_lambda > 1.0f)) {
2906 const float epsilon)
2908 float a[3],
b[3], c[3], ab[3], cb[3];
2937 float v3t[3], v4t[3];
2971 const float epsilon = 0.000001f;
2982 const float epsilon = 0.000001f;
2983 float a[3],
b[3], c[3], ab[3], cb[3], ca[3];
3011 if (f1 >= 0 && f1 <= 1 && f2 >= 0 && f2 <= 1) {
3026 const float ray_direction_a[3],
3027 const float ray_origin_b[3],
3028 const float ray_direction_b[3],
3029 const float epsilon,
3044 float t[3], c[3], cray[3];
3048 if (r_lambda_a !=
nullptr) {
3050 *r_lambda_a =
dot_v3v3(cray, n) / nlen;
3053 if (r_lambda_b !=
nullptr) {
3055 *r_lambda_b =
dot_v3v3(cray, n) / nlen;
3062 const float ray_direction_a[3],
3063 const float ray_origin_b[3],
3064 const float ray_direction_b[3],
3078 const float max1[3],
3079 const float min2[3],
3080 const float max2[3])
3082 return (min1[0] < max2[0] && min1[1] < max2[1] && min1[2] < max2[2] && min2[0] < max1[0] &&
3083 min2[1] < max1[1] && min2[2] < max1[2]);
3087 const float ray_origin[3],
3088 const float ray_direction[3])
3092 data->ray_inv_dir[0] = 1.0f / ray_direction[0];
3093 data->ray_inv_dir[1] = 1.0f / ray_direction[1];
3094 data->ray_inv_dir[2] = 1.0f / ray_direction[2];
3096 data->sign[0] =
data->ray_inv_dir[0] < 0.0f;
3097 data->sign[1] =
data->ray_inv_dir[1] < 0.0f;
3098 data->sign[2] =
data->ray_inv_dir[2] < 0.0f;
3102 const float bb_min[3],
3103 const float bb_max[3],
3113 float tmin = (bbox[
data->sign[0]][0] -
data->ray_origin[0]) *
data->ray_inv_dir[0];
3114 float tmax = (bbox[1 -
data->sign[0]][0] -
data->ray_origin[0]) *
data->ray_inv_dir[0];
3116 const float tymin = (bbox[
data->sign[1]][1] -
data->ray_origin[1]) *
data->ray_inv_dir[1];
3117 const float tymax = (bbox[1 -
data->sign[1]][1] -
data->ray_origin[1]) *
data->ray_inv_dir[1];
3119 if ((tmin > tymax) || (tymin > tmax)) {
3123 tmin = std::max(tymin, tmin);
3124 tmax = std::min(tymax, tmax);
3126 const float tzmin = (bbox[
data->sign[2]][2] -
data->ray_origin[2]) *
data->ray_inv_dir[2];
3127 const float tzmax = (bbox[1 -
data->sign[2]][2] -
data->ray_origin[2]) *
data->ray_inv_dir[2];
3129 if ((tmin > tzmax) || (tzmin > tmax)) {
3133 tmin = std::max(tzmin, tmin);
3148 const float bb_min[3],
3149 const float bb_max[3],
3155 const double invdirx = (dir[0] > 1e-35f || dir[0] < -1e-35f) ? 1.0 /
double(dir[0]) : DBL_MAX;
3156 const double invdiry = (dir[1] > 1e-35f || dir[1] < -1e-35f) ? 1.0 /
double(dir[1]) : DBL_MAX;
3157 const double invdirz = (dir[2] > 1e-35f || dir[2] < -1e-35f) ? 1.0 /
double(dir[2]) : DBL_MAX;
3158 t[0] = double(bb_min[0] - orig[0]) * invdirx;
3159 t[1] = double(bb_max[0] - orig[0]) * invdirx;
3160 t[2] = double(bb_min[1] - orig[1]) * invdiry;
3161 t[3] = double(bb_max[1] - orig[1]) * invdiry;
3162 t[4] = double(bb_min[2] - orig[2]) * invdirz;
3163 t[5] = double(bb_max[2] - orig[2]) * invdirz;
3164 hit_dist[0] =
float(fmax(fmax(fmin(t[0], t[1]), fmin(t[2], t[3])), fmin(t[4], t[5])));
3165 hit_dist[1] =
float(fmin(fmin(fmax(t[0], t[1]), fmax(t[2], t[3])), fmax(t[4], t[5])));
3166 if ((hit_dist[1] < 0.0f) || (hit_dist[0] > hit_dist[1])) {
3171 *tmin = hit_dist[0];
3174 *tmax = hit_dist[1];
3181 const float ray_orig[3],
3182 const float ray_dir[3])
3207 float h[2], u[2], lambda, denom;
3211 if (denom == 0.0f) {
3217 r_close[0] = l1[0] + u[0] * lambda;
3218 r_close[1] = l1[1] + u[1] * lambda;
3227 double h[2], u[2], lambda, denom;
3237 r_close[0] = l1[0] + u[0] * lambda;
3238 r_close[1] = l1[1] + u[1] * lambda;
3243 const float ray_origin[3],
3244 const float ray_direction[3],
3245 const float epsilon,
3246 const float fallback)
3248 float p_relative[3];
3251 return (
dot > epsilon) ? (
dot_v3v3(ray_direction, p_relative) /
dot) : fallback;
3255 const float ray_origin[3],
3256 const float ray_direction[3])
3264 const float epsilon,
3265 const float fallback)
3284 const float epsilon,
3285 const float fallback)
3302 const float plane_no[3],
3318 if (dist_old > dist) {
3321 float fac = (dist / dist_old) * 0.5f;
3332 const int x1,
const int y1,
const int x2,
const int y2,
const int a,
const int b)
3334 float v1[2],
v2[2], v3[2], p[2];
3366 float h, rp[3], cp[3], q[3];
3375 return (h >= 0.0f && h <= 1.0f);
3385 if (h < 0.0f || h > 1.0f) {
3418 const float p[3],
const float v1[3],
const float v2[3],
const float v3[3],
float r_isect_co[3])
3438 const float p1[3],
const float p2[3],
const float plane[4],
float r_p1[3],
float r_p2[3])
3458 const float p1_copy[3] = {
UNPACK3(p1)};
3470 const float p1_copy[3] = {
UNPACK3(p1)};
3478 const float p1_copy[3] = {
UNPACK3(p1)};
3486 const float plane_array[][4],
3487 const int plane_num,
3492 float p1_fac = 0.0f, p2_fac = 1.0f;
3497 for (
int i = 0;
i < plane_num;
i++) {
3498 const float *plane = plane_array[
i];
3499 const float div =
dot_v3v3(dp, plane);
3512 if (p1_fac > p2_fac) {
3518 else if (div < 0.0f) {
3527 if (p1_fac > p2_fac) {
3537 const float p1_copy[3] = {
UNPACK3(p1)};
3583 const float v1[3],
const float v2[3],
const float v3[3],
const int i,
const int j)
3585 return 0.5f * ((v1[
i] -
v2[
i]) * (
v2[j] - v3[j]) + (v1[j] -
v2[j]) * (v3[
i] -
v2[
i]));
3607 wtot =
w[0] +
w[1] +
w[2];
3624 float w[3],
const float v1[3],
const float v2[3],
const float v3[3],
const float co[3])
3658 float n1[3], n2[3], n[3];
3666 std::swap(
w[2],
w[3]);
3668 if (!ok || (
w[0] < 0.0f)) {
3698 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3700 const float x = co[0],
y = co[1];
3701 const float x1 = v1[0], y1 = v1[1];
3702 const float x2 =
v2[0], y2 =
v2[1];
3703 const float x3 = v3[0], y3 = v3[1];
3704 const float det = (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3);
3710 w[0] = ((y2 - y3) * (
x - x3) + (x3 - x2) * (
y - y3)) / det;
3711 w[1] = ((y3 - y1) * (
x - x3) + (x1 - x3) * (
y - y3)) / det;
3712 w[2] = 1.0f -
w[0] -
w[1];
3722 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3729 wtot =
w[0] +
w[1] +
w[2];
3745 const float v1[2],
const float v2[2],
const float v3[2],
const float co[2],
float w[3])
3752 wtot =
w[0] +
w[1] +
w[2];
3768 const float v1[4],
const float v2[4],
const float v3[4],
const float co[2],
float w[3])
3775 wtot =
w[0] +
w[1] +
w[2];
3802#define MEAN_VALUE_HALF_TAN_V2(_area, i1, i2) \
3803 ((_area = cross_v2v2(dirs[i1], dirs[i2])) != 0.0f ? \
3804 fabsf(((lens[i1] * lens[i2]) - dot_v2v2(dirs[i1], dirs[i2])) / _area) : \
3807 const float dirs[4][2] = {
3808 {v1[0] - co[0], v1[1] - co[1]},
3809 {
v2[0] - co[0],
v2[1] - co[1]},
3810 {v3[0] - co[0], v3[1] - co[1]},
3811 {v4[0] - co[0], v4[1] - co[1]},
3814 const float lens[4] = {
3822 if (
UNLIKELY(lens[0] < FLT_EPSILON)) {
3824 w[1] =
w[2] =
w[3] = 0.0f;
3826 else if (
UNLIKELY(lens[1] < FLT_EPSILON)) {
3828 w[0] =
w[2] =
w[3] = 0.0f;
3830 else if (
UNLIKELY(lens[2] < FLT_EPSILON)) {
3832 w[0] =
w[1] =
w[3] = 0.0f;
3834 else if (
UNLIKELY(lens[3] < FLT_EPSILON)) {
3836 w[0] =
w[1] =
w[2] = 0.0f;
3844# pragma clang diagnostic push
3845# pragma clang diagnostic ignored "-Wunsequenced"
3849 const float t[4] = {
3857# pragma clang diagnostic pop
3860#undef MEAN_VALUE_HALF_TAN_V2
3862 w[0] = (t[3] + t[0]) / lens[0];
3863 w[1] = (t[0] + t[1]) / lens[1];
3864 w[2] = (t[1] + t[2]) / lens[2];
3865 w[3] = (t[2] + t[3]) / lens[3];
3867 wtot =
w[0] +
w[1] +
w[2] +
w[3];
3884 float const pt_src[3],
3885 const float tri_tar_p1[3],
3886 const float tri_tar_p2[3],
3887 const float tri_tar_p3[3],
3888 const float tri_src_p1[3],
3889 const float tri_src_p2[3],
3890 const float tri_src_p3[3])
3898 float no_tar[3], no_src[3];
3899 float mat_src[3][3];
3901 float tri_xy_src[3][3];
3903 float area_tar, area_src;
3921 area_src =
sqrtf(
area_tri_v2(tri_xy_src[0], tri_xy_src[1], tri_xy_src[2]));
3923 z_ofs_src = pt_src_xy[2] - tri_xy_src[0][2];
3924 madd_v3_v3v3fl(pt_tar, pt_tar, no_tar, (z_ofs_src / area_src) * area_tar);
3928 const float p_src[3],
3929 const float l_dst_p1[3],
3930 const float l_dst_p2[3],
3931 const float l_src_p1[3],
3932 const float l_src_p2[3])
3940 int found_invalid = 0;
3941 int found_valid = 0;
3944 for (
i = 0;
i < list_size;
i++) {
3945 if (
array[
i] == skipval) {
3953 if (found_valid == 0) {
3956 if (found_invalid == 0) {
3961 float valid_last = skipval;
3970 for (
i = 0;
i < list_size;
i++) {
3971 if (
array[
i] == skipval) {
3972 array_up[
i] = valid_last;
3973 ofs_tot_up[
i] = ++valid_ofs;
3981 valid_last = skipval;
3984 for (
i = list_size - 1;
i >= 0;
i--) {
3985 if (
array[
i] == skipval) {
3986 array_down[
i] = valid_last;
3987 ofs_tot_down[
i] = ++valid_ofs;
3996 for (
i = 0;
i < list_size;
i++) {
3997 if (
array[
i] == skipval) {
3998 if (array_up[
i] != skipval && array_down[
i] != skipval) {
4000 (array_down[
i] *
float(ofs_tot_up[
i]))) /
4001 float(ofs_tot_down[
i] + ofs_tot_up[
i]);
4003 else if (array_up[
i] != skipval) {
4006 else if (array_down[
i] != skipval) {
4019#define IS_POINT_IX (1 << 0)
4020#define IS_SEGMENT_IX (1 << 1)
4022#define DIR_V3_SET(d_len, va, vb) \
4024 sub_v3_v3v3((d_len)->dir, va, vb); \
4025 (d_len)->len = len_v3((d_len)->dir); \
4029#define DIR_V2_SET(d_len, va, vb) \
4031 sub_v2db_v2fl_v2fl((d_len)->dir, va, vb); \
4032 (d_len)->len = len_v2_db((d_len)->dir); \
4052 if (
LIKELY(area != 0.0f)) {
4054 const float len = d_curr->
len * d_next->
len;
4077 if (
LIKELY(area != 0.0)) {
4079 const double len = d_curr->
len * d_next->
len;
4092 float max_value = 0;
4094 for (
int i = 0;
i < n;
i++) {
4102 const float eps = 16.0f * FLT_EPSILON * max_value;
4103 const float eps_sq =
eps *
eps;
4104 const float *v_curr, *v_next;
4106 float totweight = 0.0f;
4122 while (i_next < n) {
4140 w[i_curr] = (ht_prev + ht) / d_curr.
len;
4141 totweight +=
w[i_curr];
4152 memset(
w, 0,
sizeof(*
w) *
size_t(n));
4159 CLAMP(fac, 0.0f, 1.0f);
4160 w[i_curr] = 1.0f - fac;
4165 if (totweight != 0.0f) {
4166 for (i_curr = 0; i_curr < n; i_curr++) {
4167 w[i_curr] /= totweight;
4177 float max_value = 0;
4179 for (
int i = 0;
i < n;
i++) {
4186 const float eps = 16.0f * FLT_EPSILON * max_value;
4187 const float eps_sq =
eps *
eps;
4189 const float *v_curr, *v_next;
4191 float totweight = 0.0f;
4207 while (i_next < n) {
4225 w[i_curr] = (d_curr.
len == 0.0) ? 0.0f :
float((ht_prev + ht) / d_curr.
len);
4226 totweight +=
w[i_curr];
4237 memset(
w, 0,
sizeof(*
w) *
size_t(n));
4244 CLAMP(fac, 0.0f, 1.0f);
4245 w[i_curr] = 1.0f - fac;
4250 if (totweight != 0.0f) {
4251 for (i_curr = 0; i_curr < n; i_curr++) {
4252 w[i_curr] /= totweight;
4275 const float t2 = t * t;
4276 const float t3 = t2 * t;
4279 a[0] = v1[0] +
v2[0] + 2 * (x1[0] - x2[0]);
4280 a[1] = v1[1] +
v2[1] + 2 * (x1[1] - x2[1]);
4281 a[2] = v1[2] +
v2[2] + 2 * (x1[2] - x2[2]);
4283 b[0] = -2 * v1[0] -
v2[0] - 3 * (x1[0] - x2[0]);
4284 b[1] = -2 * v1[1] -
v2[1] - 3 * (x1[1] - x2[1]);
4285 b[2] = -2 * v1[2] -
v2[2] - 3 * (x1[2] - x2[2]);
4287 x[0] = a[0] * t3 +
b[0] * t2 + v1[0] * t + x1[0];
4288 x[1] = a[1] * t3 +
b[1] * t2 + v1[1] * t + x1[1];
4289 x[2] = a[2] * t3 +
b[2] * t2 + v1[2] * t + x1[2];
4291 v[0] = 3 * a[0] * t2 + 2 *
b[0] * t + v1[0];
4292 v[1] = 3 * a[1] * t2 + 2 *
b[1] * t + v1[1];
4293 v[2] = 3 * a[2] * t2 + 2 *
b[2] * t + v1[2];
4299#define IS_ZERO(x) ((x > (-DBL_EPSILON) && x < DBL_EPSILON) ? 1 : 0)
4302 float r_uv[2],
const float st[2],
const float st0[2],
const float st1[2],
const float st2[2])
4307 const double a = st0[0] - st2[0],
b = st1[0] - st2[0];
4308 const double c = st0[1] - st2[1], d = st1[1] - st2[1];
4309 const double det = a * d - c *
b;
4313 const double x[2] = {st[0] - st2[0], st[1] - st2[1]};
4315 r_uv[0] =
float((d *
x[0] -
b *
x[1]) / det);
4316 r_uv[1] =
float(((-c) *
x[0] + a *
x[1]) / det);
4324 float r_uv[2],
const float st[3],
const float st0[3],
const float st1[3],
const float st2[3])
4326 float v0[3], v1[3],
v2[3];
4327 double d00, d01, d11, d20, d21, det;
4339 det = d00 * d11 - d01 * d01;
4345 w =
float((d00 * d21 - d01 * d20) / det);
4346 r_uv[1] =
float((d11 * d20 - d01 * d21) / det);
4347 r_uv[0] = 1.0f - r_uv[1] -
w;
4365 float r_deriv[2][2],
4372 const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) +
4373 (st1[0] * st2[1] - st1[1] * st2[0]) +
4374 (st2[0] * st3[1] - st2[1] * st3[0]) +
4375 (st3[0] * st0[1] - st3[1] * st0[0]);
4379 const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
4383 0.5 * double(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
4384 ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
4387 const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
4388 double denom = a - 2 *
b + fC;
4394 const double fDen = a - fC;
4396 r_uv[0] =
float(a / fDen);
4400 const double desc_sq =
b *
b - a * fC;
4401 const double desc =
sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
4402 const double s = signed_area > 0 ? (-1.0) : 1.0;
4404 r_uv[0] =
float(((a -
b) + s * desc) / denom);
4410 const double denom_s = (1 - r_uv[0]) * (st0[0] - st3[0]) + r_uv[0] * (st1[0] - st2[0]);
4411 const double denom_t = (1 - r_uv[0]) * (st0[1] - st3[1]) + r_uv[0] * (st1[1] - st2[1]);
4415 if (
fabs(denom_s) <
fabs(denom_t)) {
4421 r_uv[1] =
float(
double((1.0f - r_uv[0]) * (st0[
i] - st[
i]) + r_uv[0] * (st1[
i] - st[
i])) /
4427 float tmp1[2], tmp2[2], s[2], t[2];
4440 denom = t[0] * s[1] - t[1] * s[0];
4443 double inv_denom = 1.0 / denom;
4444 r_deriv[0][0] =
float(
double(-t[1]) * inv_denom);
4445 r_deriv[0][1] =
float(
double(t[0]) * inv_denom);
4446 r_deriv[1][0] =
float(
double(s[1]) * inv_denom);
4447 r_deriv[1][1] =
float(
double(-s[0]) * inv_denom);
4458 const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) +
4459 (st1[0] * st2[1] - st1[1] * st2[0]) +
4460 (st2[0] * st3[1] - st2[1] * st3[0]) +
4461 (st3[0] * st0[1] - st3[1] * st0[0]);
4465 const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]);
4469 0.5 * double(((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) +
4470 ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0])));
4473 const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]);
4474 double denom = a - 2 *
b + fC;
4477 const double fDen = a - fC;
4479 return float(a / fDen);
4485 const double desc_sq =
b *
b - a * fC;
4486 const double desc =
sqrt(desc_sq < 0.0 ? 0.0 : desc_sq);
4487 const double s = signed_area > 0 ? (-1.0) : 1.0;
4489 return float(((a -
b) + s * desc) / denom);
4532 const float nearClip,
4533 const float farClip)
4535 float Xdelta, Ydelta, Zdelta;
4537 Xdelta = right -
left;
4538 Ydelta =
top - bottom;
4539 Zdelta = farClip - nearClip;
4540 if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
4544 mat[0][0] = 2.0f / Xdelta;
4545 mat[3][0] = -(right +
left) / Xdelta;
4546 mat[1][1] = 2.0f / Ydelta;
4547 mat[3][1] = -(
top + bottom) / Ydelta;
4548 mat[2][2] = -2.0f / Zdelta;
4549 mat[3][2] = -(farClip + nearClip) / Zdelta;
4557 const float nearClip,
4558 const float farClip)
4560 const float Xdelta = right -
left;
4561 const float Ydelta =
top - bottom;
4562 const float Zdelta = farClip - nearClip;
4564 if (Xdelta == 0.0f || Ydelta == 0.0f || Zdelta == 0.0f) {
4567 mat[0][0] = nearClip * 2.0f / Xdelta;
4568 mat[1][1] = nearClip * 2.0f / Ydelta;
4569 mat[2][0] = (right +
left) / Xdelta;
4570 mat[2][1] = (
top + bottom) / Ydelta;
4571 mat[2][2] = -(farClip + nearClip) / Zdelta;
4573 mat[3][2] = (-2.0f * nearClip * farClip) / Zdelta;
4574 mat[0][1] = mat[0][2] = mat[0][3] = mat[1][0] = mat[1][2] = mat[1][3] = mat[3][0] = mat[3][1] =
4579 const float angle_left,
4580 const float angle_right,
4581 const float angle_up,
4582 const float angle_down,
4583 const float nearClip,
4584 const float farClip)
4586 const float tan_angle_left =
tanf(angle_left);
4587 const float tan_angle_right =
tanf(angle_right);
4588 const float tan_angle_bottom =
tanf(angle_up);
4589 const float tan_angle_top =
tanf(angle_down);
4592 mat, tan_angle_left, tan_angle_right, tan_angle_top, tan_angle_bottom, nearClip, farClip);
4593 mat[0][0] /= nearClip;
4594 mat[1][1] /= nearClip;
4599 if (winmat[2][3] == -1.0f) {
4605 v1[0] = perspmat[0][0];
4606 v1[1] = perspmat[1][0];
4607 v1[2] = perspmat[2][0];
4609 v2[0] = perspmat[0][1];
4610 v2[1] = perspmat[1][1];
4611 v2[2] = perspmat[2][1];
4613 len1 = (1.0f /
len_v3(v1));
4616 winmat[2][0] -= len1 * winmat[0][0] *
x;
4617 winmat[2][1] -= len2 * winmat[1][1] *
y;
4643 left[
i] = mat[
i][3] + mat[
i][0];
4649 right[
i] = mat[
i][3] - mat[
i][0];
4655 bottom[
i] = mat[
i][3] + mat[
i][1];
4661 top[
i] = mat[
i][3] - mat[
i][1];
4667 near[
i] = mat[
i][3] + mat[
i][2];
4673 far[
i] = mat[
i][3] - mat[
i][2];
4686 const bool is_persp = winmat[3][3] == 0.0f;
4688 const float near = winmat[3][2] / (winmat[2][2] - 1.0f);
4689 *r_left = near * ((winmat[2][0] - 1.0f) / winmat[0][0]);
4690 *r_right = near * ((winmat[2][0] + 1.0f) / winmat[0][0]);
4691 *r_bottom = near * ((winmat[2][1] - 1.0f) / winmat[1][1]);
4692 *r_top = near * ((winmat[2][1] + 1.0f) / winmat[1][1]);
4694 *r_far = winmat[3][2] / (winmat[2][2] + 1.0f);
4697 *r_left = (-winmat[3][0] - 1.0f) / winmat[0][0];
4698 *r_right = (-winmat[3][0] + 1.0f) / winmat[0][0];
4699 *r_bottom = (-winmat[3][1] - 1.0f) / winmat[1][1];
4700 *r_top = (-winmat[3][1] + 1.0f) / winmat[1][1];
4701 *r_near = (winmat[3][2] + 1.0f) / winmat[2][2];
4702 *r_far = (winmat[3][2] - 1.0f) / winmat[2][2];
4714 double winmat[4][4];
4717 const bool is_persp = winmat[3][3] == 0.0f;
4719 const double near = winmat[3][2] / (winmat[2][2] - 1.0);
4720 *r_left = near * ((winmat[2][0] - 1.0) / winmat[0][0]);
4721 *r_right = near * ((winmat[2][0] + 1.0) / winmat[0][0]);
4722 *r_bottom = near * ((winmat[2][1] - 1.0) / winmat[1][1]);
4723 *r_top = near * ((winmat[2][1] + 1.0) / winmat[1][1]);
4725 *r_far = winmat[3][2] / (winmat[2][2] + 1.0);
4728 *r_left = (-winmat[3][0] - 1.0) / winmat[0][0];
4729 *r_right = (-winmat[3][0] + 1.0) / winmat[0][0];
4730 *r_bottom = (-winmat[3][1] - 1.0) / winmat[1][1];
4731 *r_top = (-winmat[3][1] + 1.0) / winmat[1][1];
4732 *r_near = (winmat[3][2] + 1.0) / winmat[2][2];
4733 *r_far = (winmat[3][2] - 1.0) / winmat[2][2];
4738 const int win_size[2],
4743 float r_projmat[4][4])
4755 r_projmat[0][0] *= x_sca;
4756 r_projmat[1][1] *= y_sca;
4758 if (projmat[3][3] == 0.0f) {
4759 r_projmat[2][0] = r_projmat[2][0] * x_sca + x_fac;
4760 r_projmat[2][1] = r_projmat[2][1] * y_sca + y_fac;
4763 r_projmat[3][0] = r_projmat[3][0] * x_sca - x_fac;
4764 r_projmat[3][1] = r_projmat[3][1] * y_sca - y_fac;
4773 for (row = 0; row < 4; row++) {
4775 temp[row][
col] = (icand[row][0] * mat[0][
col] + icand[row][1] * mat[1][
col] +
4776 icand[row][2] * mat[2][
col] + icand[row][3] * mat[3][
col]);
4782void polarview_m4(
float mat[4][4],
float dist,
float azimuth,
float incidence,
float twist)
4793 float mat[4][4],
float vx,
float vy,
float vz,
float px,
float py,
float pz,
float twist)
4795 float sine, cosine, hyp, hyp1, dx, dy, dz;
4805 hyp = dx * dx + dz * dz;
4806 hyp1 =
sqrtf(dy * dy + hyp);
4811 cosine = hyp / hyp1;
4817 mat1[1][1] = cosine;
4820 mat1[2][2] = cosine;
4825 mat1[1][1] = mat1[2][2] = 1.0f;
4826 mat1[1][2] = mat1[2][1] = 0.0f;
4837 mat1[0][0] = cosine;
4840 mat1[2][2] = cosine;
4848 float mat[4][4], vec[4];
4849 int a, fl,
flag = -1;
4853 for (a = 0; a < 8; a++) {
4854 vec[0] = (a & 1) ? boundbox[0][0] : boundbox[1][0];
4855 vec[1] = (a & 2) ? boundbox[0][1] : boundbox[1][1];
4856 vec[2] = (a & 4) ? boundbox[0][2] : boundbox[1][2];
4862 if (vec[0] >
bounds[1] * vec[3]) {
4865 if (vec[0] <
bounds[0] * vec[3]) {
4868 if (vec[1] >
bounds[3] * vec[3]) {
4871 if (vec[1] <
bounds[2] * vec[3]) {
4876 if (vec[0] < -vec[3]) {
4879 if (vec[0] > vec[3]) {
4882 if (vec[1] < -vec[3]) {
4885 if (vec[1] > vec[3]) {
4889 if (vec[2] < -vec[3]) {
4892 if (vec[2] > vec[3]) {
4907 float mn[3], mx[3], vec[3];
4913 for (a = 0; a < 8; a++) {
4914 vec[0] = (a & 1) ? boundbox[0][0] : boundbox[1][0];
4915 vec[1] = (a & 2) ? boundbox[0][1] : boundbox[1][1];
4916 vec[2] = (a & 4) ? boundbox[0][2] : boundbox[1][2];
4941 const float epsilon = 0.25f / 65536.0f;
4945 if (1.0f - epsilon < u) {
4953 bool regular =
true;
4954 if (
x *
x +
y *
y < 1e-6f * 1e-6f) {
4962 *r_v = (
z + 1.0f) / 2.0f;
4968 bool regular =
true;
4969 const float epsilon = 0.25f / 65536.0f;
4970 const float len_xy =
sqrtf(
x *
x +
y *
y);
4971 if (len_xy <=
fabsf(
z) * epsilon) {
4985 const float target[3] = {0.0f, 0.0f, 1.0f};
4996 const float axis[3],
5011 const float f_no[3],
5017 const int nverts = 3;
5030 float *vn[] = {n1, n2, n3};
5031 const float *prev_edge = vdiffs[nverts - 1];
5034 for (
i = 0;
i < nverts;
i++) {
5035 const float *cur_edge = vdiffs[
i];
5040 prev_edge = cur_edge;
5049 const float f_no[3],
5056 const int nverts = (n4 !=
nullptr && co4 !=
nullptr) ? 4 : 3;
5077 float *vn[] = {n1, n2, n3, n4};
5078 const float *prev_edge = vdiffs[nverts - 1];
5081 for (
i = 0;
i < nverts;
i++) {
5082 const float *cur_edge = vdiffs[
i];
5087 prev_edge = cur_edge;
5093 const float polyno[3],
5094 const float **vertcos,
5101 for (
i = 0;
i < nverts;
i++) {
5108 const float *prev_edge = vdiffs[nverts - 1];
5110 for (
i = 0;
i < nverts;
i++) {
5111 const float *cur_edge = vdiffs[
i];
5119 prev_edge = cur_edge;
5135 const float s1 = uv2[0] - uv1[0];
5136 const float s2 = uv3[0] - uv1[0];
5137 const float t1 = uv2[1] - uv1[1];
5138 const float t2 = uv3[1] - uv1[1];
5139 float det = (s1 * t2 - s2 * t1);
5143 float tangv[3], ct[3], e1[3], e2[3];
5150 r_tang[0] = (t2 * e1[0] - t1 * e2[0]) * det;
5151 r_tang[1] = (t2 * e1[1] - t1 * e2[1]) * det;
5152 r_tang[2] = (t2 * e1[2] - t1 * e2[2]) * det;
5153 tangv[0] = (s1 * e2[0] - s2 * e1[0]) * det;
5154 tangv[1] = (s1 * e2[1] - s2 * e1[1]) * det;
5155 tangv[2] = (s1 * e2[2] - s2 * e1[2]) * det;
5173 const float (*
pos)[3],
5174 const float *weight,
5175 const float (*rpos)[3],
5176 const float *rweight,
5182 float accu_com[3] = {0.0f, 0.0f, 0.0f}, accu_rcom[3] = {0.0f, 0.0f, 0.0f};
5183 float accu_weight = 0.0f, accu_rweight = 0.0f;
5184 const float eps = 1e-6f;
5201 if (
pos && rpos && (list_size > 0)) {
5203 for (a = 0; a < list_size; a++) {
5209 accu_weight += weight[a];
5220 accu_rweight += rweight[a];
5226 if (!weight || !rweight) {
5227 accu_weight = accu_rweight =
float(list_size);
5230 mul_v3_fl(accu_com, 1.0f / accu_weight);
5231 mul_v3_fl(accu_rcom, 1.0f / accu_rweight);
5238 if (lrot || lscale) {
5242 float m[3][3], mr[3][3], q[3][3], qi[3][3];
5243 float va[3], vb[3], stunt[3];
5245 int i = 0, imax = 15;
5250 for (a = 0; a < list_size; a++) {
5255 m[0][0] += va[0] * vb[0];
5256 m[0][1] += va[0] * vb[1];
5257 m[0][2] += va[0] * vb[2];
5259 m[1][0] += va[1] * vb[0];
5260 m[1][1] += va[1] * vb[1];
5261 m[1][2] += va[1] * vb[2];
5263 m[2][0] += va[2] * vb[0];
5264 m[2][1] += va[2] * vb[1];
5265 m[2][2] += va[2] * vb[2];
5270 mr[0][0] += va[0] * va[0];
5271 mr[0][1] += va[0] * va[1];
5272 mr[0][2] += va[0] * va[2];
5274 mr[1][0] += va[1] * va[0];
5275 mr[1][1] += va[1] * va[1];
5276 mr[1][2] += va[1] * va[2];
5278 mr[2][0] += va[2] * va[0];
5279 mr[2][1] += va[2] * va[1];
5280 mr[2][2] += va[2] * va[2];
5293 while ((odet - ndet) * (odet - ndet) >
eps &&
i < imax) {
5323 const float f1_no[3],
5324 const float f2_no[3])
5352 float v13[3], v24[3];
5362 const float eps_sq =
square_f(1e-8f);
5368 const float *quad_coords[4] = {v1,
v2, v3, v4};
5369 float quad_proj[4][3];
5371 for (
int i = 0;
i < 4;
i++) {
5375 float quad_dirs[4][3];
5376 for (
int i = 0, j = 3;
i < 4; j =
i++) {
5382#define CROSS_SIGN(dir_a, dir_b) \
5383 ((void)cross_v3_v3v3(test_dir, dir_a, dir_b), (dot_v3v3(plane, test_dir) > 0.0f))
5401 const float *co_curr, *co_prev;
5402 float dir_curr[2], dir_prev[2];
5404 co_prev =
verts[nr - 1];
5409 for (a = 0; a < nr; a++) {
5419 else if (
cross > 0.0f) {
5423 if (sign_flag == (1 | 2)) {
5438 float d_12[3], d_23[3], d_34[3], d_41[3];
5439 float cross_a[3], cross_b[3];
5449 ret |= ((
dot_v3v3(cross_a, cross_b) < 0.0f) << 0);
5453 ret |= ((
dot_v3v3(cross_a, cross_b) < 0.0f) << 1);
5466 float d_12[3], d_13[3], d_14[3];
5467 float cross_a[3], cross_b[3];
5473 return dot_v3v3(cross_a, cross_b) > 0.0f;
5482 const float eps = 1e-5f;
5484 const float tan_dot =
dot_v3v3(tan_l, tan_r);
5485 if (tan_dot > 1.0f -
eps) {
5487 return (1.0f / 3.0f) * 0.75f;
5489 if (tan_dot < -1.0f +
eps) {
5491 return (1.0f / 2.0f);
5500 return ((1.0f - angle_cos) / (angle_sin * 2.0f)) / angle_sin;
5504 const float v0[3],
const float v1[3],
const float v2[3],
const float dist1,
const float dist2)
5507 float v10[3], v12[3];
5511 if (dist1 != 0.0f && dist2 != 0.0f) {
5513 float u[3],
v[3], n[3];
5516 if (d12 * d12 > 0.0f) {
5526 const float a = 0.5f * (1.0f + (dist1 * dist1 - dist2 * dist2) / (d12 * d12));
5527 const float hh = dist1 * dist1 - a * a * d12 * d12;
5530 const float h =
sqrtf(hh);
5531 const float S_[2] = {a * d12, -h};
5535 const float x_intercept = S_[0] + h * (v0_[0] - S_[0]) / (v0_[1] + h);
5536 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 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 unit_m4(float m[4][4])
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 is_finite_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
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])
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])
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 bool is_finite_v4(const float v[4]) ATTR_WARN_UNUSED_RESULT
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])
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
BMesh const char void * data
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)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
bool closest(btVector3 &v)
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
float determinant(MatBase< C, R >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
float length(VecOp< float, D >) RET
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)