Blender V4.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
10#include "BLI_array.hh"
12#include "BLI_offset_indices.hh"
13
14struct BMLoop;
15struct MemArena;
16
17/* UvVertMap */
18#define STD_UV_CONNECT_LIMIT 0.0001f
19
20struct UvMapVert {
22 unsigned int face_index;
23 unsigned short loop_of_face_index;
25};
26
32
38struct UvElement {
44 unsigned short loop_of_face_index;
48 unsigned char flag;
50 unsigned int island;
51};
52
93
94/* Connectivity data */
96 int *indices;
97 int count;
98};
99
100/* mapping */
101
103 const bool *hide_poly,
104 const bool *select_poly,
105 const int *corner_verts,
106 const float (*mloopuv)[2],
107 unsigned int totvert,
108 const float limit[2],
109 bool selected,
110 bool use_winding);
111
114
121 int **r_mem,
122 int totvert,
123 const blender::int3 *corner_tris,
124 int tris_num,
125 const int *corner_verts,
126 int corners_num);
142 MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal);
148 int **r_mem,
150 const int *corner_tri_faces,
151 int corner_tris_num);
152
153/* islands */
154
155/* Loop islands data helpers. */
156enum {
162};
163
165 short item_type; /* MISLAND_TYPE_... */
166 short island_type; /* MISLAND_TYPE_... */
167 short innercut_type; /* MISLAND_TYPE_... */
168
170 int *items_to_islands; /* map the item to the island index */
171
174 MeshElemMap **islands; /* Array of pointers, one item per island. */
175 MeshElemMap **innercuts; /* Array of pointers, one item per island. */
176
177 MemArena *mem; /* Memory arena, internal use only. */
178};
179
181 short item_type,
182 int items_num,
183 short island_type,
184 short innercut_type);
188 int item_num,
189 const int *items_indices,
190 int num_island_items,
191 int *island_item_indices,
192 int num_innercut_items,
193 int *innercut_item_indices);
194
195using MeshRemapIslandsCalc = bool (*)(const float (*vert_positions)[3],
196 int totvert,
197 const blender::int2 *edges,
198 int totedge,
199 const bool *uv_seams,
201 const int *corner_verts,
202 const int *corner_edges,
203 int corners_num,
204 MeshIslandStore *r_island_store);
205
206/* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here.
207 * So better keep them separated for now, I think. */
208
213bool BKE_mesh_calc_islands_loop_face_edgeseam(const float (*vert_positions)[3],
214 int totvert,
215 const blender::int2 *edges,
216 int totedge,
217 const bool *uv_seams,
219 const int *corner_verts,
220 const int *corner_edges,
221 int corners_num,
222 MeshIslandStore *r_island_store);
223
237bool BKE_mesh_calc_islands_loop_face_uvmap(float (*vert_positions)[3],
238 int totvert,
239 blender::int2 *edges,
240 int totedge,
241 const bool *uv_seams,
243 const int *corner_verts,
244 const int *corner_edges,
245 int corners_num,
246 const float (*luvs)[2],
247 MeshIslandStore *r_island_store);
248
259int *BKE_mesh_calc_smoothgroups(int edges_num,
261 blender::Span<int> corner_edges,
262 blender::Span<bool> sharp_edges,
263 blender::Span<bool> sharp_faces,
264 int *r_totgroup,
265 bool use_bitflags);
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 blender::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 blender::bke::mesh
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
bool BKE_mesh_calc_islands_loop_face_edgeseam(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)
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(int edges_num, blender::OffsetIndices< int > faces, blender::Span< int > corner_edges, blender::Span< bool > sharp_edges, blender::Span< bool > sharp_faces, int *r_totgroup, bool use_bitflags)
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_origindex_map_create(MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal)
void BKE_mesh_vert_corner_tri_map_create(MeshElemMap **r_map, int **r_mem, int totvert, const blender::int3 *corner_tris, int tris_num, const int *corner_verts, int corners_num)
UvVertMap * BKE_mesh_uv_vert_map_create(blender::OffsetIndices< int > faces, const bool *hide_poly, const bool *select_poly, const int *corner_verts, const float(*mloopuv)[2], unsigned int totvert, const float limit[2], bool selected, bool use_winding)
void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store)
@ MISLAND_TYPE_POLY
@ MISLAND_TYPE_VERT
@ MISLAND_TYPE_LOOP
@ MISLAND_TYPE_EDGE
@ MISLAND_TYPE_NONE
void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
UvMapVert * BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v)
bool BKE_mesh_calc_islands_loop_face_uvmap(float(*vert_positions)[3], int totvert, blender::int2 *edges, int totedge, const bool *uv_seams, blender::OffsetIndices< int > faces, const int *corner_verts, const int *corner_edges, int corners_num, const float(*luvs)[2], MeshIslandStore *r_island_store)
void BKE_mesh_loop_islands_free(MeshIslandStore *island_store)
void BKE_mesh_origindex_map_create_corner_tri(MeshElemMap **r_map, int **r_mem, blender::OffsetIndices< int > faces, const int *corner_tri_faces, int corner_tris_num)
ATTR_WARN_UNUSED_RESULT const BMVert * v
draw_view in_light_buf[] float
static char faces[256]
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)
MeshElemMap ** islands
MeshElemMap ** innercuts
UvElement * storage
int * island_total_unique_uvs
UvElement ** vertex
UvElement ** head_table
unsigned char flag
unsigned int island
unsigned short loop_of_face_index
UvElement * next
unsigned int face_index
UvMapVert * next
unsigned short loop_of_face_index
UvMapVert * buf
UvMapVert ** vert