Blender
V3.3
|
#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 | |
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) |
UvMapVert * | BKE_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. | |
#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) |
Functions for accessing mesh connectivity data. eg: polys connected to verts, UV's connected to verts.
Definition in file mesh_mapping.c.
#define MISLAND_DEFAULT_BUFSIZE 64 |
Definition at line 813 of file mesh_mapping.c.
typedef struct MeshCheckIslandBoundaryUv MeshCheckIslandBoundaryUv |
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.
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().
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.
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 | ||
) |
Definition at line 784 of file mesh_mapping.c.
References NULL, poly_edge_loop_islands_calc(), and poly_is_island_boundary_smooth_cb().
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 | ||
) |
Definition at line 380 of file mesh_mapping.c.
References MeshElemMap::count, MLoop::e, indices, MeshElemMap::indices, MPoly::loopstart, map, MEM_callocN, MEM_mallocN, and MPoly::totloop.
Referenced by mesh_calc_islands_loop_poly_uv().
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 | ||
) |
Definition at line 433 of file mesh_mapping.c.
References MeshElemMap::count, MLoop::e, indices, MeshElemMap::indices, MPoly::loopstart, map, MEM_callocN, MEM_mallocN, and MPoly::totloop.
Referenced by mesh_calc_islands_loop_poly_uv(), and poly_edge_loop_islands_calc().
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 | ||
) |
Definition at line 877 of file mesh_mapping.c.
References BLI_memarena_alloc(), MeshElemMap::count, MeshElemMap::indices, MeshIslandStore::innercuts, MeshIslandStore::islands, MeshIslandStore::islands_num, MeshIslandStore::islands_num_alloc, MeshIslandStore::items_to_islands, MeshIslandStore::mem, and UNLIKELY.
Referenced by mesh_calc_islands_loop_poly_uv().
void BKE_mesh_loop_islands_clear | ( | MeshIslandStore * | island_store | ) |
Definition at line 849 of file mesh_mapping.c.
References BLI_memarena_clear(), MeshIslandStore::innercut_type, MeshIslandStore::innercuts, MeshIslandStore::island_type, MeshIslandStore::islands, MeshIslandStore::islands_num, MeshIslandStore::islands_num_alloc, MeshIslandStore::item_type, MeshIslandStore::items_to_islands, MeshIslandStore::items_to_islands_num, MeshIslandStore::mem, MISLAND_TYPE_NONE, and NULL.
Referenced by mesh_calc_islands_loop_poly_uv().
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().
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 | ||
) |
Definition at line 815 of file mesh_mapping.c.
References BLI_assert, BLI_memarena_alloc(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, ELEM, MeshIslandStore::innercut_type, MeshIslandStore::innercuts, MeshIslandStore::island_type, MeshIslandStore::islands, MeshIslandStore::islands_num_alloc, MeshIslandStore::item_type, MeshIslandStore::items_to_islands, MeshIslandStore::items_to_islands_num, MeshIslandStore::mem, MISLAND_DEFAULT_BUFSIZE, MISLAND_TYPE_EDGE, MISLAND_TYPE_LOOP, MISLAND_TYPE_POLY, MISLAND_TYPE_VERT, and NULL.
Referenced by mesh_calc_islands_loop_poly_uv().
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.
totsource | The total number of elements that final_origindex points to. |
totfinal | The size of final_origindex |
final_origindex | The size of the final array. |
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.
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 | ||
) |
Definition at line 522 of file mesh_mapping.c.
References MeshElemMap::count, indices, MeshElemMap::indices, map, ME_POLY_TRI_TOT, MEM_callocN, MEM_mallocN, and MLoopTri::poly.
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 | ||
) |
Definition at line 31 of file mesh_mapping.c.
References Freestyle::a, BKE_mesh_uv_vert_map_free(), BLI_buffer_declare_static, BLI_buffer_free, BLI_BUFFER_NOP, BLI_buffer_reinit_data, UvVertMap::buf, copy_v2_v2(), cross_poly_v2(), fabsf, MPoly::flag, float(), UvMapVert::loop_of_poly_index, MPoly::loopstart, ME_FACE_SEL, ME_HIDE, MEM_callocN, MEM_freeN, UvMapVert::next, next, NULL, UvMapVert::poly_index, UvMapVert::separate, sub_v2_v2v2(), MPoly::totloop, MLoopUV::uv, v, MLoop::v, and UvVertMap::vert.
Definition at line 167 of file mesh_mapping.c.
References UvVertMap::buf, MEM_freeN, and UvVertMap::vert.
Referenced by BKE_mesh_uv_vert_map_create(), BM_uv_vert_map_create(), precalc_uv_layer(), ss_sync_from_uv(), and blender::io::obj::OBJMesh::store_uv_coords_and_indices().
Definition at line 162 of file mesh_mapping.c.
References v, and UvVertMap::vert.
Referenced by get_face_uv_map_vert(), precalc_uv_layer(), ss_sync_from_uv(), and blender::io::obj::OBJMesh::store_uv_coords_and_indices().
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.
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.
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().
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 | ||
) |
Definition at line 258 of file mesh_mapping.c.
References MeshElemMap::count, indices, MeshElemMap::indices, map, MEM_callocN, MEM_mallocN, MLoopTri::tri, and MLoop::v.
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().
|
static |
Definition at line 978 of file mesh_mapping.c.
References BKE_mesh_edge_loop_map_create(), BKE_mesh_edge_poly_map_create(), BKE_mesh_loop_islands_add(), BKE_mesh_loop_islands_clear(), BKE_mesh_loop_islands_init(), BLI_BITMAP_TEST, MLoop::e, MeshCheckIslandBoundaryUv::edge_loop_map, MeshCheckIslandBoundaryUv::loops, MPoly::loopstart, MeshCheckIslandBoundaryUv::luvs, MEM_freeN, MEM_mallocN, mesh_check_island_boundary_uv(), MISLAND_TYPE_EDGE, MISLAND_TYPE_LOOP, MISLAND_TYPE_POLY, NULL, and poly_edge_loop_islands_calc().
Referenced by BKE_mesh_calc_islands_loop_poly_edgeseam(), and BKE_mesh_calc_islands_loop_poly_uvmap().
|
static |
Definition at line 935 of file mesh_mapping.c.
References BLI_assert, MeshElemMap::count, data, MLoop::e, equals_v2v2(), MEdge::flag, MeshElemMap::indices, ME_SEAM, UNUSED_VARS_NDEBUG, user_data, MLoopUV::uv, MLoop::v, v1, and v2.
Referenced by mesh_calc_islands_loop_poly_uv().
|
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().
|
static |
Definition at line 569 of file mesh_mapping.c.
References BKE_mesh_edge_poly_map_create(), BLI_assert, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, MLoop::e, ELEM, if(), MeshElemMap::indices, MPoly::loopstart, MEM_callocN, MEM_freeN, MEM_mallocN, NULL, MPoly::totloop, and UNLIKELY.
Referenced by BKE_mesh_calc_smoothgroups(), and mesh_calc_islands_loop_poly_uv().
|
static |
Definition at line 764 of file mesh_mapping.c.
References MEdge::flag, MPoly::flag, MeshElemMap::indices, ME_SHARP, ME_SMOOTH, and return().
Referenced by BKE_mesh_calc_smoothgroups().