Blender V5.0
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
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 blender::Span<int> corner_verts,
105 int verts_num,
106 const blender::float2 &limit,
107 bool use_winding);
108
111
118 int **r_mem,
119 int totvert,
120 const blender::int3 *corner_tris,
121 int tris_num,
122 const int *corner_verts,
123 int corners_num);
139 MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal);
145 int **r_mem,
147 const int *corner_tri_faces,
148 int corner_tris_num);
149
150/* islands */
151
152/* Loop islands data helpers. */
153enum {
159};
160
162 short item_type; /* MISLAND_TYPE_... */
163 short island_type; /* MISLAND_TYPE_... */
164 short innercut_type; /* MISLAND_TYPE_... */
165
167 int *items_to_islands; /* map the item to the island index */
168
171 MeshElemMap **islands; /* Array of pointers, one item per island. */
172 MeshElemMap **innercuts; /* Array of pointers, one item per island. */
173
174 MemArena *mem; /* Memory arena, internal use only. */
175};
176
178 short item_type,
179 int items_num,
180 short island_type,
181 short innercut_type);
185 int item_num,
186 const int *items_indices,
187 int num_island_items,
188 int *island_item_indices,
189 int num_innercut_items,
190 int *innercut_item_indices);
191
194 blender::Span<bool> uv_seams,
196 blender::Span<int> corner_verts,
197 blender::Span<int> corner_edges,
198 MeshIslandStore *r_island_store);
199
200/* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here.
201 * So better keep them separated for now, I think. */
202
211 blender::Span<bool> uv_seams,
213 blender::Span<int> corner_verts,
214 blender::Span<int> corner_edges,
215 MeshIslandStore *r_island_store);
216
226int *BKE_mesh_calc_smoothgroups(int edges_num,
228 blender::Span<int> corner_edges,
229 blender::Span<bool> sharp_edges,
230 blender::Span<bool> sharp_faces,
231 int *r_totgroup);
255int *BKE_mesh_calc_smoothgroups_bitflags(int edges_num,
256 int verts_num,
258 blender::Span<int> corner_edges,
259 blender::Span<int> corner_verts,
260 blender::Span<bool> sharp_edges,
261 blender::Span<bool> sharp_faces,
262 bool use_boundary_vertices_for_bitflags,
263 int *r_totgroup);
264
265/* Use on corner_tri vertex values. */
266#define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v) \
267 ((CHECK_TYPE_ANY( \
268 _tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \
269 CHECK_TYPE_ANY(_v, unsigned int, const unsigned int, int, const int)), \
270 (((_tri)[0] == _v) ? 0 : \
271 ((_tri)[1] == _v) ? 1 : \
272 ((_tri)[2] == _v) ? 2 : \
273 -1))
274
275namespace blender::bke::mesh {
276
277Array<int> build_corner_to_face_map(OffsetIndices<int> faces);
278
279GroupedSpan<int> build_vert_to_edge_map(Span<int2> edges,
280 int verts_num,
281 Array<int> &r_offsets,
282 Array<int> &r_indices);
283
284void build_vert_to_face_indices(OffsetIndices<int> faces,
285 Span<int> corner_verts,
286 OffsetIndices<int> offsets,
287 MutableSpan<int> face_indices);
288GroupedSpan<int> build_vert_to_face_map(OffsetIndices<int> faces,
289 Span<int> corner_verts,
290 int verts_num,
291 Array<int> &r_offsets,
292 Array<int> &r_indices);
293
294Array<int> build_vert_to_corner_indices(Span<int> corner_verts, OffsetIndices<int> offsets);
295GroupedSpan<int> build_vert_to_corner_map(Span<int> corner_verts,
296 int verts_num,
297 Array<int> &r_offsets,
298 Array<int> &r_indices);
299
300GroupedSpan<int> build_edge_to_corner_map(Span<int> corner_edges,
301 int edges_num,
302 Array<int> &r_offsets,
303 Array<int> &r_indices);
304
305GroupedSpan<int> build_edge_to_face_map(OffsetIndices<int> faces,
306 Span<int> corner_edges,
307 int edges_num,
308 Array<int> &r_offsets,
309 Array<int> &r_indices);
310
311} // namespace blender::bke::mesh
void BKE_mesh_loop_islands_init(MeshIslandStore *island_store, short item_type, int items_num, short island_type, short innercut_type)
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)
bool(*)(blender::Span< blender::float3 > vert_positions, blender::Span< blender::int2 > edges, blender::Span< bool > uv_seams, blender::OffsetIndices< int > faces, blender::Span< int > corner_verts, blender::Span< int > corner_edges, MeshIslandStore *r_island_store) MeshRemapIslandsCalc
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)
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)
void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store)
bool BKE_mesh_calc_islands_loop_face_edgeseam(blender::Span< blender::float3 > vert_positions, blender::Span< blender::int2 > edges, blender::Span< bool > uv_seams, blender::OffsetIndices< int > faces, blender::Span< int > corner_verts, blender::Span< int > corner_edges, MeshIslandStore *r_island_store)
void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
UvMapVert * BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v)
void BKE_mesh_loop_islands_free(MeshIslandStore *island_store)
int * BKE_mesh_calc_smoothgroups_bitflags(int edges_num, int verts_num, blender::OffsetIndices< int > faces, blender::Span< int > corner_edges, blender::Span< int > corner_verts, blender::Span< bool > sharp_edges, blender::Span< bool > sharp_faces, bool use_boundary_vertices_for_bitflags, int *r_totgroup)
@ MISLAND_TYPE_POLY
@ MISLAND_TYPE_VERT
@ MISLAND_TYPE_LOOP
@ MISLAND_TYPE_EDGE
@ MISLAND_TYPE_NONE
UvVertMap * BKE_mesh_uv_vert_map_create(blender::OffsetIndices< int > faces, blender::Span< int > corner_verts, blender::Span< blender::float2 > uv_map, int verts_num, const blender::float2 &limit, bool use_winding)
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
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)
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
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