Blender  V3.3
Classes | Macros | Typedefs | Enumerations | Functions
BKE_mesh_mapping.h File Reference

Go to the source code of this file.

Classes

struct  UvVertMap
 
struct  UvMapVert
 
struct  UvElement
 
struct  UvElementMap
 
struct  MeshElemMap
 
struct  MeshIslandStore
 

Macros

#define STD_UV_CONNECT_LIMIT   0.0001f
 
#define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v)
 

Typedefs

typedef struct UvVertMap UvVertMap
 
typedef struct UvMapVert UvMapVert
 
typedef struct UvElement UvElement
 
typedef struct UvElementMap UvElementMap
 
typedef struct MeshElemMap MeshElemMap
 
typedef struct MeshIslandStore MeshIslandStore
 
typedef bool(* MeshRemapIslandsCalc) (struct MVert *verts, int totvert, struct MEdge *edges, int totedge, struct MPoly *polys, int totpoly, struct MLoop *loops, int totloop, struct MeshIslandStore *r_island_store)
 

Enumerations

enum  {
  MISLAND_TYPE_NONE = 0 , MISLAND_TYPE_VERT = 1 , MISLAND_TYPE_EDGE = 2 , MISLAND_TYPE_POLY = 3 ,
  MISLAND_TYPE_LOOP = 4
}
 

Functions

UvVertMapBKE_mesh_uv_vert_map_create (const struct MPoly *mpoly, const struct MLoop *mloop, const struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, const float limit[2], bool selected, bool use_winding)
 
UvMapVertBKE_mesh_uv_vert_map_get_vert (UvVertMap *vmap, unsigned int v)
 
void BKE_mesh_uv_vert_map_free (UvVertMap *vmap)
 
void BKE_mesh_vert_poly_map_create (MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const struct MLoop *mloop, int totvert, int totpoly, int totloop)
 
void BKE_mesh_vert_loop_map_create (MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const struct MLoop *mloop, int totvert, int totpoly, int totloop)
 
void BKE_mesh_vert_looptri_map_create (MeshElemMap **r_map, int **r_mem, const struct MVert *mvert, int totvert, const struct MLoopTri *mlooptri, int totlooptri, const struct MLoop *mloop, int totloop)
 
void BKE_mesh_vert_edge_map_create (MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totvert, int totedge)
 
void BKE_mesh_vert_edge_vert_map_create (MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totvert, int totedge)
 
void BKE_mesh_edge_loop_map_create (MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totedge, const struct MPoly *mpoly, int totpoly, const struct MLoop *mloop, int totloop)
 
void BKE_mesh_edge_poly_map_create (MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totedge, const struct MPoly *mpoly, int totpoly, const struct MLoop *mloop, int totloop)
 
void BKE_mesh_origindex_map_create (MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal)
 
void BKE_mesh_origindex_map_create_looptri (MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, int mpoly_num, const struct MLoopTri *looptri, int looptri_num)
 
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_clear (MeshIslandStore *island_store)
 
void BKE_mesh_loop_islands_free (MeshIslandStore *island_store)
 
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 BKE_mesh_calc_islands_loop_poly_edgeseam (struct MVert *verts, int totvert, struct MEdge *edges, int totedge, struct MPoly *polys, int totpoly, struct MLoop *loops, int totloop, MeshIslandStore *r_island_store)
 
bool BKE_mesh_calc_islands_loop_poly_uvmap (struct MVert *verts, int totvert, struct MEdge *edges, int totedge, struct MPoly *polys, int totpoly, struct MLoop *loops, int totloop, const struct MLoopUV *luvs, MeshIslandStore *r_island_store)
 
int * BKE_mesh_calc_smoothgroups (const struct MEdge *medge, int totedge, const struct MPoly *mpoly, int totpoly, const struct MLoop *mloop, int totloop, int *r_totgroup, bool use_bitflags)
 

Macro Definition Documentation

◆ BKE_MESH_TESSTRI_VINDEX_ORDER

#define BKE_MESH_TESSTRI_VINDEX_ORDER (   _tri,
  _v 
)
Value:
_tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \
CHECK_TYPE_ANY(_v, unsigned int, const unsigned int, int, const int)), \
(((_tri)[0] == _v) ? 0 : \
((_tri)[1] == _v) ? 1 : \
((_tri)[2] == _v) ? 2 : \
-1))
#define CHECK_TYPE_ANY(...)

Definition at line 304 of file BKE_mesh_mapping.h.

◆ STD_UV_CONNECT_LIMIT

#define STD_UV_CONNECT_LIMIT   0.0001f

