Blender V5.3
BKE_mesh_mapping.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
9
10#include "BLI_array.hh"
12#include "BLI_offset_indices.hh"
13
14namespace blender {
15
16struct BMLoop;
17struct MemArena;
18
19/* UvVertMap */
20#define STD_UV_CONNECT_LIMIT 0.0001f
21
22struct UvMapVert {
24 unsigned int face_index;
25 unsigned short loop_of_face_index;
27};
28
34
40struct UvElement {
46 unsigned short loop_of_face_index;
50 unsigned char flag;
52 unsigned int island;
53};
54
95
96/* Connectivity data */
98 int *indices;
99 int count;
100};
101
102/* mapping */
103
105 Span<int> corner_verts,
106 Span<float2> uv_map,
107 int verts_num,
108 const float2 &limit,
109 bool use_winding);
110
113
120 int **r_mem,
121 int totvert,
122 const int3 *corner_tris,
123 int tris_num,
124 const int *corner_verts,
125 int corners_num);
141 MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal);
147 int **r_mem,
148 OffsetIndices<int> faces,
149 const int *corner_tri_faces,
150 int corner_tris_num);
151
152/* islands */
153
154/* Loop islands data helpers. */
155enum {
161};
162
164 short item_type; /* MISLAND_TYPE_... */
165 short island_type; /* MISLAND_TYPE_... */
166 short innercut_type; /* MISLAND_TYPE_... */
167
169 int *items_to_islands; /* map the item to the island index */
170
173 MeshElemMap **islands; /* Array of pointers, one item per island. */
174 MeshElemMap **innercuts; /* Array of pointers, one item per island. */
175
176 MemArena *mem; /* Memory arena, internal use only. */
177};
178
180 short item_type,
181 int items_num,
182 short island_type,
183 short innercut_type);
187 int item_num,
188 const int *items_indices,
189 int num_island_items,
190 int *island_item_indices,
191 int num_innercut_items,
192 int *innercut_item_indices);
193
194using MeshRemapIslandsCalc = bool (*)(Span<float3> vert_positions,
195 Span<int2> edges,
196 Span<bool> uv_seams,
197 OffsetIndices<int> faces,
198 Span<int> corner_verts,
199 Span<int> corner_edges,
200 MeshIslandStore *r_island_store);
201
202/* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here.
203 * So better keep them separated for now, I think. */
204
212 Span<int2> edges,
213 Span<bool> uv_seams,
214 OffsetIndices<int> faces,
215 Span<int> corner_verts,
216 Span<int> corner_edges,
217 MeshIslandStore *r_island_store);
218
228int *BKE_mesh_calc_smoothgroups(int edges_num,
229 OffsetIndices<int> faces,
230 Span<int> corner_edges,
231 Span<bool> sharp_edges,
232 Span<bool> sharp_faces,
233 int *r_totgroup);
257int *BKE_mesh_calc_smoothgroups_bitflags(int edges_num,
258 int verts_num,
259 OffsetIndices<int> faces,
260 Span<int> corner_edges,
261 Span<int> corner_verts,
262 Span<bool> sharp_edges,
263 Span<bool> sharp_faces,
264 bool use_boundary_vertices_for_bitflags,
265 int *r_totgroup);
266
267/* Use on corner_tri vertex values. */
268#define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v) \
269 ((CHECK_TYPE_ANY( \
270 _tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \
271 CHECK_TYPE_ANY(_v, unsigned int, const unsigned int, int, const int)), \
272 (((_tri)[0] == _v) ? 0 : \
273 ((_tri)[1] == _v) ? 1 : \
274 ((_tri)[2] == _v) ? 2 : \
275 -1))
276
277namespace bke::mesh {
278
279Array<int> build_corner_to_face_map(OffsetIndices<int> faces);
280
281GroupedSpan<int> build_vert_to_edge_map(Span<int2> edges,
282 int verts_num,
283 Array<int> &r_offsets,
284 Array<int> &r_indices);
285
286void build_vert_to_face_indices(OffsetIndices<int> faces,
287 Span<int> corner_verts,
288 OffsetIndices<int> offsets,
289 MutableSpan<int> face_indices);
290GroupedSpan<int> build_vert_to_face_map(OffsetIndices<int> faces,
291 Span<int> corner_verts,
292 int verts_num,
293 Array<int> &r_offsets,
294 Array<int> &r_indices);
295
296Array<int> build_vert_to_corner_indices(Span<int> corner_verts, OffsetIndices<int> offsets);
297GroupedSpan<int> build_vert_to_corner_map(Span<int> corner_verts,
298 int verts_num,
299 Array<int> &r_offsets,
300 Array<int> &r_indices);
301
302GroupedSpan<int> build_edge_to_corner_map(Span<int> corner_edges,
303 int edges_num,
304 Array<int> &r_offsets,
305 Array<int> &r_indices);
306
307GroupedSpan<int> build_edge_to_face_map(OffsetIndices<int> faces,
308 Span<int> corner_edges,
309 int edges_num,
310 Array<int> &r_offsets,
311 Array<int> &r_indices);
312
313} // namespace bke::mesh
314} // namespace blender
void build_vert_to_face_indices(OffsetIndices< int > faces, Span< int > corner_verts, OffsetIndices< int > offsets, MutableSpan< int > face_indices)
GroupedSpan< int > build_vert_to_corner_map(Span< int > corner_verts, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_edge_to_corner_map(Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_edge_to_face_map(OffsetIndices< int > faces, Span< int > corner_edges, int edges_num, Array< int > &r_offsets, Array< int > &r_indices)
Array< int > build_corner_to_face_map(OffsetIndices< int > faces)
Array< int > build_vert_to_corner_indices(Span< int > corner_verts, OffsetIndices< int > offsets)
GroupedSpan< int > build_vert_to_face_map(OffsetIndices< int > faces, Span< int > corner_verts, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
GroupedSpan< int > build_vert_to_edge_map(Span< int2 > edges, int verts_num, Array< int > &r_offsets, Array< int > &r_indices)
BMesh Iterators.
void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
UvMapVert * BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v)
ATTR_WARN_UNUSED_RESULT const BMVert * v
int * BKE_mesh_calc_smoothgroups(int edges_num, OffsetIndices< int > faces, Span< int > corner_edges, Span< bool > sharp_edges, Span< bool > sharp_faces, int *r_totgroup)
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
void BKE_mesh_origindex_map_create_corner_tri(MeshElemMap **r_map, int **r_mem, OffsetIndices< int > faces, const int *corner_tri_faces, int corner_tris_num)
UvVertMap * BKE_mesh_uv_vert_map_create(OffsetIndices< int > faces, Span< int > corner_verts, Span< float2 > uv_map, int verts_num, const float2 &limit, bool use_winding)
void BKE_mesh_loop_islands_add(MeshIslandStore *island_store, int item_num, const int *items_indices, int num_island_items, int *island_item_indices, int num_innercut_items, int *innercut_item_indices)
void BKE_mesh_vert_corner_tri_map_create(MeshElemMap **r_map, int **r_mem, int totvert, const int3 *corner_tris, int tris_num, const int *corner_verts, int corners_num)
void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store)
void BKE_mesh_loop_islands_free(MeshIslandStore *island_store)
bool(*)(Span< float3 > vert_positions, Span< int2 > edges, Span< bool > uv_seams, OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, MeshIslandStore *r_island_store) MeshRemapIslandsCalc
void BKE_mesh_origindex_map_create(MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal)
bool BKE_mesh_calc_islands_loop_face_edgeseam(Span< float3 > vert_positions, Span< int2 > edges, Span< bool > uv_seams, OffsetIndices< int > faces, Span< int > corner_verts, Span< int > corner_edges, MeshIslandStore *r_island_store)
void BKE_mesh_loop_islands_init(MeshIslandStore *island_store, short item_type, int items_num, short island_type, short innercut_type)
int * BKE_mesh_calc_smoothgroups_bitflags(int edges_num, int verts_num, OffsetIndices< int > faces, Span< int > corner_edges, Span< int > corner_verts, Span< bool > sharp_edges, Span< bool > sharp_faces, bool use_boundary_vertices_for_bitflags, int *r_totgroup)
unsigned short loop_of_face_index
unsigned short loop_of_face_index