Blender  V3.3
Classes
mesh_mapping.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_meshdata_types.h"
#include "DNA_vec_types.h"
#include "BLI_bitmap.h"
#include "BLI_buffer.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_mesh_mapping.h"
#include "BLI_memarena.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Classes

struct  MeshCheckIslandBoundaryUv
 

Functions

Mesh Connectivity Mapping
UvVertMapBKE_mesh_uv_vert_map_create (const MPoly *mpoly, const MLoop *mloop, const MLoopUV *mloopuv, uint totpoly, uint totvert, const float limit[2], const bool selected, const bool use_winding)
 
UvMapVertBKE_mesh_uv_vert_map_get_vert (UvVertMap *vmap, uint v)
 
void BKE_mesh_uv_vert_map_free (UvVertMap *vmap)
 
static void mesh_vert_poly_or_loop_map_create (MeshElemMap **r_map, int **r_mem, const MPoly *mpoly, const MLoop *mloop, int totvert, int totpoly, int totloop, const bool do_loops)
 
void BKE_mesh_vert_poly_map_create (MeshElemMap **r_map, int **r_mem, const MPoly *mpoly, const MLoop *mloop, int totvert, int totpoly, int totloop)
 
void BKE_mesh_vert_loop_map_create (MeshElemMap **r_map, int **r_mem, const MPoly *mpoly, const MLoop *mloop, int totvert, int totpoly, int totloop)
 
void BKE_mesh_vert_looptri_map_create (MeshElemMap **r_map, int **r_mem, const MVert *UNUSED(mvert), const int totvert, const MLoopTri *mlooptri, const int totlooptri, const MLoop *mloop, const int UNUSED(totloop))
 