Definition at line 23 of file BKE_mesh_mapping.h.

Typedef Documentation

◆ MeshElemMap

typedef struct MeshElemMap MeshElemMap

◆ MeshIslandStore

◆ MeshRemapIslandsCalc

typedef bool(* MeshRemapIslandsCalc) (struct MVert *verts, int totvert, struct MEdge *edges, int totedge, struct MPoly *polys, int totpoly, struct MLoop *loops, int totloop, struct MeshIslandStore *r_island_store)

Definition at line 235 of file BKE_mesh_mapping.h.

◆ UvElement

typedef struct UvElement UvElement

◆ UvElementMap

typedef struct UvElementMap UvElementMap

◆ UvMapVert

typedef struct UvMapVert UvMapVert

◆ UvVertMap

typedef struct UvVertMap UvVertMap

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MISLAND_TYPE_NONE 
MISLAND_TYPE_VERT 
MISLAND_TYPE_EDGE 
MISLAND_TYPE_POLY 
MISLAND_TYPE_LOOP 

Definition at line 196 of file BKE_mesh_mapping.h.

Function Documentation

◆ BKE_mesh_calc_islands_loop_poly_edgeseam()

bool BKE_mesh_calc_islands_loop_poly_edgeseam ( struct MVert verts,
int  totvert,
struct MEdge edges,
int  totedge,
struct MPoly polys,
int  totpoly,
struct MLoop loops,
int  totloop,
MeshIslandStore r_island_store 
)

Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams), not some UV layers coordinates.

Definition at line 1128 of file mesh_mapping.c.

References mesh_calc_islands_loop_poly_uv(), NULL, and verts.

Referenced by data_transfer_get_loop_islands_generator().

◆ BKE_mesh_calc_islands_loop_poly_uvmap()

bool BKE_mesh_calc_islands_loop_poly_uvmap ( struct MVert verts,
int  totvert,
struct MEdge edges,
int  totedge,
struct MPoly polys,
int  totpoly,
struct MLoop loops,
int  totloop,
const struct MLoopUV luvs,
MeshIslandStore r_island_store 
)

Calculate UV islands.

Note
If no MLoopUV layer is passed, we only consider edges tagged as seams as UV boundaries. This has the advantages of simplicity, and being valid/common to all UV maps. However, it means actual UV islands without matching UV seams will not be handled correctly. If a valid UV layer is passed as luvs parameter, UV coordinates are also used to detect islands boundaries.
All this could be optimized. Not sure it would be worth the more complex code, though, those loops are supposed to be really quick to do.

◆ BKE_mesh_calc_smoothgroups()

int* BKE_mesh_calc_smoothgroups ( const struct MEdge medge,
int  totedge,
const struct MPoly mpoly,
int  totpoly,
const struct MLoop mloop,
int  totloop,
int *  r_totgroup,
bool  use_bitflags 
)

Calculate smooth groups from sharp edges.

Parameters
r_totgroupThe total number of groups, 1 or more.
Returns
Polygon aligned array of group index values (bitflags if use_bitflags is true), starting at 1 (0 being used as 'invalid' flag). Note it's callers's responsibility to MEM_freeN returned array.

Referenced by blender::io::obj::OBJMesh::calc_smooth_groups().

◆ BKE_mesh_edge_loop_map_create()

void BKE_mesh_edge_loop_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MEdge medge,
int  totedge,
const struct MPoly mpoly,
int  totpoly,
const struct MLoop mloop,
int  totloop 
)

Generates a map where the key is the edge and the value is a list of loops that use that edge. Loops indices of a same poly are contiguous and in winding order. The lists are allocated from one memory pool.

◆ BKE_mesh_edge_poly_map_create()

void BKE_mesh_edge_poly_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MEdge medge,
int  totedge,
const struct MPoly mpoly,
int  totpoly,
const struct MLoop mloop,
int  totloop 
)

Generates a map where the key is the edge and the value is a list of polygons that use that edge. The lists are allocated from one memory pool.

Referenced by BKE_mesh_remap_calc_loops_from_mesh(), and SCULPT_geodesic_mesh_create().

◆ BKE_mesh_loop_islands_add()

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 
)

◆ BKE_mesh_loop_islands_clear()

void BKE_mesh_loop_islands_clear ( MeshIslandStore island_store)

◆ BKE_mesh_loop_islands_free()

void BKE_mesh_loop_islands_free ( MeshIslandStore island_store)

Definition at line 869 of file mesh_mapping.c.

References BLI_memarena_free(), MeshIslandStore::mem, and NULL.

