Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_remap.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c103
1 files changed, 52 insertions, 51 deletions
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index 90798ea593d..6d7c79ddbfc 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -110,7 +110,7 @@ static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
* \{ */
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform,
- const MVert *verts_dst,
+ const float (*positions_dst)[3],
const int numverts_dst,
Mesh *me_src)
{
@@ -127,7 +127,7 @@ float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_trans
for (i = 0; i < numverts_dst; i++) {
float tmp_co[3];
- copy_v3_v3(tmp_co, verts_dst[i].co);
+ copy_v3_v3(tmp_co, positions_dst[i]);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -164,7 +164,7 @@ float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_trans
* axes in those cases. We default to dummy generated orthogonal vectors in this case,
* instead of using eigen vectors.
*/
-static void mesh_calc_eigen_matrix(const MVert *verts,
+static void mesh_calc_eigen_matrix(const float (*positions)[3],
const float (*vcos)[3],
const int numverts,
float r_mat[4][4])
@@ -176,13 +176,12 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
bool eigen_success;
int i;
- if (verts) {
- const MVert *mv;
+ if (positions) {
float(*co)[3];
cos = MEM_mallocN(sizeof(*cos) * (size_t)numverts, __func__);
- for (i = 0, co = cos, mv = verts; i < numverts; i++, co++, mv++) {
- copy_v3_v3(*co, mv->co);
+ for (i = 0, co = cos; i < numverts; i++, co++) {
+ copy_v3_v3(*co, positions[i]);
}
/* TODO(sergey): For until we officially drop all compilers which
* doesn't handle casting correct we use workaround to avoid explicit
@@ -244,7 +243,7 @@ static void mesh_calc_eigen_matrix(const MVert *verts,
copy_v3_v3(r_mat[3], center);
}
-void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
+void BKE_mesh_remap_find_best_match_from_mesh(const float (*positions_dst)[3],
const int numverts_dst,
Mesh *me_src,
SpaceTransform *r_space_transform)
@@ -270,11 +269,11 @@ void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL);
mesh_calc_eigen_matrix(NULL, (const float(*)[3])vcos_src, numverts_src, mat_src);
- mesh_calc_eigen_matrix(verts_dst, NULL, numverts_dst, mat_dst);
+ mesh_calc_eigen_matrix(positions_dst, NULL, numverts_dst, mat_dst);
BLI_space_transform_global_from_matrices(r_space_transform, mat_dst, mat_src);
match = BKE_mesh_remap_calc_difference_from_mesh(
- r_space_transform, verts_dst, numverts_dst, me_src);
+ r_space_transform, positions_dst, numverts_dst, me_src);
best_match = match;
copy_m4_m4(best_mat_dst, mat_dst);
@@ -286,7 +285,7 @@ void BKE_mesh_remap_find_best_match_from_mesh(const MVert *verts_dst,
BLI_space_transform_global_from_matrices(r_space_transform, mat_dst, mat_src);
match = BKE_mesh_remap_calc_difference_from_mesh(
- r_space_transform, verts_dst, numverts_dst, me_src);
+ r_space_transform, positions_dst, numverts_dst, me_src);
if (match < best_match) {
best_match = match;
copy_m4_m4(best_mat_dst, mat_dst);
@@ -469,7 +468,7 @@ 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 float (*positions_dst)[3],
const int numverts_dst,
const bool UNUSED(dirty_nors_dst),
Mesh *me_src,
@@ -502,7 +501,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
- copy_v3_v3(tmp_co, verts_dst[i].co);
+ copy_v3_v3(tmp_co, positions_dst[i]);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -527,7 +526,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
- copy_v3_v3(tmp_co, verts_dst[i].co);
+ copy_v3_v3(tmp_co, positions_dst[i]);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -587,7 +586,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) {
for (i = 0; i < numverts_dst; i++) {
- copy_v3_v3(tmp_co, verts_dst[i].co);
+ copy_v3_v3(tmp_co, positions_dst[i]);
copy_v3_v3(tmp_no, vert_normals_dst[i]);
/* Convert the vertex to tree coordinates, if needed. */
@@ -624,7 +623,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
nearest.index = -1;
for (i = 0; i < numverts_dst; i++) {
- copy_v3_v3(tmp_co, verts_dst[i].co);
+ copy_v3_v3(tmp_co, positions_dst[i]);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -693,7 +692,7 @@ 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 float (*positions_dst)[3],
const int numverts_dst,
const MEdge *edges_dst,
const int numedges_dst,
@@ -762,7 +761,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
/* Compute closest verts only once! */
if (v_dst_to_src_map[vidx_dst].hit_dist == -1.0f) {
- copy_v3_v3(tmp_co, verts_dst[vidx_dst].co);
+ copy_v3_v3(tmp_co, positions_dst[vidx_dst]);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -800,7 +799,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
const MEdge *e_src = &edges_src[*eidx_src];
const float *other_co_src = vcos_src[BKE_mesh_edge_other_vert(e_src, vidx_src)];
const float *other_co_dst =
- verts_dst[BKE_mesh_edge_other_vert(e_dst, (int)vidx_dst)].co;
+ positions_dst[BKE_mesh_edge_other_vert(e_dst, (int)vidx_dst)];
const float totdist = first_dist + len_v3v3(other_co_src, other_co_dst);
if (totdist < best_totdist) {
@@ -813,8 +812,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
if (best_eidx_src >= 0) {
const float *co1_src = vcos_src[edges_src[best_eidx_src].v1];
const float *co2_src = vcos_src[edges_src[best_eidx_src].v2];
- const float *co1_dst = verts_dst[e_dst->v1].co;
- const float *co2_dst = verts_dst[e_dst->v2].co;
+ const float *co1_dst = positions_dst[e_dst->v1];
+ const float *co2_dst = positions_dst[e_dst->v2];
float co_src[3], co_dst[3];
/* TODO: would need an isect_seg_seg_v3(), actually! */
@@ -855,7 +854,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
nearest.index = -1;
for (i = 0; i < numedges_dst; i++) {
- interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].v1].co, verts_dst[edges_dst[i].v2].co, 0.5f);
+ interp_v3_v3v3(
+ tmp_co, positions_dst[edges_dst[i].v1], positions_dst[edges_dst[i].v2], 0.5f);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -881,7 +881,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2);
for (i = 0; i < numedges_dst; i++) {
- interp_v3_v3v3(tmp_co, verts_dst[edges_dst[i].v1].co, verts_dst[edges_dst[i].v2].co, 0.5f);
+ interp_v3_v3v3(
+ tmp_co, positions_dst[edges_dst[i].v1], positions_dst[edges_dst[i].v2], 0.5f);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -953,8 +954,8 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
int sources_num = 0;
int j;
- copy_v3_v3(v1_co, verts_dst[me->v1].co);
- copy_v3_v3(v2_co, verts_dst[me->v2].co);
+ copy_v3_v3(v1_co, positions_dst[me->v1]);
+ copy_v3_v3(v2_co, positions_dst[me->v2]);
copy_v3_v3(v1_no, vert_normals_dst[me->v1]);
copy_v3_v3(v2_no, vert_normals_dst[me->v2]);
@@ -1041,7 +1042,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands,
const int island_index,
BLI_AStarGraph *as_graph,
- const MVert *verts,
+ const float (*positions)[3],
const MPoly *polys,
const MLoop *loops,
const int edge_idx,
@@ -1074,7 +1075,7 @@ static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands,
}
if (poly_status[pidx_isld] == POLY_UNSET) {
- BKE_mesh_calc_poly_center(mp, &loops[mp->loopstart], verts, poly_centers[pidx_isld]);
+ BKE_mesh_calc_poly_center(mp, &loops[mp->loopstart], positions, poly_centers[pidx_isld]);
BLI_astar_node_init(as_graph, pidx_isld, poly_centers[pidx_isld]);
poly_status[pidx_isld] = POLY_CENTER_INIT;
}
@@ -1099,7 +1100,7 @@ static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands,
static void mesh_island_to_astar_graph(MeshIslandStore *islands,
const int island_index,
- const MVert *verts,
+ const float (*positions)[3],
MeshElemMap *edge_to_poly_map,
const int numedges,
const MLoop *loops,
@@ -1138,7 +1139,7 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands,
mesh_island_to_astar_graph_edge_process(islands,
island_index,
r_as_graph,
- verts,
+ positions,
polys,
loops,
island_einnercut_map->indices[i],
@@ -1170,7 +1171,7 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands,
mesh_island_to_astar_graph_edge_process(islands,
island_index,
r_as_graph,
- verts,
+ positions,
polys,
loops,
(int)ml->e,
@@ -1229,7 +1230,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
const float max_dist,
const float ray_radius,
Mesh *mesh_dst,
- const MVert *verts_dst,
+ const float (*positions_dst)[3],
const int numverts_dst,
const MEdge *edges_dst,
const int numedges_dst,
@@ -1302,7 +1303,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* Unlike above, those are one-to-one mappings, simpler! */
int *loop_to_poly_map_src = NULL;
- const MVert *verts_src = BKE_mesh_verts(me_src);
+ const float(*positions_src)[3] = BKE_mesh_positions(me_src);
const int num_verts_src = me_src->totvert;
float(*vcos_src)[3] = NULL;
const MEdge *edges_src = BKE_mesh_edges(me_src);
@@ -1358,7 +1359,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst || do_loop_nors_dst) {
- BKE_mesh_normals_loop_split(verts_dst,
+ BKE_mesh_normals_loop_split(positions_dst,
BKE_mesh_vertex_normals_ensure(mesh_dst),
numverts_dst,
edges_dst,
@@ -1425,7 +1426,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
plidx_src++, lidx_src++) {
loop_to_poly_map_src[lidx_src] = pidx_src;
}
- BKE_mesh_calc_poly_center(mp_src, ml_src, verts_src, poly_cents_src[pidx_src]);
+ BKE_mesh_calc_poly_center(mp_src, ml_src, positions_src, poly_cents_src[pidx_src]);
}
}
@@ -1438,7 +1439,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
/* First, generate the islands, if possible. */
if (gen_islands_src) {
- use_islands = gen_islands_src(verts_src,
+ use_islands = gen_islands_src(positions_src,
num_verts_src,
edges_src,
num_edges_src,
@@ -1476,7 +1477,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
for (tindex = 0; tindex < num_trees; tindex++) {
mesh_island_to_astar_graph(use_islands ? &island_store : NULL,
tindex,
- verts_src,
+ positions_src,
edge_to_poly_map_src,
num_edges_src,
loops_src,
@@ -1507,7 +1508,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
}
bvhtree_from_mesh_verts_ex(&treedata[tindex],
- verts_src,
+ positions_src,
num_verts_src,
verts_active,
num_verts_active,
@@ -1543,7 +1544,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
}
bvhtree_from_mesh_looptri_ex(&treedata[tindex],
- verts_src,
+ positions_src,
loops_src,
looptri_src,
num_looptri_src,
@@ -1599,7 +1600,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (use_from_vert) {
MeshElemMap *vert_to_refelem_map_src = NULL;
- copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml_dst->v]);
nearest.index = -1;
/* Convert the vertex to tree coordinates, if needed. */
@@ -1662,7 +1663,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (!pcent_dst_valid) {
BKE_mesh_calc_poly_center(
- mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst);
+ mp_dst, &loops_dst[mp_dst->loopstart], positions_dst, pcent_dst);
pcent_dst_valid = true;
}
pcent_src = poly_cents_src[pidx_src];
@@ -1708,7 +1709,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
int n = (ray_radius > 0.0f) ? MREMAP_RAYCAST_APPROXIMATE_NR : 1;
float w = 1.0f;
- copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml_dst->v]);
copy_v3_v3(tmp_no, loop_nors_dst[plidx_dst + mp_dst->loopstart]);
/* We do our transform here, since we may do several raycast/nearest queries. */
@@ -1736,7 +1737,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
* is null, it means none of its loop mapped to this source island,
* hence we can skip it later.
*/
- copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml_dst->v]);
nearest.index = -1;
/* Convert the vertex to tree coordinates, if needed. */
@@ -1762,7 +1763,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
}
}
else { /* Nearest poly either to use all its loops/verts or just closest one. */
- copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml_dst->v]);
nearest.index = -1;
/* Convert the vertex to tree coordinates, if needed. */
@@ -1892,7 +1893,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
float best_dist_sq = FLT_MAX;
ml_dst = &loops_dst[lidx_dst];
- copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml_dst->v]);
/* We do our transform here,
* since we may do several raycast/nearest queries. */
@@ -1905,7 +1906,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
mp_src = &polys_src[pidx_src];
ml_src = &loops_src[mp_src->loopstart];
for (j = 0; j < mp_src->totloop; j++, ml_src++) {
- const float dist_sq = len_squared_v3v3(verts_src[ml_src->v].co, tmp_co);
+ const float dist_sq = len_squared_v3v3(positions_src[ml_src->v], tmp_co);
if (dist_sq < best_dist_sq) {
best_dist_sq = dist_sq;
lidx_src = mp_src->loopstart + j;
@@ -1984,7 +1985,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
int j;
ml_dst = &loops_dst[lidx_dst];
- copy_v3_v3(tmp_co, verts_dst[ml_dst->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml_dst->v]);
/* We do our transform here,
* since we may do several raycast/nearest queries. */
@@ -2151,7 +2152,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
const float max_dist,
const float ray_radius,
const Mesh *mesh_dst,
- const MVert *verts_dst,
+ const float (*positions_dst)[3],
const MLoop *loops_dst,
const MPoly *polys_dst,
const int numpolys_dst,
@@ -2192,7 +2193,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
for (i = 0; i < numpolys_dst; i++) {
const MPoly *mp = &polys_dst[i];
- BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], verts_dst, tmp_co);
+ BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], positions_dst, tmp_co);
/* Convert the vertex to tree coordinates, if needed. */
if (space_transform) {
@@ -2217,7 +2218,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
for (i = 0; i < numpolys_dst; i++) {
const MPoly *mp = &polys_dst[i];
- BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], verts_dst, tmp_co);
+ BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], positions_dst, tmp_co);
copy_v3_v3(tmp_no, poly_nors_dst[i]);
/* Convert the vertex to tree coordinates, if needed. */
@@ -2277,7 +2278,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
const int tris_num = mp->totloop - 2;
int j;
- BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], verts_dst, pcent_dst);
+ BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], positions_dst, pcent_dst);
copy_v3_v3(tmp_no, poly_nors_dst[i]);
/* We do our transform here, else it'd be redone by raycast helper for each ray, ugh! */
@@ -2305,7 +2306,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
for (j = 0; j < mp->totloop; j++) {
const MLoop *ml = &loops_dst[j + mp->loopstart];
- copy_v3_v3(tmp_co, verts_dst[ml->v].co);
+ copy_v3_v3(tmp_co, positions_dst[ml->v]);
if (space_transform) {
BLI_space_transform_apply(space_transform, tmp_co);
}