Blender V4.3
BKE_mesh_remap.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include "BLI_math_matrix.h"
12#include "BLI_math_rotation.h"
14#include "BLI_offset_indices.hh"
15
16#include "BKE_mesh_mapping.hh"
17
18struct MemArena;
19struct Mesh;
20
21/* Generic ways to map some geometry elements from a source mesh to a destination one. */
22
25 int *indices_src; /* NULL if no source found. */
26 float *weights_src; /* NULL if no source found, else, always normalized! */
27 /* UNUSED (at the moment). */
28 // float hit_dist; /* FLT_MAX if irrelevant or no source found. */
29 int island; /* For loops only. */
30};
31
32/* All mapping computing func return this. */
35 MeshPairRemapItem *items; /* Array, one item per destination element. */
36
37 MemArena *mem; /* memory arena, internal use only. */
38};
39
40/* Helpers! */
41void BKE_mesh_remap_init(MeshPairRemap *map, int items_num);
43
45
46/* TODO:
47 * Add other 'from/to' mapping sources, like e.g. using a UVMap, etc.
48 * https://blenderartists.org/t/619105
49 *
50 * We could also use similar topology mappings inside a same mesh
51 * (cf. Campbell's 'select face islands from similar topology' WIP work).
52 * Also, users will have to check, whether we can get rid of some modes here,
53 * not sure all will be useful!
54 */
55enum {
60
65
66 /* ***** Target's vertices ***** */
68 /* Nearest source vert. */
70
71 /* Nearest vertex of nearest edge. */
73 /* This one uses two verts of selected edge (weighted interpolation). */
74 /* Nearest point on nearest edge. */
77
78 /* Nearest vertex of nearest face. */
80 /* Those two use all verts of selected face (weighted interpolation). */
81 /* Nearest point on nearest face. */
84 /* Point on nearest face hit by ray from target vertex's normal. */
87
88 /* ***** Target's edges ***** */
90
91 /* Source edge which both vertices are nearest of destination ones. */
93
94 /* Nearest source edge (using mid-point). */
96
97 /* Nearest edge of nearest face (using mid-point). */
99
100 /* Cast a set of rays from along destination edge,
101 * interpolating its vertices' normals, and use hit source edges. */
104
105 /* ***** Target's loops ***** */
106 /* NOTE: when islands are given to loop mapping func,
107 * all loops from the same destination face will always be mapped
108 * to loops of source faces within a same island, regardless of mapping mode. */
110
111 /* Best normal-matching loop from nearest vert. */
114 /* Loop from best normal-matching face from nearest vert. */
117
118 /* Loop from nearest vertex of nearest face. */
120 /* Those two use all verts of selected face (weighted interpolation). */
121 /* Nearest point on nearest face. */
124 /* Point on nearest face hit by ray from target loop's normal. */
127
128 /* ***** Target's faces ***** */
130
131 /* Nearest source face. */
133 /* Source face from best normal-matching destination face. */
135
136 /* Project destination face onto source mesh using its normal,
137 * and use interpolation of all intersecting source faces. */
140
141 /* ***** Same topology, applies to all four elements types. ***** */
143};
144
156 const float (*vert_positions_dst)[3],
157 int numverts_dst,
158 const Mesh *me_src);
159
163void BKE_mesh_remap_find_best_match_from_mesh(const float (*vert_positions_dst)[3],
164 int numverts_dst,
165 const Mesh *me_src,
166 SpaceTransform *r_space_transform);
167
169 const SpaceTransform *space_transform,
170 float max_dist,
171 float ray_radius,
172 const float (*vert_positions_dst)[3],
173 int numverts_dst,
174 const Mesh *me_src,
175 Mesh *me_dst,
176 MeshPairRemap *r_map);
177
179 const SpaceTransform *space_transform,
180 float max_dist,
181 float ray_radius,
182 const float (*vert_positions_dst)[3],
183 int numverts_dst,
184 const blender::int2 *edges_dst,
185 int numedges_dst,
186 const Mesh *me_src,
187 Mesh *me_dst,
188 MeshPairRemap *r_map);
189
191 const SpaceTransform *space_transform,
192 float max_dist,
193 float ray_radius,
194 const Mesh *mesh_dst,
195 const float (*vert_positions_dst)[3],
196 int numverts_dst,
197 const int *corner_verts_dst,
198 int numloops_dst,
199 const blender::OffsetIndices<int> faces_dst,
200 const Mesh *me_src,
201 MeshRemapIslandsCalc gen_islands_src,
202 float islands_precision_src,
203 MeshPairRemap *r_map);
204
206 const SpaceTransform *space_transform,
207 float max_dist,
208 float ray_radius,
209 const Mesh *mesh_dst,
210 const float (*vert_positions_dst)[3],
211 int numverts_dst,
212 const int *corner_verts,
213 const blender::OffsetIndices<int> faces_dst,
214 const Mesh *me_src,
215 MeshPairRemap *r_map);
bool(*)(const float(*vert_positions)[3], int totvert, const blender::int2 *edges, int totedge, const bool *uv_seams, blender::OffsetIndices< int > faces, const int *corner_verts, const int *corner_edges, int corners_num, MeshIslandStore *r_island_store) MeshRemapIslandsCalc
void BKE_mesh_remap_calc_loops_from_mesh(int mode, const SpaceTransform *space_transform, float max_dist, float ray_radius, const Mesh *mesh_dst, const float(*vert_positions_dst)[3], int numverts_dst, const int *corner_verts_dst, int numloops_dst, const blender::OffsetIndices< int > faces_dst, const Mesh *me_src, MeshRemapIslandsCalc gen_islands_src, float islands_precision_src, MeshPairRemap *r_map)
void BKE_mesh_remap_init(MeshPairRemap *map, int items_num)
void BKE_mesh_remap_calc_edges_from_mesh(int mode, const SpaceTransform *space_transform, float max_dist, float ray_radius, const float(*vert_positions_dst)[3], int numverts_dst, const blender::int2 *edges_dst, int numedges_dst, const Mesh *me_src, Mesh *me_dst, MeshPairRemap *r_map)
void BKE_mesh_remap_free(MeshPairRemap *map)
void BKE_mesh_remap_calc_verts_from_mesh(int mode, const SpaceTransform *space_transform, float max_dist, float ray_radius, const float(*vert_positions_dst)[3], int numverts_dst, const Mesh *me_src, Mesh *me_dst, MeshPairRemap *r_map)
void BKE_mesh_remap_item_define_invalid(MeshPairRemap *map, int index)
void BKE_mesh_remap_calc_faces_from_mesh(int mode, const SpaceTransform *space_transform, float max_dist, float ray_radius, const Mesh *mesh_dst, const float(*vert_positions_dst)[3], int numverts_dst, const int *corner_verts, const blender::OffsetIndices< int > faces_dst, const Mesh *me_src, MeshPairRemap *r_map)
void BKE_mesh_remap_find_best_match_from_mesh(const float(*vert_positions_dst)[3], int numverts_dst, const Mesh *me_src, SpaceTransform *r_space_transform)
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform, const float(*vert_positions_dst)[3], int numverts_dst, const Mesh *me_src)
@ MREMAP_MODE_VERT_EDGE_NEAREST
@ MREMAP_MODE_LOOP_POLYINTERP_NEAREST
@ MREMAP_MODE_VERT_POLYINTERP_VNORPROJ
@ MREMAP_MODE_VERT_FACE_NEAREST
@ MREMAP_MODE_LOOP
@ MREMAP_MODE_EDGE_POLY_NEAREST
@ MREMAP_MODE_POLY
@ MREMAP_MODE_VERT_EDGEINTERP_NEAREST
@ MREMAP_MODE_VERT_NEAREST
@ MREMAP_MODE_LOOP_NEAREST_POLYNOR
@ MREMAP_MODE_EDGE_VERT_NEAREST
@ MREMAP_USE_NORMAL
@ MREMAP_USE_LOOP
@ MREMAP_USE_INTERP
@ MREMAP_MODE_TOPOLOGY
@ MREMAP_MODE_VERT
@ MREMAP_USE_POLY
@ MREMAP_USE_NEAREST
@ MREMAP_MODE_EDGE
@ MREMAP_MODE_EDGE_NEAREST
@ MREMAP_MODE_POLY_NOR
@ MREMAP_USE_EDGE
@ MREMAP_MODE_LOOP_POLYINTERP_LNORPROJ
@ MREMAP_MODE_LOOP_NEAREST_LOOPNOR
@ MREMAP_MODE_LOOP_POLY_NEAREST
@ MREMAP_USE_NORPROJ
@ MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ
@ MREMAP_USE_VERT
@ MREMAP_MODE_POLY_POLYINTERP_PNORPROJ
@ MREMAP_MODE_POLY_NEAREST
@ MREMAP_MODE_VERT_POLYINTERP_NEAREST
MeshPairRemapItem * items