diff options
author | Hans Goudey <h.goudey@me.com> | 2022-07-24 02:32:29 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-07-24 02:32:29 +0300 |
commit | 5c8e367f1424de44169fe6d27e3ac56540ddf395 (patch) | |
tree | 9bb06d49af3d961e87803a734f7d61fa86fb5609 /source/blender/blenkernel/intern/mesh_remap.c | |
parent | af71f0814ddfc3c1b08b92a46579215b054b5e45 (diff) |
Progress
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_remap.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_remap.c | 72 |
1 files changed, 37 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c index 24ac9238a66..84926dedd7b 100644 --- a/source/blender/blenkernel/intern/mesh_remap.c +++ b/source/blender/blenkernel/intern/mesh_remap.c @@ -382,7 +382,7 @@ void BKE_mesh_remap_item_define_invalid(MeshPairRemap *map, const int index) } static int mesh_remap_interp_poly_data_get(const MPoly *mp, - MLoop *mloops, + const MLoop *mloops, const float (*vcos_src)[3], const float point[3], size_t *buff_size, @@ -393,7 +393,7 @@ static int mesh_remap_interp_poly_data_get(const MPoly *mp, const bool do_weights, int *r_closest_index) { - MLoop *ml; + const MLoop *ml; float(*vco)[3]; float ref_dist_sq = FLT_MAX; int *index; @@ -525,7 +525,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, } } else if (ELEM(mode, MREMAP_MODE_VERT_EDGE_NEAREST, MREMAP_MODE_VERT_EDGEINTERP_NEAREST)) { - MEdge *edges_src = BKE_mesh_edges(me_src); + const MEdge *edges_src = BKE_mesh_edges(me_src); float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL); BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_EDGES, 2); @@ -541,7 +541,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, if (mesh_remap_bvhtree_query_nearest( &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { - MEdge *me = &edges_src[nearest.index]; + const MEdge *me = &edges_src[nearest.index]; const float *v1cos = vcos_src[me->v1]; const float *v2cos = vcos_src[me->v2]; @@ -578,8 +578,8 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, MREMAP_MODE_VERT_POLY_NEAREST, MREMAP_MODE_VERT_POLYINTERP_NEAREST, MREMAP_MODE_VERT_POLYINTERP_VNORPROJ)) { - MPoly *polys_src = BKE_mesh_polygons(me_src); - MLoop *loops_src = BKE_mesh_loops(me_src); + const MPoly *polys_src = BKE_mesh_polygons(me_src); + const MLoop *loops_src = BKE_mesh_loops(me_src); float(*vcos_src)[3] = BKE_mesh_vert_coords_alloc(me_src, NULL); const float(*vert_normals_dst)[3] = BKE_mesh_vertex_normals_ensure(me_dst); @@ -604,7 +604,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, if (mesh_remap_bvhtree_query_raycast( &treedata, &rayhit, tmp_co, tmp_no, ray_radius, max_dist, &hit_dist)) { const MLoopTri *lt = &treedata.looptri[rayhit.index]; - MPoly *mp_src = &polys_src[lt->poly]; + const MPoly *mp_src = &polys_src[lt->poly]; const int sources_num = mesh_remap_interp_poly_data_get(mp_src, loops_src, (const float(*)[3])vcos_src, @@ -639,7 +639,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode, if (mesh_remap_bvhtree_query_nearest( &treedata, &nearest, tmp_co, max_dist_sq, &hit_dist)) { const MLoopTri *lt = &treedata.looptri[nearest.index]; - MPoly *mp = &polys_src[lt->poly]; + const MPoly *mp = &polys_src[lt->poly]; if (mode == MREMAP_MODE_VERT_POLY_NEAREST) { int index; @@ -1046,9 +1046,9 @@ 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, - MVert *verts, - MPoly *polys, - MLoop *loops, + const MVert *verts, + const MPoly *polys, + const MLoop *loops, const int edge_idx, BLI_bitmap *done_edges, MeshElemMap *edge_to_poly_map, @@ -1063,7 +1063,7 @@ static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands, for (i = 0; i < edge_to_poly_map[edge_idx].count; i++) { const int pidx = edge_to_poly_map[edge_idx].indices[i]; - MPoly *mp = &polys[pidx]; + const MPoly *mp = &polys[pidx]; const int pidx_isld = islands ? poly_island_index_map[pidx] : pidx; void *custom_data = is_edge_innercut ? POINTER_FROM_INT(edge_idx) : POINTER_FROM_INT(-1); @@ -1104,11 +1104,11 @@ static void mesh_island_to_astar_graph_edge_process(MeshIslandStore *islands, static void mesh_island_to_astar_graph(MeshIslandStore *islands, const int island_index, - MVert *verts, + const MVert *verts, MeshElemMap *edge_to_poly_map, const int numedges, - MLoop *loops, - MPoly *polys, + const MLoop *loops, + const MPoly *polys, const int numpolys, BLI_AStarGraph *r_as_graph) { @@ -1158,7 +1158,7 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands, for (pidx_isld = node_num; pidx_isld--;) { const int pidx = islands ? island_poly_map->indices[pidx_isld] : pidx_isld; - MPoly *mp = &polys[pidx]; + const MPoly *mp = &polys[pidx]; int pl_idx, l_idx; if (poly_status[pidx_isld] == POLY_COMPLETE) { @@ -1166,7 +1166,7 @@ static void mesh_island_to_astar_graph(MeshIslandStore *islands, } for (pl_idx = 0, l_idx = mp->loopstart; pl_idx < mp->totloop; pl_idx++, l_idx++) { - MLoop *ml = &loops[l_idx]; + const MLoop *ml = &loops[l_idx]; if (BLI_BITMAP_TEST(done_edges, ml->e)) { continue; @@ -1234,13 +1234,13 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode, const float max_dist, const float ray_radius, Mesh *mesh_dst, - MVert *verts_dst, + const MVert *verts_dst, const int numverts_dst, - MEdge *edges_dst, + const MEdge *edges_dst, const int numedges_dst, - MLoop *loops_dst, + const MLoop *loops_dst, const int numloops_dst, - MPoly *polys_dst, + const MPoly *polys_dst, const int numpolys_dst, CustomData *ldata_dst, const bool use_split_nors_dst, @@ -1307,14 +1307,14 @@ 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; - MVert *verts_src = BKE_mesh_vertices(me_src); + const MVert *verts_src = BKE_mesh_vertices(me_src); const int num_verts_src = me_src->totvert; float(*vcos_src)[3] = NULL; - MEdge *edges_src = BKE_mesh_edges(me_src); + const MEdge *edges_src = BKE_mesh_edges(me_src); const int num_edges_src = me_src->totedge; - MLoop *loops_src = BKE_mesh_loops(me_src); + const MLoop *loops_src = BKE_mesh_loops(me_src); const int num_loops_src = me_src->totloop; - MPoly *polys_src = BKE_mesh_polygons(me_src); + const MPoly *polys_src = BKE_mesh_polygons(me_src); const int num_polys_src = me_src->totpoly; const MLoopTri *looptri_src = NULL; int num_looptri_src = 0; @@ -1324,8 +1324,10 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode, int *indices_interp = NULL; float *weights_interp = NULL; - MLoop *ml_src, *ml_dst; - MPoly *mp_src, *mp_dst; + const MLoop *ml_src; + const MLoop *ml_dst; + const MPoly *mp_src; + const MPoly *mp_dst; int tindex, pidx_dst, lidx_dst, plidx_dst, pidx_src, lidx_src, plidx_src; IslandResult **islands_res; @@ -2153,10 +2155,10 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, const SpaceTransform *space_transform, const float max_dist, const float ray_radius, - Mesh *mesh_dst, - MVert *verts_dst, - MLoop *loops_dst, - MPoly *polys_dst, + const Mesh *mesh_dst, + const MVert *verts_dst, + const MLoop *loops_dst, + const MPoly *polys_dst, const int numpolys_dst, Mesh *me_src, MeshPairRemap *r_map) @@ -2193,7 +2195,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, nearest.index = -1; for (i = 0; i < numpolys_dst; i++) { - MPoly *mp = &polys_dst[i]; + const MPoly *mp = &polys_dst[i]; BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], verts_dst, tmp_co); @@ -2218,7 +2220,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, BLI_assert(poly_nors_dst); for (i = 0; i < numpolys_dst; i++) { - MPoly *mp = &polys_dst[i]; + const MPoly *mp = &polys_dst[i]; BKE_mesh_calc_poly_center(mp, &loops_dst[mp->loopstart], verts_dst, tmp_co); copy_v3_v3(tmp_no, poly_nors_dst[i]); @@ -2264,7 +2266,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, /* For each dst poly, we sample some rays from it (2D grid in pnor space) * and use their hits to interpolate from source polys. */ /* NOTE: dst poly is early-converted into src space! */ - MPoly *mp = &polys_dst[i]; + const MPoly *mp = &polys_dst[i]; int tot_rays, done_rays = 0; float poly_area_2d_inv, done_area = 0.0f; @@ -2307,7 +2309,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode, INIT_MINMAX2(poly_dst_2d_min, poly_dst_2d_max); for (j = 0; j < mp->totloop; j++) { - MLoop *ml = &loops_dst[j + mp->loopstart]; + const MLoop *ml = &loops_dst[j + mp->loopstart]; copy_v3_v3(tmp_co, verts_dst[ml->v].co); if (space_transform) { BLI_space_transform_apply(space_transform, tmp_co); |