59 const float max_dist_sq,
63 if (nearest->
index != -1) {
65 if (nearest->
dist_sq > max_dist_sq) {
77 if ((nearest->
index != -1) && (nearest->
dist_sq <= max_dist_sq)) {
97 rayhit->
dist = max_dist;
102 rayhit_tmp = *rayhit;
106 if (rayhit_tmp.
dist < rayhit->
dist) {
107 *rayhit = rayhit_tmp;
110 if ((rayhit->
index != -1) && (rayhit->
dist <= max_dist)) {
111 *r_hit_dist = rayhit->
dist;
137 const MVert *verts_dst,
138 const int numverts_dst,
151 for (i = 0; i < numverts_dst; i++) {
157 if (space_transform) {
162 result += 1.0f / (hit_dist + 1.0f);
173 printf(
"%s: Computed difference between meshes (the lower the better): %f\n", __func__,
result);
192 const float (*vcos)[3],
196 float center[3], covmat[3][3];
197 float eigen_val[3], eigen_vec[3][3];
208 for (i = 0, co =
cos,
mv =
verts; i < numverts; i++, co++,
mv++) {
255 for (i = 0; i < 3; i++) {
256 float evi = eigen_val[i];
263 evi = (evi < 1e-6f && evi > -1e-6f) ? ((evi < 0.0f) ? -1e-3f : 1e-3f) :
sqrtf_signed(evi);
275 const int numverts_dst,
281 const float mirrors[][3] = {
291 const float(*mirr)[3];
293 float mat_src[4][4], mat_dst[4][4], best_mat_dst[4][4];
294 float best_match = FLT_MAX, match;
296 const int numverts_src = me_src->
totvert;
304 r_space_transform, verts_dst, numverts_dst, me_src);
309 for (mirr = mirrors; (*mirr)[0]; mirr++) {
316 r_space_transform, verts_dst, numverts_dst, me_src);
317 if (match < best_match) {
335 const int UNUSED(edge_mode),
337 const int UNUSED(poly_mode),
342 const bool need_pnors_src = need_lnors_src ||
345 if (need_lnors_src) {
348 if (need_pnors_src) {
378 const float UNUSED(hit_dist),
380 const int sources_num,
381 const int *indices_src,
382 const float *weights_src)
390 sizeof(*mapit->
indices_src) * (
size_t)sources_num);
393 sizeof(*mapit->
weights_src) * (
size_t)sources_num);
413 const float (*vcos_src)[3],
414 const float point[3],
417 const bool use_loops,
420 const bool do_weights,
421 int *r_closest_index)
425 float ref_dist_sq = FLT_MAX;
427 const int sources_num = mp->
totloop;
430 if ((
size_t)sources_num > *buff_size) {
431 *buff_size = (size_t)sources_num;
432 *vcos =
MEM_reallocN(*vcos,
sizeof(**vcos) * *buff_size);
435 *weights =
MEM_reallocN(*weights,
sizeof(**weights) * *buff_size);
439 for (i = 0, ml = &mloops[mp->
loopstart], vco = *vcos, index = *
indices; i < sources_num;
440 i++, ml++, vco++, index++) {
441 *index = use_loops ? (int)mp->
loopstart + i : (
int)ml->
v;
443 if (r_closest_index) {
446 if (dist_sq < ref_dist_sq) {
447 ref_dist_sq = dist_sq;
448 *r_closest_index = *index;
489 #define MREMAP_RAYCAST_APPROXIMATE_NR 3
491 #define MREMAP_RAYCAST_APPROXIMATE_FAC 5.0f
494 #define MREMAP_RAYCAST_TRI_SAMPLES_MIN 4
495 #define MREMAP_RAYCAST_TRI_SAMPLES_MAX 20
498 #define MREMAP_DEFAULT_BUFSIZE 32
502 const float max_dist,
503 const float ray_radius,
504 const MVert *verts_dst,
505 const int numverts_dst,
506 const bool UNUSED(dirty_nors_dst),
510 const float full_weight = 1.0f;
511 const float max_dist_sq = max_dist * max_dist;
520 for (i = 0; i < numverts_dst; i++) {
529 float tmp_co[3], tmp_no[3];
535 for (i = 0; i < numverts_dst; i++) {
539 if (space_transform) {
544 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
560 for (i = 0; i < numverts_dst; i++) {
564 if (space_transform) {
569 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
571 const float *v1cos = vcos_src[me->
v1];
572 const float *v2cos = vcos_src[me->
v2];
577 const int index = (int)((dist_v1 > dist_v2) ? me->
v2 : me->
v1);
589 CLAMP(weights[0], 0.0f, 1.0f);
590 weights[1] = 1.0f - weights[0];
614 float *weights =
MEM_mallocN(
sizeof(*weights) * tmp_buff_size, __func__);
619 for (i = 0; i < numverts_dst; i++) {
624 if (space_transform) {
630 &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) {
635 (
const float(*)[3])vcos_src,
656 for (i = 0; i < numverts_dst; i++) {
660 if (space_transform) {
665 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
673 (
const float(*)[3])vcos_src,
688 (
const float(*)[3])vcos_src,
714 CLOG_WARN(&
LOG,
"Unsupported mesh-to-mesh vertex mapping mode (%d)!", mode);
715 memset(r_map->
items, 0,
sizeof(*r_map->
items) * (
size_t)numverts_dst);
724 const float max_dist,
725 const float ray_radius,
726 const MVert *verts_dst,
727 const int numverts_dst,
728 const MEdge *edges_dst,
729 const int numedges_dst,
730 const bool UNUSED(dirty_nors_dst),
734 const float full_weight = 1.0f;
735 const float max_dist_sq = max_dist * max_dist;
744 for (i = 0; i < numedges_dst; i++) {
753 float tmp_co[3], tmp_no[3];
756 const int num_verts_src = me_src->
totvert;
757 const int num_edges_src = me_src->
totedge;
762 int *vert_to_edge_src_map_mem;
767 } *v_dst_to_src_map =
MEM_mallocN(
sizeof(*v_dst_to_src_map) * (
size_t)numverts_dst,
770 for (i = 0; i < numverts_dst; i++) {
771 v_dst_to_src_map[i].hit_dist = -1.0f;
775 &vert_to_edge_src_map_mem,
783 for (i = 0; i < numedges_dst; i++) {
784 const MEdge *e_dst = &edges_dst[i];
785 float best_totdist = FLT_MAX;
786 int best_eidx_src = -1;
790 const unsigned int vidx_dst = j ? e_dst->
v1 : e_dst->
v2;
793 if (v_dst_to_src_map[vidx_dst].hit_dist == -1.0f) {
797 if (space_transform) {
802 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
803 v_dst_to_src_map[vidx_dst].hit_dist = hit_dist;
804 v_dst_to_src_map[vidx_dst].index = nearest.
index;
808 v_dst_to_src_map[vidx_dst].hit_dist = FLT_MAX;
816 const unsigned int vidx_dst = j ? e_dst->
v1 : e_dst->
v2;
817 const float first_dist = v_dst_to_src_map[vidx_dst].hit_dist;
818 const int vidx_src = v_dst_to_src_map[vidx_dst].index;
825 eidx_src = vert_to_edge_src_map[vidx_src].
indices;
826 k = vert_to_edge_src_map[vidx_src].
count;
828 for (; k--; eidx_src++) {
829 MEdge *e_src = &edges_src[*eidx_src];
831 const float *other_co_dst =
833 const float totdist = first_dist +
len_v3v3(other_co_src, other_co_dst);
835 if (totdist < best_totdist) {
836 best_totdist = totdist;
837 best_eidx_src = *eidx_src;
842 if (best_eidx_src >= 0) {
843 const float *co1_src = vcos_src[edges_src[best_eidx_src].
v1];
844 const float *co2_src = vcos_src[edges_src[best_eidx_src].v2];
845 const float *co1_dst = verts_dst[e_dst->
v1].
co;
846 const float *co2_dst = verts_dst[e_dst->
v2].
co;
847 float co_src[3], co_dst[3];
851 co1_src, co2_src, co1_dst, co2_dst, co_src, co_dst);
852 if (isect_type != 0) {
855 if (fac_src < 0.0f) {
858 else if (fac_src > 1.0f) {
861 if (fac_dst < 0.0f) {
864 else if (fac_dst > 1.0f) {
868 hit_dist =
len_v3v3(co_dst, co_src);
886 for (i = 0; i < numedges_dst; i++) {
887 interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].
v1].co, verts_dst[edges_dst[i].
v2].co, 0.5f);
890 if (space_transform) {
895 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
912 for (i = 0; i < numedges_dst; i++) {
913 interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].
v1].co, verts_dst[edges_dst[i].
v2].co, 0.5f);
916 if (space_transform) {
921 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
926 float best_dist_sq = FLT_MAX;
927 int best_eidx_src = -1;
929 for (; nloops--; ml_src++) {
930 MEdge *med_src = &edges_src[ml_src->
e];
931 float *co1_src = vcos_src[med_src->
v1];
932 float *co2_src = vcos_src[med_src->
v2];
938 if (dist_sq < best_dist_sq) {
939 best_dist_sq = dist_sq;
940 best_eidx_src = (int)ml_src->
e;
943 if (best_eidx_src >= 0) {
956 const int num_rays_min = 5, num_rays_max = 100;
957 const int numedges_src = me_src->
totedge;
963 float *weights =
MEM_mallocN(
sizeof(*weights) * (
size_t)numedges_src, __func__);
967 for (i = 0; i < numedges_dst; i++) {
970 const MEdge *me = &edges_dst[i];
971 float v1_co[3], v2_co[3];
972 float v1_no[3], v2_no[3];
978 float totweights = 0.0f;
979 float hit_dist_accum = 0.0f;
990 if (space_transform) {
1001 edge_dst_len =
len_v3v3(v1_co, v2_co);
1003 grid_size = (int)((edge_dst_len / ray_radius) + 0.5f);
1004 CLAMP(grid_size, num_rays_min, num_rays_max);
1010 for (j = 0; j < grid_size; j++) {
1011 const float fac = grid_step * (
float)j;
1021 &treedata, &rayhit, tmp_co, tmp_no, ray_radius /
w, max_dist, &hit_dist)) {
1022 weights[rayhit.
index] +=
w;
1024 hit_dist_accum += hit_dist;
1033 if (totweights > ((
float)grid_size / 2.0f)) {
1034 for (j = 0; j < (int)numedges_src; j++) {
1039 weights[sources_num] = weights[j] / totweights;
1044 r_map, i, hit_dist_accum / totweights, 0, sources_num,
indices, weights);
1056 CLOG_WARN(&
LOG,
"Unsupported mesh-to-mesh edge mapping mode (%d)!", mode);
1057 memset(r_map->
items, 0,
sizeof(*r_map->
items) * (
size_t)numedges_dst);
1064 #define POLY_UNSET 0
1065 #define POLY_CENTER_INIT 1
1066 #define POLY_COMPLETE 2
1069 const int island_index,
1077 const bool is_edge_innercut,
1078 const int *poly_island_index_map,
1079 float (*poly_centers)[3],
1080 unsigned char *poly_status)
1083 (
size_t)edge_to_poly_map[edge_idx].
count);
1086 for (i = 0; i < edge_to_poly_map[edge_idx].
count; i++) {
1087 const int pidx = edge_to_poly_map[edge_idx].
indices[i];
1088 MPoly *mp = &polys[pidx];
1089 const int pidx_isld = islands ? poly_island_index_map[pidx] : pidx;
1094 poly_island_indices[i] = -1;
1099 poly_island_indices[i] = pidx_isld;
1111 const int pidx_isld_other = poly_island_indices[j];
1113 if (pidx_isld_other == -1 || poly_status[pidx_isld_other] ==
POLY_COMPLETE) {
1117 dist_cost =
len_v3v3(poly_centers[pidx_isld_other], poly_centers[pidx_isld]);
1121 poly_island_indices[i] = pidx_isld;
1128 const int island_index,
1140 int *poly_island_index_map =
NULL;
1143 const int node_num = islands ? island_poly_map->
count : numpolys;
1144 unsigned char *poly_status =
MEM_callocN(
sizeof(*poly_status) * (
size_t)node_num, __func__);
1145 float(*poly_centers)[3];
1157 sizeof(*poly_island_index_map) * (
size_t)numpolys);
1158 for (i = island_poly_map->
count; i--;) {
1159 poly_island_index_map[island_poly_map->
indices[i]] = i;
1164 for (i = island_einnercut_map->
count; i--;) {
1171 island_einnercut_map->
indices[i],
1175 poly_island_index_map,
1181 for (pidx_isld = node_num; pidx_isld--;) {
1182 const int pidx = islands ? island_poly_map->
indices[pidx_isld] : pidx_isld;
1183 MPoly *mp = &polys[pidx];
1190 for (pl_idx = 0, l_idx = mp->
loopstart; pl_idx < mp->totloop; pl_idx++, l_idx++) {
1191 MLoop *ml = &loops[l_idx];
1207 poly_island_index_map,
1219 #undef POLY_CENTER_INIT
1220 #undef POLY_COMPLETE
1228 const int node_idx_curr,
1229 const int node_idx_next,
1230 const int node_idx_dst)
1232 float *co_next, *co_dest;
1248 return (link ? (as_solution->
g_costs[node_idx_curr] + link->
cost) : 0.0f) +
1252 #define ASTAR_STEPS_MAX 64
1256 const float max_dist,
1257 const float ray_radius,
1259 const int numverts_dst,
1261 const int numedges_dst,
1263 const int numloops_dst,
1265 const int numpolys_dst,
1268 const bool use_split_nors_dst,
1269 const float split_angle_dst,
1270 const bool dirty_nors_dst,
1273 const float islands_precision_src,
1276 const float full_weight = 1.0f;
1277 const float max_dist_sq = max_dist * max_dist;
1282 BLI_assert((islands_precision_src >= 0.0f) && (islands_precision_src <= 1.0f));
1289 for (i = 0; i < numloops_dst; i++) {
1299 float tmp_co[3], tmp_no[3];
1304 bool use_islands =
false;
1308 const int isld_steps_src = (islands_precision_src ?
1321 int *vert_to_loop_map_src_buff =
NULL;
1323 int *vert_to_poly_map_src_buff =
NULL;
1325 int *edge_to_poly_map_src_buff =
NULL;
1327 int *poly_to_looptri_map_src_buff =
NULL;
1330 int *loop_to_poly_map_src =
NULL;
1333 const int num_verts_src = me_src->
totvert;
1336 const int num_edges_src = me_src->
totedge;
1338 const int num_loops_src = me_src->
totloop;
1340 const int num_polys_src = me_src->
totpoly;
1342 int num_looptri_src = 0;
1346 int *indices_interp =
NULL;
1347 float *weights_interp =
NULL;
1349 MLoop *ml_src, *ml_dst;
1350 MPoly *mp_src, *mp_dst;
1351 int tindex, pidx_dst, lidx_dst, plidx_dst, pidx_src, lidx_src, plidx_src;
1356 if (!use_from_vert) {
1359 vcos_interp =
MEM_mallocN(
sizeof(*vcos_interp) * buff_size_interp, __func__);
1360 indices_interp =
MEM_mallocN(
sizeof(*indices_interp) * buff_size_interp, __func__);
1361 weights_interp =
MEM_mallocN(
sizeof(*weights_interp) * buff_size_interp, __func__);
1367 const bool need_pnors_src = need_lnors_src ||
1369 const bool need_pnors_dst = need_lnors_dst || need_pnors_src;
1371 if (need_pnors_dst) {
1374 const bool do_poly_nors_dst = (poly_nors_dst ==
NULL);
1375 if (!poly_nors_dst) {
1380 if (dirty_nors_dst || do_poly_nors_dst) {
1392 if (need_lnors_dst) {
1397 const bool do_loop_nors_dst = (loop_nors_dst ==
NULL);
1398 if (!loop_nors_dst) {
1403 if (dirty_nors_dst || do_loop_nors_dst) {
1412 (
const float(*)[3])poly_nors_dst,
1421 if (need_pnors_src || need_lnors_src) {
1422 if (need_pnors_src) {
1426 if (need_lnors_src) {
1433 if (use_from_vert) {
1435 &vert_to_loop_map_src_buff,
1443 &vert_to_poly_map_src_buff,
1454 &edge_to_poly_map_src_buff,
1461 if (use_from_vert) {
1462 loop_to_poly_map_src =
MEM_mallocN(
sizeof(*loop_to_poly_map_src) * (
size_t)num_loops_src,
1464 poly_cents_src =
MEM_mallocN(
sizeof(*poly_cents_src) * (
size_t)num_polys_src, __func__);
1465 for (pidx_src = 0, mp_src = polys_src; pidx_src < num_polys_src; pidx_src++, mp_src++) {
1467 for (plidx_src = 0, lidx_src = mp_src->
loopstart; plidx_src < mp_src->totloop;
1468 plidx_src++, lidx_src++) {
1469 loop_to_poly_map_src[lidx_src] = pidx_src;
1483 if (gen_islands_src) {
1484 use_islands = gen_islands_src(verts_src,
1494 num_trees = use_islands ? island_store.
islands_num : 1;
1495 treedata =
MEM_callocN(
sizeof(*treedata) * (
size_t)num_trees, __func__);
1496 if (isld_steps_src) {
1497 as_graphdata =
MEM_callocN(
sizeof(*as_graphdata) * (
size_t)num_trees, __func__);
1511 treedata =
MEM_callocN(
sizeof(*treedata), __func__);
1512 if (isld_steps_src) {
1513 as_graphdata =
MEM_callocN(
sizeof(*as_graphdata), __func__);
1518 if (isld_steps_src) {
1519 for (tindex = 0; tindex < num_trees; tindex++) {
1523 edge_to_poly_map_src,
1528 &as_graphdata[tindex]);
1533 if (use_from_vert) {
1537 for (tindex = 0; tindex < num_trees; tindex++) {
1539 int num_verts_active = 0;
1541 for (i = 0; i < isld->
count; i++) {
1542 mp_src = &polys_src[isld->
indices[i]];
1543 for (lidx_src = mp_src->
loopstart; lidx_src < mp_src->loopstart + mp_src->
totloop;
1545 const unsigned int vidx_src = loops_src[lidx_src].
v;
1580 looptri_active =
BLI_BITMAP_NEW((
size_t)num_looptri_src, __func__);
1582 for (tindex = 0; tindex < num_trees; tindex++) {
1583 int num_looptri_active = 0;
1585 for (i = 0; i < num_looptri_src; i++) {
1586 mp_src = &polys_src[looptri_src[i].
poly];
1589 num_looptri_active++;
1619 islands_res =
MEM_mallocN(
sizeof(*islands_res) * (
size_t)num_trees, __func__);
1620 for (tindex = 0; tindex < num_trees; tindex++) {
1621 islands_res[tindex] =
MEM_mallocN(
sizeof(**islands_res) * islands_res_buff_size, __func__);
1624 for (pidx_dst = 0, mp_dst = polys_dst; pidx_dst < numpolys_dst; pidx_dst++, mp_dst++) {
1630 bool pcent_dst_valid =
false;
1633 copy_v3_v3(pnor_dst, poly_nors_dst[pidx_dst]);
1634 if (space_transform) {
1639 if ((
size_t)mp_dst->
totloop > islands_res_buff_size) {
1641 for (tindex = 0; tindex < num_trees; tindex++) {
1642 islands_res[tindex] =
MEM_reallocN(islands_res[tindex],
1643 sizeof(**islands_res) * islands_res_buff_size);
1647 for (tindex = 0; tindex < num_trees; tindex++) {
1651 for (plidx_dst = 0; plidx_dst < mp_dst->
totloop; plidx_dst++, ml_dst++) {
1652 if (use_from_vert) {
1659 if (space_transform) {
1664 tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
1666 float(*nors_src)[3];
1667 float best_nor_dot = -2.0f;
1668 float best_sqdist_fallback = FLT_MAX;
1669 int best_index_src = -1;
1673 if (space_transform) {
1677 nors_src = loop_nors_src;
1678 vert_to_refelem_map_src = vert_to_loop_map_src;
1681 nor_dst = &pnor_dst;
1682 nors_src = poly_nors_src;
1683 vert_to_refelem_map_src = vert_to_poly_map_src;
1686 for (i = vert_to_refelem_map_src[nearest.
index].
count; i--;) {
1687 const int index_src = vert_to_refelem_map_src[nearest.
index].
indices[i];
1689 const float dot =
dot_v3v3(nors_src[index_src], *nor_dst);
1692 loop_to_poly_map_src[index_src] :
1699 polys_src[pidx_src].loopstart);
1707 if (
dot > best_nor_dot - 1e-6f) {
1713 mp_src = &polys_src[pidx_src];
1716 if (!pcent_dst_valid) {
1718 mp_dst, &loops_dst[mp_dst->
loopstart], verts_dst, pcent_dst);
1719 pcent_dst_valid =
true;
1721 pcent_src = poly_cents_src[pidx_src];
1724 if ((
dot > best_nor_dot + 1e-6f) || (sqdist < best_sqdist_fallback)) {
1726 best_sqdist_fallback = sqdist;
1727 best_index_src = index_src;
1731 if (best_index_src == -1) {
1733 best_nor_dot = -1.0f;
1739 mp_src = &polys_src[best_index_src];
1741 for (plidx_src = 0; plidx_src < mp_src->
totloop; plidx_src++, ml_src++) {
1742 if ((
int)ml_src->
v == nearest.
index) {
1743 best_index_src = plidx_src + mp_src->
loopstart;
1748 best_nor_dot = (best_nor_dot + 1.0f) * 0.5f;
1749 islands_res[tindex][plidx_dst].
factor = hit_dist ? (best_nor_dot / hit_dist) : 1e18f;
1750 islands_res[tindex][plidx_dst].
hit_dist = hit_dist;
1751 islands_res[tindex][plidx_dst].
index_src = best_index_src;
1755 islands_res[tindex][plidx_dst].
factor = 0.0f;
1756 islands_res[tindex][plidx_dst].
hit_dist = FLT_MAX;
1757 islands_res[tindex][plidx_dst].
index_src = -1;
1768 if (space_transform) {
1775 tdata, &rayhit, tmp_co, tmp_no, ray_radius /
w, max_dist, &hit_dist)) {
1776 islands_res[tindex][plidx_dst].
factor = (hit_dist ? (1.0f / hit_dist) : 1e18f) *
w;
1777 islands_res[tindex][plidx_dst].
hit_dist = hit_dist;
1779 copy_v3_v3(islands_res[tindex][plidx_dst].hit_point, rayhit.
co);
1796 if (space_transform) {
1802 islands_res[tindex][plidx_dst].
factor = 0.0f;
1805 tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
1806 islands_res[tindex][plidx_dst].
hit_dist = hit_dist;
1808 copy_v3_v3(islands_res[tindex][plidx_dst].hit_point, nearest.
co);
1812 islands_res[tindex][plidx_dst].
hit_dist = FLT_MAX;
1813 islands_res[tindex][plidx_dst].
index_src = -1;
1822 if (space_transform) {
1827 tdata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
1828 islands_res[tindex][plidx_dst].
factor = hit_dist ? (1.0f / hit_dist) : 1e18f;
1829 islands_res[tindex][plidx_dst].
hit_dist = hit_dist;
1831 copy_v3_v3(islands_res[tindex][plidx_dst].hit_point, nearest.
co);
1835 islands_res[tindex][plidx_dst].
factor = 0.0f;
1836 islands_res[tindex][plidx_dst].
hit_dist = FLT_MAX;
1837 islands_res[tindex][plidx_dst].
index_src = -1;
1857 int *poly_island_index_map =
NULL;
1858 int pidx_src_prev = -1;
1861 float best_island_fac = 0.0f;
1862 int best_island_index = -1;
1864 for (tindex = 0; tindex < num_trees; tindex++) {
1865 float island_fac = 0.0f;
1867 for (plidx_dst = 0; plidx_dst < mp_dst->
totloop; plidx_dst++) {
1868 island_fac += islands_res[tindex][plidx_dst].
factor;
1872 if (island_fac > best_island_fac) {
1873 best_island_fac = island_fac;
1874 best_island_index = tindex;
1878 if (best_island_index != -1 && isld_steps_src) {
1879 best_island = use_islands ? island_store.
islands[best_island_index] :
NULL;
1880 as_graph = &as_graphdata[best_island_index];
1881 poly_island_index_map = (
int *)as_graph->
custom_data;
1885 for (plidx_dst = 0; plidx_dst < mp_dst->
totloop; plidx_dst++) {
1887 lidx_dst = plidx_dst + mp_dst->
loopstart;
1889 if (best_island_index == -1) {
1897 isld_res = &islands_res[best_island_index][plidx_dst];
1898 if (use_from_vert) {
1901 if (lidx_src >= 0) {
1902 pidx_src = loop_to_poly_map_src[lidx_src];
1904 if (!
ELEM(pidx_src_prev, -1, pidx_src) && isld_steps_src) {
1905 int pidx_isld_src, pidx_isld_src_prev;
1906 if (poly_island_index_map) {
1907 pidx_isld_src = poly_island_index_map[pidx_src];
1908 pidx_isld_src_prev = poly_island_index_map[pidx_src_prev];
1911 pidx_isld_src = pidx_src;
1912 pidx_isld_src_prev = pidx_src_prev;
1929 int last_valid_pidx_isld_src = -1;
1931 for (i = as_solution.
steps - 1; i--;) {
1934 pidx_isld_src = as_solution.
prev_nodes[pidx_isld_src];
1938 last_valid_pidx_isld_src = pidx_isld_src;
1941 if (last_valid_pidx_isld_src != -1) {
1945 float best_dist_sq = FLT_MAX;
1947 ml_dst = &loops_dst[lidx_dst];
1952 if (space_transform) {
1956 pidx_src = (use_islands ? best_island->
indices[last_valid_pidx_isld_src] :
1957 last_valid_pidx_isld_src);
1958 mp_src = &polys_src[pidx_src];
1960 for (j = 0; j < mp_src->
totloop; j++, ml_src++) {
1962 if (dist_sq < best_dist_sq) {
1963 best_dist_sq = dist_sq;
1977 pidx_src_prev = pidx_src;
1989 if (pidx_src >= 0) {
1991 int best_loop_index_src;
1993 mp_src = &polys_src[pidx_src];
1995 if (!
ELEM(pidx_src_prev, -1, pidx_src) && isld_steps_src) {
1996 int pidx_isld_src, pidx_isld_src_prev;
1997 if (poly_island_index_map) {
1998 pidx_isld_src = poly_island_index_map[pidx_src];
1999 pidx_isld_src_prev = poly_island_index_map[pidx_src_prev];
2002 pidx_isld_src = pidx_src;
2003 pidx_isld_src_prev = pidx_src_prev;
2020 int last_valid_pidx_isld_src = -1;
2022 for (i = as_solution.
steps - 1; i--;) {
2026 pidx_isld_src = as_solution.
prev_nodes[pidx_isld_src];
2030 last_valid_pidx_isld_src = pidx_isld_src;
2033 if (last_valid_pidx_isld_src != -1) {
2036 float best_dist_sq = FLT_MAX;
2039 ml_dst = &loops_dst[lidx_dst];
2044 if (space_transform) {
2048 pidx_src = (use_islands ? best_island->
indices[last_valid_pidx_isld_src] :
2049 last_valid_pidx_isld_src);
2050 mp_src = &polys_src[pidx_src];
2053 if (poly_to_looptri_map_src ==
NULL) {
2055 &poly_to_looptri_map_src_buff,
2062 for (j = poly_to_looptri_map_src[pidx_src].
count; j--;) {
2065 &looptri_src[poly_to_looptri_map_src[pidx_src].
indices[j]];
2070 vcos_src[loops_src[lt->
tri[0]].
v],
2071 vcos_src[loops_src[lt->
tri[1]].v],
2072 vcos_src[loops_src[lt->
tri[2]].v]);
2074 if (dist_sq < best_dist_sq) {
2076 best_dist_sq = dist_sq;
2086 (
const float(*)[3])vcos_src,
2094 &best_loop_index_src);
2101 &best_loop_index_src,
2108 (
const float(*)[3])vcos_src,
2127 pidx_src_prev = pidx_src;
2142 for (tindex = 0; tindex < num_trees; tindex++) {
2145 if (isld_steps_src) {
2152 if (isld_steps_src) {
2160 if (vert_to_loop_map_src) {
2163 if (vert_to_loop_map_src_buff) {
2166 if (vert_to_poly_map_src) {
2169 if (vert_to_poly_map_src_buff) {
2172 if (edge_to_poly_map_src) {
2175 if (edge_to_poly_map_src_buff) {
2178 if (poly_to_looptri_map_src) {
2181 if (poly_to_looptri_map_src_buff) {
2182 MEM_freeN(poly_to_looptri_map_src_buff);
2184 if (loop_to_poly_map_src) {
2187 if (poly_cents_src) {
2193 if (indices_interp) {
2196 if (weights_interp) {
2204 const float max_dist,
2205 const float ray_radius,
2207 const int numverts_dst,
2209 const int numloops_dst,
2211 const int numpolys_dst,
2213 const bool dirty_nors_dst,
2217 const float full_weight = 1.0f;
2218 const float max_dist_sq = max_dist * max_dist;
2220 float tmp_co[3], tmp_no[3];
2228 if (!poly_nors_dst) {
2232 if (dirty_nors_dst) {
2249 for (i = 0; i < numpolys_dst; i++) {
2264 for (i = 0; i < numpolys_dst; i++) {
2265 MPoly *mp = &polys_dst[i];
2270 if (space_transform) {
2275 &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) {
2277 const int poly_index = (int)lt->
poly;
2289 for (i = 0; i < numpolys_dst; i++) {
2290 MPoly *mp = &polys_dst[i];
2296 if (space_transform) {
2302 &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) {
2304 const int poly_index = (int)lt->
poly;
2321 const size_t numpolys_src = (size_t)me_src->
totpoly;
2325 float *weights =
MEM_mallocN(
sizeof(*weights) * numpolys_src, __func__);
2328 float(*poly_vcos_2d)[2] =
MEM_mallocN(
sizeof(*poly_vcos_2d) * tmp_poly_size, __func__);
2330 int(*tri_vidx_2d)[3] =
MEM_mallocN(
sizeof(*tri_vidx_2d) * (tmp_poly_size - 2), __func__);
2332 for (i = 0; i < numpolys_dst; i++) {
2336 MPoly *mp = &polys_dst[i];
2338 int tot_rays, done_rays = 0;
2339 float poly_area_2d_inv, done_area = 0.0f;
2342 float to_pnor_2d_mat[3][3], from_pnor_2d_mat[3][3];
2343 float poly_dst_2d_min[2], poly_dst_2d_max[2], poly_dst_2d_z;
2344 float poly_dst_2d_size[2];
2346 float totweights = 0.0f;
2347 float hit_dist_accum = 0.0f;
2348 int sources_num = 0;
2349 const int tris_num = mp->
totloop - 2;
2356 if (space_transform) {
2361 copy_vn_fl(weights, (
int)numpolys_src, 0.0f);
2364 tmp_poly_size = (size_t)mp->
totloop;
2365 poly_vcos_2d =
MEM_reallocN(poly_vcos_2d,
sizeof(*poly_vcos_2d) * tmp_poly_size);
2366 tri_vidx_2d =
MEM_reallocN(tri_vidx_2d,
sizeof(*tri_vidx_2d) * (tmp_poly_size - 2));
2373 poly_dst_2d_z = pcent_dst[2];
2378 for (j = 0; j < mp->
totloop; j++) {
2381 if (space_transform) {
2384 mul_v2_m3v3(poly_vcos_2d[j], to_pnor_2d_mat, tmp_co);
2385 minmax_v2v2_v2(poly_dst_2d_min, poly_dst_2d_max, poly_vcos_2d[j]);
2390 sub_v2_v2v2(poly_dst_2d_size, poly_dst_2d_max, poly_dst_2d_min);
2393 tot_rays = (int)((
max_ff(poly_dst_2d_size[0], poly_dst_2d_size[1]) / ray_radius) + 0.5f);
2400 tot_rays *= tot_rays;
2402 poly_area_2d_inv =
area_poly_v2((
const float(*)[2])poly_vcos_2d,
2405 poly_area_2d_inv = 1.0f /
max_ff(poly_area_2d_inv, 1e-9f);
2409 tri_vidx_2d[0][0] = 0;
2410 tri_vidx_2d[0][1] = 1;
2411 tri_vidx_2d[0][2] = 2;
2414 tri_vidx_2d[0][0] = 0;
2415 tri_vidx_2d[0][1] = 1;
2416 tri_vidx_2d[0][2] = 2;
2417 tri_vidx_2d[1][0] = 0;
2418 tri_vidx_2d[1][1] = 2;
2419 tri_vidx_2d[1][2] = 3;
2423 poly_vcos_2d, (
unsigned int)mp->
totloop, -1, (
unsigned int(*)[3])tri_vidx_2d);
2426 for (j = 0; j < tris_num; j++) {
2427 float *
v1 = poly_vcos_2d[tri_vidx_2d[j][0]];
2428 float *
v2 = poly_vcos_2d[tri_vidx_2d[j][1]];
2429 float *v3 = poly_vcos_2d[tri_vidx_2d[j][2]];
2436 (
int)((
float)tot_rays * done_area * poly_area_2d_inv + 0.5f) - done_rays, 0);
2437 done_rays += rays_num;
2439 while (rays_num--) {
2445 tmp_co[2] = poly_dst_2d_z;
2451 &treedata, &rayhit, tmp_co, tmp_no, ray_radius /
w, max_dist, &hit_dist)) {
2454 weights[lt->
poly] +=
w;
2456 hit_dist_accum += hit_dist;
2465 if (totweights > 0.0f) {
2466 for (j = 0; j < (int)numpolys_src; j++) {
2471 weights[sources_num] = weights[j] / totweights;
2476 r_map, i, hit_dist_accum / totweights, 0, sources_num,
indices, weights);
2491 CLOG_WARN(&
LOG,
"Unsupported mesh-to-mesh poly mapping mode (%d)!", mode);
2492 memset(r_map->
items, 0,
sizeof(*r_map->
items) * (
size_t)numpolys_dst);
2499 #undef MREMAP_RAYCAST_APPROXIMATE_NR
2500 #undef MREMAP_RAYCAST_APPROXIMATE_FAC
2501 #undef MREMAP_RAYCAST_TRI_SAMPLES_MIN
2502 #undef MREMAP_RAYCAST_TRI_SAMPLES_MAX
2503 #undef MREMAP_DEFAULT_BUFSIZE
typedef float(TangentPoint)[2]
BVHTree * BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, struct Mesh *mesh, const BVHCacheType bvh_cache_type, const int tree_type)
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
BVHTree * bvhtree_from_mesh_verts_ex(struct BVHTreeFromMesh *data, const struct MVert *vert, const int verts_num, const bool vert_allocated, const BLI_bitmap *mask, int verts_num_active, float epsilon, int tree_type, int axis, const BVHCacheType bvh_cache_type, struct BVHCache **bvh_cache_p, ThreadMutex *mesh_eval_mutex)
BVHTree * bvhtree_from_mesh_looptri_ex(struct BVHTreeFromMesh *data, const struct MVert *vert, const bool vert_allocated, const struct MLoop *mloop, const bool loop_allocated, const struct MLoopTri *looptri, const int looptri_num, const bool looptri_allocated, const BLI_bitmap *mask, int looptri_num_active, float epsilon, int tree_type, int axis, const BVHCacheType bvh_cache_type, struct BVHCache **bvh_cache_p, ThreadMutex *mesh_eval_mutex)
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer(const struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
void CustomData_set_layer_flag(struct CustomData *data, int type, int flag)
int BKE_mesh_edge_other_vert(const struct MEdge *e, int v)
void BKE_mesh_calc_poly_center(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray, float r_cent[3])
void BKE_mesh_normals_loop_split(const struct MVert *mverts, const int numVerts, struct MEdge *medges, const int numEdges, struct MLoop *mloops, float(*r_loopnors)[3], const int numLoops, struct MPoly *mpolys, const float(*polynors)[3], const int numPolys, const bool use_split_normals, const float split_angle, MLoopNorSpaceArray *r_lnors_spacearr, short(*clnors_data)[2], int *r_loop_to_poly)
float(* BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3]
void BKE_mesh_calc_normals_poly(struct MVert *mverts, float(*r_vertnors)[3], int numVerts, const struct MLoop *mloop, const struct MPoly *mpolys, int numLoops, int numPolys, float(*r_polyNors)[3], const bool only_face_normals)
bool(* MeshRemapIslandsCalc)(struct MVert *verts, const int totvert, struct MEdge *edges, const int totedge, struct MPoly *polys, const int totpoly, struct MLoop *loops, const int totloop, struct MeshIslandStore *r_island_store)
void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, const int totedge, const struct MPoly *mpoly, const int totpoly, const struct MLoop *mloop, const int totloop)
void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const struct MLoop *mloop, int totvert, int totpoly, int totloop)
void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const struct MLoop *mloop, int totvert, int totpoly, int totloop)
void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totvert, int totedge)
void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const int mpoly_num, const struct MLoopTri *looptri, const int looptri_num)
void BKE_mesh_loop_islands_free(MeshIslandStore *island_store)
@ MREMAP_MODE_VERT_EDGE_NEAREST
@ MREMAP_MODE_VERT_POLYINTERP_VNORPROJ
@ MREMAP_MODE_EDGE_POLY_NEAREST
@ MREMAP_MODE_VERT_EDGEINTERP_NEAREST
@ MREMAP_MODE_VERT_NEAREST
@ MREMAP_MODE_LOOP_NEAREST_POLYNOR
@ MREMAP_MODE_EDGE_VERT_NEAREST
@ MREMAP_MODE_EDGE_NEAREST
@ MREMAP_MODE_LOOP_NEAREST_LOOPNOR
@ MREMAP_MODE_LOOP_POLY_NEAREST
@ MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ
@ MREMAP_MODE_POLY_POLYINTERP_PNORPROJ
@ MREMAP_MODE_VERT_POLY_NEAREST
@ MREMAP_MODE_POLY_NEAREST
@ MREMAP_MODE_VERT_POLYINTERP_NEAREST
const struct MLoopTri * BKE_mesh_runtime_looptri_ensure(struct Mesh *mesh)
#define BLI_array_alloca(arr, realsize)
An implementation of the A* (AStar) algorithm to solve shortest path problem.
void BLI_astar_graph_init(BLI_AStarGraph *as_graph, const int node_num, void *custom_data)
void BLI_astar_solution_clear(BLI_AStarSolution *as_solution)
void BLI_astar_node_init(BLI_AStarGraph *as_graph, const int node_index, void *custom_data)
void BLI_astar_solution_init(BLI_AStarGraph *as_graph, BLI_AStarSolution *as_solution, void *custom_data)
void BLI_astar_node_link_add(BLI_AStarGraph *as_graph, const int node1_index, const int node2_index, const float cost, void *custom_data)
bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph, const int node_index_src, const int node_index_dst, astar_f_cost f_cost_cb, BLI_AStarSolution *r_solution, const int max_steps)
void BLI_astar_solution_free(BLI_AStarSolution *as_solution)
void BLI_astar_graph_free(BLI_AStarGraph *as_graph)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
MINLINE float sqrtf_signed(float f)
MINLINE int compare_ff_relative(float a, float b, const float max_diff, const int max_ulps)
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])
MINLINE float area_tri_v2(const float v1[2], const float v2[2], const float v3[2])
void interp_weights_poly_v3(float w[], float v[][3], const int n, const float co[3])
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
void axis_dominant_v3_to_m3(float r_mat[3][3], const float normal[3])
Normal to x,y matrix.
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
float area_poly_v2(const float verts[][2], unsigned int nr)
void mul_m3_v3(const float M[3][3], float r[3])
void BLI_space_transform_apply_normal(const struct SpaceTransform *data, float no[3])
void BLI_space_transform_apply(const struct SpaceTransform *data, float co[3])
void unit_m3(float m[3][3])
void mul_v2_m3v3(float r[2], const float M[3][3], const float a[3])
void unit_m4(float m[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void BLI_space_transform_global_from_matrices(struct SpaceTransform *data, const float local[4][4], const float target[4][4])
bool invert_m3_m3(float R[3][3], const float A[3][3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool BLI_eigen_solve_selfadjoint_m3(const float m3[3][3], float r_eigen_values[3], float r_eigen_vectors[3][3])
Compute the eigen values and/or vectors of given 3D symmetric (aka adjoint) matrix.
void BLI_covariance_m3_v3n(const float(*cos_v3)[3], const int nbr_cos_v3, const bool use_sample_correction, float r_covmat[3][3], float r_center[3])
Compute the covariance matrix of given set of 3D coordinates.
void copy_vn_fl(float *array_tar, const int size, const float val)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void normal_short_to_float_v3(float r[3], const short n[3])
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 minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
void interp_v3_v3v3_slerp_safe(float target[3], const float a[3], const float b[3], const float t)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
struct MemArena * BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC
void * BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_polyfill_calc(const float(*coords)[2], const unsigned int coords_tot, const int coords_sign, unsigned int(*r_tris)[3])
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
struct RNG * BLI_rng_new(unsigned int seed)
void void void BLI_rng_get_tri_sample_float_v2(struct RNG *rng, const float v1[2], const float v2[2], const float v3[2], float r_pt[2]) ATTR_NONNULL()
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
#define INIT_MINMAX2(min, max)
#define POINTER_FROM_INT(i)
#define UNUSED_VARS_NDEBUG(...)
#define POINTER_AS_INT(i)
#define CLOG_WARN(clg_ref,...)
NSNotificationCenter * center
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
Group RGB to Bright Vector Camera CLAMP
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
#define MREMAP_RAYCAST_TRI_SAMPLES_MIN
static int mesh_remap_interp_poly_data_get(const MPoly *mp, MLoop *mloops, const float(*vcos_src)[3], const float point[3], size_t *buff_size, float(**vcos)[3], const bool use_loops, int **indices, float **weights, const bool do_weights, int *r_closest_index)
void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst, const int numverts_dst, Mesh *me_src, SpaceTransform *r_space_transform)
#define MREMAP_RAYCAST_TRI_SAMPLES_MAX
void BKE_mesh_remap_calc_polys_from_mesh(const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, MVert *verts_dst, const int numverts_dst, MLoop *loops_dst, const int numloops_dst, MPoly *polys_dst, const int numpolys_dst, CustomData *pdata_dst, const bool dirty_nors_dst, Mesh *me_src, MeshPairRemap *r_map)
void BKE_mesh_remap_calc_verts_from_mesh(const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, const MVert *verts_dst, const int numverts_dst, const bool UNUSED(dirty_nors_dst), Mesh *me_src, MeshPairRemap *r_map)
void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(const int UNUSED(vert_mode), const int UNUSED(edge_mode), const int loop_mode, const int UNUSED(poly_mode), CustomData_MeshMasks *r_cddata_mask)
void BKE_mesh_remap_free(MeshPairRemap *map)
#define MREMAP_RAYCAST_APPROXIMATE_NR
void BKE_mesh_remap_item_define_invalid(MeshPairRemap *map, const int index)
struct IslandResult IslandResult
static void mesh_calc_eigen_matrix(const MVert *verts, const float(*vcos)[3], const int numverts, float r_mat[4][4])
void BKE_mesh_remap_calc_loops_from_mesh(const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, MVert *verts_dst, const int numverts_dst, MEdge *edges_dst, const int numedges_dst, MLoop *loops_dst, const int numloops_dst, MPoly *polys_dst, const int numpolys_dst, CustomData *ldata_dst, CustomData *pdata_dst, const bool use_split_nors_dst, const float split_angle_dst, const bool dirty_nors_dst, Mesh *me_src, MeshRemapIslandsCalc gen_islands_src, const float islands_precision_src, MeshPairRemap *r_map)
#define MREMAP_RAYCAST_APPROXIMATE_FAC
static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands, const int island_index, BLI_AStarGraph *as_graph, MVert *verts, MPoly *polys, MLoop *loops, const int edge_idx, BLI_bitmap *done_edges, MeshElemMap *edge_to_poly_map, const bool is_edge_innercut, const int *poly_island_index_map, float(*poly_centers)[3], unsigned char *poly_status)
static float mesh_remap_calc_loops_astar_f_cost(BLI_AStarGraph *as_graph, BLI_AStarSolution *as_solution, BLI_AStarGNLink *link, const int node_idx_curr, const int node_idx_next, const int node_idx_dst)
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform, const MVert *verts_dst, const int numverts_dst, Mesh *me_src)
static void mesh_remap_item_define(MeshPairRemap *map, const int index, const float UNUSED(hit_dist), const int island, const int sources_num, const int *indices_src, const float *weights_src)
#define MREMAP_DEFAULT_BUFSIZE
static bool mesh_remap_bvhtree_query_nearest(BVHTreeFromMesh *treedata, BVHTreeNearest *nearest, const float co[3], const float max_dist_sq, float *r_hit_dist)
static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata, BVHTreeRayHit *rayhit, const float co[3], const float no[3], const float radius, const float max_dist, float *r_hit_dist)
static void mesh_island_to_astar_graph(MeshIslandStore *islands, const int island_index, MVert *verts, MeshElemMap *edge_to_poly_map, const int numedges, MLoop *loops, MPoly *polys, const int numpolys, BLI_AStarGraph *r_as_graph)
void BKE_mesh_remap_calc_edges_from_mesh(const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, const MVert *verts_dst, const int numverts_dst, const MEdge *edges_dst, const int numedges_dst, const bool UNUSED(dirty_nors_dst), Mesh *me_src, MeshPairRemap *r_map)
void BKE_mesh_remap_init(MeshPairRemap *map, const int items_num)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
BLI_AStarGNLink ** prev_links
BVHTree_RayCastCallback raycast_callback
BVHTree_NearestPointCallback nearest_callback
const struct MLoopTri * looptri
struct MeshElemMap ** innercuts
struct MeshElemMap ** islands
MeshPairRemapItem * items
struct MLoopTri_Store looptris
struct CustomData pdata ldata
ccl_device_inline float dot(const float2 &a, const float2 &b)