void BKE_mesh_vert_edge_map_create (MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
 
void BKE_mesh_vert_edge_vert_map_create (MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
 
void BKE_mesh_edge_loop_map_create (MeshElemMap **r_map, int **r_mem, const MEdge *UNUSED(medge), const int totedge, const MPoly *mpoly, const int totpoly, const MLoop *mloop, const int totloop)
 
void BKE_mesh_edge_poly_map_create (MeshElemMap **r_map, int **r_mem, const MEdge *UNUSED(medge), const int totedge, const MPoly *mpoly, const int totpoly, const MLoop *mloop, const int totloop)
 
void BKE_mesh_origindex_map_create (MeshElemMap **r_map, int **r_mem, const int totsource, const int *final_origindex, const int totfinal)
 
void BKE_mesh_origindex_map_create_looptri (MeshElemMap **r_map, int **r_mem, const MPoly *mpoly, const int mpoly_num, const MLoopTri *looptri, const int looptri_num)
 

Mesh loops/poly islands.

Used currently for UVs and 'smooth groups'.

#define MISLAND_DEFAULT_BUFSIZE   64
 
typedef bool(* MeshRemap_CheckIslandBoundary) (const struct MPoly *mpoly, const struct MLoop *mloop, const struct MEdge *medge, const int edge_user_count, const struct MPoly *mpoly_array, const struct MeshElemMap *edge_poly_map, void *user_data)
 
typedef struct MeshCheckIslandBoundaryUv MeshCheckIslandBoundaryUv
 
static void poly_edge_loop_islands_calc (const MEdge *medge, const int totedge, const MPoly *mpoly, const int totpoly, const MLoop *mloop, const int totloop, MeshElemMap *edge_poly_map, const bool use_bitflags, MeshRemap_CheckIslandBoundary edge_boundary_check, void *edge_boundary_check_data, int **r_poly_groups, int *r_totgroup, BLI_bitmap **r_edge_borders, int *r_totedgeborder)
 
static bool poly_is_island_boundary_smooth_cb (const MPoly *mp, const MLoop *UNUSED(ml), const MEdge *me, const int edge_user_count, const MPoly *mpoly_array, const MeshElemMap *edge_poly_map, void *UNUSED(user_data))
 
int * BKE_mesh_calc_smoothgroups (const MEdge *medge, const int totedge, const MPoly *mpoly, const int totpoly, const MLoop *mloop, const int totloop, int *r_totgroup, const bool use_bitflags)
 
void BKE_mesh_loop_islands_init (MeshIslandStore *island_store, const short item_type, const int items_num, const short island_type, const 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, const int item_num, const int *items_indices, const int num_island_items, int *island_item_indices, const int num_innercut_items, int *innercut_item_indices)
 
static bool mesh_check_island_boundary_uv (const MPoly *UNUSED(mp), const MLoop *ml, const MEdge *me, const int UNUSED(edge_user_count), const MPoly *UNUSED(mpoly_array), const MeshElemMap *UNUSED(edge_poly_map), void *user_data)
 
static bool mesh_calc_islands_loop_poly_uv (MVert *UNUSED(verts), const int UNUSED(totvert), MEdge *edges, const int totedge, MPoly *polys, const int totpoly, MLoop *loops, const int totloop, const MLoopUV *luvs, MeshIslandStore *r_island_store)
 
bool BKE_mesh_calc_islands_loop_poly_edgeseam (MVert *verts, const int totvert, MEdge *edges, const int totedge, MPoly *polys, const int totpoly, MLoop *loops, const int totloop, MeshIslandStore *r_island_store)
 
bool BKE_mesh_calc_islands_loop_poly_uvmap (MVert *verts, const int totvert, MEdge *edges, const int totedge, MPoly *polys, const int totpoly, MLoop *loops, const int totloop, const MLoopUV *luvs, MeshIslandStore *r_island_store)
 

Detailed Description

Functions for accessing mesh connectivity data. eg: polys connected to verts, UV's connected to verts.

Definition in file mesh_mapping.c.

Macro Definition Documentation

◆ MISLAND_DEFAULT_BUFSIZE

#define MISLAND_DEFAULT_BUFSIZE   64

Definition at line 813 of file mesh_mapping.c.

Typedef Documentation

◆ MeshCheckIslandBoundaryUv

◆ MeshRemap_CheckIslandBoundary

typedef bool(* MeshRemap_CheckIslandBoundary) (const struct MPoly *mpoly, const struct MLoop *mloop, const struct MEdge *medge, const int edge_user_count, const struct MPoly *mpoly_array, const struct MeshElemMap *edge_poly_map, void *user_data)

Callback deciding whether the given poly/loop/edge define an island boundary or not.

Definition at line 561 of file mesh_mapping.c.

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 ( MVert verts,
const int  totvert,
MEdge edges,
const int  totedge,
MPoly polys,
const int  totpoly,
MLoop loops,
const int  totloop,
const MLoopUV luvs,
MeshIslandStore r_island_store 
)

Definition at line 1142 of file mesh_mapping.c.

References BLI_assert, mesh_calc_islands_loop_poly_uv(), NULL, and verts.

◆ BKE_mesh_calc_smoothgroups()

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

◆ BKE_mesh_edge_loop_map_create()

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

◆ BKE_mesh_edge_poly_map_create()

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

◆ BKE_mesh_loop_islands_add()

void BKE_mesh_loop_islands_add ( MeshIslandStore island_store,
const int  item_num,
const int *  items_indices,
const int  num_island_items,
int *  island_item_indices,
const 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,
const short  item_type,
const int  items_num,
const short  island_type,
const 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 MPoly mpoly,
const int  mpoly_num,
const MLoopTri looptri,
const int  looptri_num 
)

◆ BKE_mesh_uv_vert_map_create()

UvVertMap* BKE_mesh_uv_vert_map_create ( const MPoly mpoly,
const MLoop mloop,
const MLoopUV mloopuv,
uint  totpoly,
uint  totvert,
const float  limit[2],
const bool  selected,
const 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,
uint  v 
)

◆ BKE_mesh_vert_edge_map_create()

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

Definition at line 302 of file mesh_mapping.c.

References indices, map, MEM_callocN, MEM_mallocN, v, MEdge::v1, and MEdge::v2.

◆ BKE_mesh_vert_edge_vert_map_create()

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

Definition at line 341 of file mesh_mapping.c.

References indices, map, MEM_callocN, MEM_mallocN, v, MEdge::v1, and MEdge::v2.

◆ BKE_mesh_vert_loop_map_create()

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

Definition at line 247 of file mesh_mapping.c.

References mesh_vert_poly_or_loop_map_create().

◆ BKE_mesh_vert_looptri_map_create()

void BKE_mesh_vert_looptri_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const MVert UNUSEDmvert,
const int  totvert,
const MLoopTri mlooptri,
const int  totlooptri,
const MLoop mloop,
const int   UNUSEDtotloop 
)

◆ BKE_mesh_vert_poly_map_create()

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

Definition at line 236 of file mesh_mapping.c.

References mesh_vert_poly_or_loop_map_create().

◆ mesh_calc_islands_loop_poly_uv()

static bool mesh_calc_islands_loop_poly_uv ( MVert UNUSEDverts,
const int   UNUSEDtotvert,
MEdge edges,
const int  totedge,
MPoly polys,
const int  totpoly,
MLoop loops,
const int  totloop,
const MLoopUV luvs,
MeshIslandStore r_island_store 
)
static

◆ mesh_check_island_boundary_uv()

static bool mesh_check_island_boundary_uv ( const MPoly UNUSEDmp,
const MLoop ml,
const MEdge me,
const int   UNUSEDedge_user_count,
const MPoly UNUSEDmpoly_array,
const MeshElemMap UNUSEDedge_poly_map,
void user_data 
)
static

◆ mesh_vert_poly_or_loop_map_create()

static void mesh_vert_poly_or_loop_map_create ( MeshElemMap **  r_map,
int **  r_mem,
const MPoly mpoly,
const MLoop mloop,
int  totvert,
int  totpoly,
int  totloop,
const bool  do_loops 
)
static

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

Wrapped by BKE_mesh_vert_poly_map_create & BKE_mesh_vert_loop_map_create

Definition at line 187 of file mesh_mapping.c.

References indices, MPoly::loopstart, map, MEM_callocN, MEM_mallocN, MPoly::totloop, v, and MLoop::v.

Referenced by BKE_mesh_vert_loop_map_create(), and BKE_mesh_vert_poly_map_create().

◆ poly_edge_loop_islands_calc()

static void poly_edge_loop_islands_calc ( const MEdge medge,
const int  totedge,
const MPoly mpoly,
const int  totpoly,
const MLoop mloop,
const int  totloop,
MeshElemMap edge_poly_map,
const bool  use_bitflags,
MeshRemap_CheckIslandBoundary  edge_boundary_check,
void edge_boundary_check_data,
int **  r_poly_groups,
int *  r_totgroup,
BLI_bitmap **  r_edge_borders,
int *  r_totedgeborder 
)
static

◆ poly_is_island_boundary_smooth_cb()

static bool poly_is_island_boundary_smooth_cb ( const MPoly mp,
const MLoop UNUSEDml,
const MEdge me,
const int  edge_user_count,
const MPoly mpoly_array,
const MeshElemMap edge_poly_map,
void UNUSEDuser_data 
)
static