Referenced by BKE_mesh_remap_calc_loops_from_mesh().

◆ BKE_mesh_loop_islands_init()

void BKE_mesh_loop_islands_init ( MeshIslandStore island_store,
short  item_type,
int  items_num,
short  island_type,
short  innercut_type 
)

◆ BKE_mesh_origindex_map_create()

void BKE_mesh_origindex_map_create ( MeshElemMap **  r_map,
int **  r_mem,
int  totsource,
const int *  final_origindex,
int  totfinal 
)

This function creates a map so the source-data (vert/edge/loop/poly) can loop over the destination data (using the destination arrays origindex).

This has the advantage that it can operate on any data-types.

Parameters
totsourceThe total number of elements that final_origindex points to.
totfinalThe size of final_origindex
final_origindexThe size of the final array.
Note
totsource could be totpoly, totfinal could be tottessface and final_origindex its ORIGINDEX custom-data. This would allow an MPoly to loop over its tessfaces.

Definition at line 481 of file mesh_mapping.c.

References BLI_assert, MeshElemMap::count, indices, MeshElemMap::indices, map, MEM_callocN, MEM_mallocN, and ORIGINDEX_NONE.

◆ BKE_mesh_origindex_map_create_looptri()

void BKE_mesh_origindex_map_create_looptri ( MeshElemMap **  r_map,
int **  r_mem,
const struct MPoly mpoly,
int  mpoly_num,
const struct MLoopTri looptri,
int  looptri_num 
)

A version of BKE_mesh_origindex_map_create that takes a looptri array. Making a poly -> looptri map.

Referenced by BKE_mesh_remap_calc_loops_from_mesh().

◆ BKE_mesh_uv_vert_map_create()

UvVertMap* BKE_mesh_uv_vert_map_create ( const struct MPoly mpoly,
const struct MLoop mloop,
const struct MLoopUV mloopuv,
unsigned int  totpoly,
unsigned int  totvert,
const float  limit[2],
bool  selected,
bool  use_winding 
)

◆ BKE_mesh_uv_vert_map_free()

void BKE_mesh_uv_vert_map_free ( UvVertMap vmap)

◆ BKE_mesh_uv_vert_map_get_vert()

UvMapVert* BKE_mesh_uv_vert_map_get_vert ( UvVertMap vmap,
unsigned int  v 
)

◆ BKE_mesh_vert_edge_map_create()

void BKE_mesh_vert_edge_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MEdge medge,
int  totvert,
int  totedge 
)

Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint. The lists are allocated from one memory pool.

Referenced by base_skin(), BKE_mesh_remap_calc_edges_from_mesh(), modifier_skin_armature_create(), SCULPT_geodesic_mesh_create(), and vgroup_smooth_subset().

◆ BKE_mesh_vert_edge_vert_map_create()

void BKE_mesh_vert_edge_vert_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MEdge medge,
int  totvert,
int  totedge 
)

A version of BKE_mesh_vert_edge_map_create that references connected vertices directly (not their edges).

◆ BKE_mesh_vert_loop_map_create()

void BKE_mesh_vert_loop_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MPoly mpoly,
const struct MLoop mloop,
int  totvert,
int  totpoly,
int  totloop 
)

Generates a map where the key is the vertex and the value is a list of loops that use that vertex as a corner. The lists are allocated from one memory pool.

Referenced by BKE_mesh_merge_customdata_for_apply_modifier(), BKE_mesh_remap_calc_loops_from_mesh(), BKE_remesh_reproject_vertex_paint(), MeshFairingContext::MeshFairingContext(), and vertex_paint_init_session_data().

◆ BKE_mesh_vert_looptri_map_create()

void BKE_mesh_vert_looptri_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MVert mvert,
int  totvert,
const struct MLoopTri mlooptri,
int  totlooptri,
const struct MLoop mloop,
int  totloop 
)

Generates a map where the key is the edge and the value is a list of looptris that use that edge. The lists are allocated from one memory pool.

Referenced by dynamicPaint_createUVSurface().

◆ BKE_mesh_vert_poly_map_create()

void BKE_mesh_vert_poly_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const struct MPoly mpoly,
const struct MLoop mloop,
int  totvert,
int  totpoly,
int  totloop 
)

Generates a map where the key is the vertex and the value is a list of polys that use that vertex as a corner. The lists are allocated from one memory pool.

Referenced by BKE_mesh_merge_verts(), BKE_mesh_remap_calc_loops_from_mesh(), multires_reshape_apply_base_refit_base_mesh(), sculpt_update_object(), and vertex_paint_init_session_data().