Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_mesh_mapping.h
| Show All 9 Lines | |||||
| # include "BLI_array.hh" | # include "BLI_array.hh" | ||||
| #endif | #endif | ||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #endif | #endif | ||||
| struct MEdge; | struct MEdge; | ||||
| struct MLoop; | |||||
| struct MLoopTri; | struct MLoopTri; | ||||
| struct MPoly; | struct MPoly; | ||||
| /* UvVertMap */ | /* UvVertMap */ | ||||
| #define STD_UV_CONNECT_LIMIT 0.0001f | #define STD_UV_CONNECT_LIMIT 0.0001f | ||||
| /* Map from uv vertex to face. Used by select linked, uv subdivision-surface and obj exporter. */ | /* Map from uv vertex to face. Used by select linked, uv subdivision-surface and obj exporter. */ | ||||
| typedef struct UvVertMap { | typedef struct UvVertMap { | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | typedef struct MeshElemMap { | ||||
| int *indices; | int *indices; | ||||
| int count; | int count; | ||||
| } MeshElemMap; | } MeshElemMap; | ||||
| /* mapping */ | /* mapping */ | ||||
| UvVertMap *BKE_mesh_uv_vert_map_create(const struct MPoly *mpoly, | UvVertMap *BKE_mesh_uv_vert_map_create(const struct MPoly *mpoly, | ||||
| const bool *hide_poly, | const bool *hide_poly, | ||||
| const bool *select_poly, | const bool *select_poly, | ||||
| const struct MLoop *mloop, | const int *corner_verts, | ||||
| const float (*mloopuv)[2], | const float (*mloopuv)[2], | ||||
| unsigned int totpoly, | unsigned int totpoly, | ||||
| unsigned int totvert, | unsigned int totvert, | ||||
| const float limit[2], | const float limit[2], | ||||
| bool selected, | bool selected, | ||||
| bool use_winding); | bool use_winding); | ||||
| UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v); | UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v); | ||||
| void BKE_mesh_uv_vert_map_free(UvVertMap *vmap); | void BKE_mesh_uv_vert_map_free(UvVertMap *vmap); | ||||
| /** | /** | ||||
| * Generates a map where the key is the vertex and the value | * Generates a map where the key is the vertex and the value | ||||
| * is a list of polys that use that vertex as a corner. | * is a list of polys that use that vertex as a corner. | ||||
| * The lists are allocated from one memory pool. | * The lists are allocated from one memory pool. | ||||
| */ | */ | ||||
| void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, | void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, | ||||
| int **r_mem, | int **r_mem, | ||||
| const struct MPoly *mpoly, | const struct MPoly *mpoly, | ||||
| const struct MLoop *mloop, | const int *corner_verts, | ||||
| int totvert, | int totvert, | ||||
| int totpoly, | int totpoly, | ||||
| int totloop); | int totloop); | ||||
| /** | /** | ||||
| * Generates a map where the key is the vertex and the value | * Generates a map where the key is the vertex and the value | ||||
| * is a list of loops that use that vertex as a corner. | * is a list of loops that use that vertex as a corner. | ||||
| * The lists are allocated from one memory pool. | * The lists are allocated from one memory pool. | ||||
| */ | */ | ||||
| void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map, | void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map, | ||||
| int **r_mem, | int **r_mem, | ||||
| const struct MPoly *mpoly, | const struct MPoly *mpoly, | ||||
| const struct MLoop *mloop, | const int *corner_verts, | ||||
| int totvert, | int totvert, | ||||
| int totpoly, | int totpoly, | ||||
| int totloop); | int totloop); | ||||
| /** | /** | ||||
| * Generates a map where the key is the edge and the value | * Generates a map where the key is the edge and the value | ||||
| * is a list of looptris that use that edge. | * is a list of looptris that use that edge. | ||||
| * The lists are allocated from one memory pool. | * The lists are allocated from one memory pool. | ||||
| */ | */ | ||||
| void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, | void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, | ||||
| int **r_mem, | int **r_mem, | ||||
| int totvert, | int totvert, | ||||
| const struct MLoopTri *mlooptri, | const struct MLoopTri *mlooptri, | ||||
| int totlooptri, | int totlooptri, | ||||
| const struct MLoop *mloop, | const int *corner_verts, | ||||
| int totloop); | int totloop); | ||||
| /** | /** | ||||
| * Generates a map where the key is the vertex and the value | * Generates a map where the key is the vertex and the value | ||||
| * is a list of edges that use that vertex as an endpoint. | * is a list of edges that use that vertex as an endpoint. | ||||
| * The lists are allocated from one memory pool. | * The lists are allocated from one memory pool. | ||||
| */ | */ | ||||
| void 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); | MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totvert, int totedge); | ||||
| Show All 9 Lines | |||||
| * The lists are allocated from one memory pool. | * The lists are allocated from one memory pool. | ||||
| */ | */ | ||||
| void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, | void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, | ||||
| int **r_mem, | int **r_mem, | ||||
| const struct MEdge *medge, | const struct MEdge *medge, | ||||
| int totedge, | int totedge, | ||||
| const struct MPoly *mpoly, | const struct MPoly *mpoly, | ||||
| int totpoly, | int totpoly, | ||||
| const struct MLoop *mloop, | const int *corner_edges, | ||||
| int totloop); | int totloop); | ||||
| /** | /** | ||||
| * Generates a map where the key is the edge and the value | * Generates a map where the key is the edge and the value | ||||
| * is a list of polygons that use that edge. | * is a list of polygons that use that edge. | ||||
| * The lists are allocated from one memory pool. | * The lists are allocated from one memory pool. | ||||
| */ | */ | ||||
| void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, | void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, | ||||
| int **r_mem, | int **r_mem, | ||||
| const struct MEdge *medge, | const struct MEdge *medge, | ||||
| int totedge, | int totedge, | ||||
| const struct MPoly *mpoly, | const struct MPoly *mpoly, | ||||
| int totpoly, | int totpoly, | ||||
| const struct MLoop *mloop, | const int *corner_edges, | ||||
| int totloop); | int totloop); | ||||
| /** | /** | ||||
| * This function creates a map so the source-data (vert/edge/loop/poly) | * This function creates a map so the source-data (vert/edge/loop/poly) | ||||
| * can loop over the destination data (using the destination arrays origindex). | * can loop over the destination data (using the destination arrays origindex). | ||||
| * | * | ||||
| * This has the advantage that it can operate on any data-types. | * This has the advantage that it can operate on any data-types. | ||||
| * | * | ||||
| * \param totsource: The total number of elements that \a final_origindex points to. | * \param totsource: The total number of elements that \a final_origindex points to. | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | void BKE_mesh_loop_islands_add(MeshIslandStore *island_store, | ||||
| int *innercut_item_indices); | int *innercut_item_indices); | ||||
| typedef bool (*MeshRemapIslandsCalc)(const float (*vert_positions)[3], | typedef bool (*MeshRemapIslandsCalc)(const float (*vert_positions)[3], | ||||
| int totvert, | int totvert, | ||||
| const struct MEdge *edges, | const struct MEdge *edges, | ||||
| int totedge, | int totedge, | ||||
| const struct MPoly *polys, | const struct MPoly *polys, | ||||
| int totpoly, | int totpoly, | ||||
| const struct MLoop *loops, | const int *corner_verts, | ||||
| const int *corner_edges, | |||||
| int totloop, | int totloop, | ||||
| struct MeshIslandStore *r_island_store); | struct MeshIslandStore *r_island_store); | ||||
| /* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here. | /* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here. | ||||
| * So better keep them separated for now, I think. */ | * So better keep them separated for now, I think. */ | ||||
| /** | /** | ||||
| * Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams), | * Calculate 'generic' UV islands, i.e. based only on actual geometry data (edge seams), | ||||
| * not some UV layers coordinates. | * not some UV layers coordinates. | ||||
| */ | */ | ||||
| bool BKE_mesh_calc_islands_loop_poly_edgeseam(const float (*vert_positions)[3], | bool BKE_mesh_calc_islands_loop_poly_edgeseam(const float (*vert_positions)[3], | ||||
| int totvert, | int totvert, | ||||
| const struct MEdge *edges, | const struct MEdge *edges, | ||||
| int totedge, | int totedge, | ||||
| const struct MPoly *polys, | const struct MPoly *polys, | ||||
| int totpoly, | int totpoly, | ||||
| const struct MLoop *loops, | const int *corner_verts, | ||||
| const int *corner_edges, | |||||
| int totloop, | int totloop, | ||||
| MeshIslandStore *r_island_store); | MeshIslandStore *r_island_store); | ||||
| /** | /** | ||||
| * Calculate UV islands. | * Calculate UV islands. | ||||
| * | * | ||||
| * \note If no UV layer is passed, we only consider edges tagged as seams as UV boundaries. | * \note If no UV 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. | * 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. | * However, it means actual UV islands without matching UV seams will not be handled correctly. | ||||
| * If a valid UV layer is passed as \a luvs parameter, | * If a valid UV layer is passed as \a luvs parameter, | ||||
| * UV coordinates are also used to detect islands boundaries. | * UV coordinates are also used to detect islands boundaries. | ||||
| * | * | ||||
| * \note All this could be optimized. | * \note All this could be optimized. | ||||
| * Not sure it would be worth the more complex code, though, | * Not sure it would be worth the more complex code, though, | ||||
| * those loops are supposed to be really quick to do. | * those loops are supposed to be really quick to do. | ||||
| */ | */ | ||||
| bool BKE_mesh_calc_islands_loop_poly_uvmap(float (*vert_positions)[3], | bool BKE_mesh_calc_islands_loop_poly_uvmap(float (*vert_positions)[3], | ||||
| int totvert, | int totvert, | ||||
| struct MEdge *edges, | struct MEdge *edges, | ||||
| int totedge, | int totedge, | ||||
| struct MPoly *polys, | struct MPoly *polys, | ||||
| int totpoly, | int totpoly, | ||||
| struct MLoop *loops, | const int *corner_verts, | ||||
| const int *corner_edges, | |||||
| int totloop, | int totloop, | ||||
| const float (*luvs)[2], | const float (*luvs)[2], | ||||
| MeshIslandStore *r_island_store); | MeshIslandStore *r_island_store); | ||||
| /** | /** | ||||
| * Calculate smooth groups from sharp edges. | * Calculate smooth groups from sharp edges. | ||||
| * | * | ||||
| * \param r_totgroup: The total number of groups, 1 or more. | * \param r_totgroup: The total number of groups, 1 or more. | ||||
| * \return Polygon aligned array of group index values (bitflags if use_bitflags is true), | * \return Polygon aligned array of group index values (bitflags if use_bitflags is true), | ||||
| * starting at 1 (0 being used as 'invalid' flag). | * starting at 1 (0 being used as 'invalid' flag). | ||||
| * Note it's callers's responsibility to MEM_freeN returned array. | * Note it's callers's responsibility to MEM_freeN returned array. | ||||
| */ | */ | ||||
| int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge, | int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge, | ||||
| int totedge, | int totedge, | ||||
| const struct MPoly *mpoly, | const struct MPoly *mpoly, | ||||
| int totpoly, | int totpoly, | ||||
| const struct MLoop *mloop, | const int *corner_edges, | ||||
| int totloop, | int totloop, | ||||
| const bool *sharp_edges, | const bool *sharp_edges, | ||||
| int *r_totgroup, | int *r_totgroup, | ||||
| bool use_bitflags); | bool use_bitflags); | ||||
| /* use on looptri vertex values */ | /* use on looptri vertex values */ | ||||
| #define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v) \ | #define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v) \ | ||||
| ((CHECK_TYPE_ANY( \ | ((CHECK_TYPE_ANY( \ | ||||
| Show All 12 Lines | |||||
| # include "DNA_meshdata_types.h" /* MPoly */ | # include "DNA_meshdata_types.h" /* MPoly */ | ||||
| namespace blender::bke::mesh_topology { | namespace blender::bke::mesh_topology { | ||||
| Array<int> build_loop_to_poly_map(Span<MPoly> polys, int loops_num); | Array<int> build_loop_to_poly_map(Span<MPoly> polys, int loops_num); | ||||
| Array<Vector<int>> build_vert_to_edge_map(Span<MEdge> edges, int verts_num); | Array<Vector<int>> build_vert_to_edge_map(Span<MEdge> edges, int verts_num); | ||||
| Array<Vector<int>> build_vert_to_poly_map(Span<MPoly> polys, Span<MLoop> loops, int verts_num); | Array<Vector<int>> build_vert_to_poly_map(Span<MPoly> polys, | ||||
| Array<Vector<int>> build_vert_to_loop_map(Span<MLoop> loops, int verts_num); | Span<int> corner_verts, | ||||
| Array<Vector<int>> build_edge_to_loop_map(Span<MLoop> loops, int edges_num); | int verts_num); | ||||
| Vector<Vector<int>> build_edge_to_loop_map_resizable(Span<MLoop> loops, int edges_num); | Array<Vector<int>> build_vert_to_loop_map(Span<int> corner_verts, int verts_num); | ||||
| Array<Vector<int>> build_edge_to_loop_map(Span<int> corner_edges, int edges_num); | |||||
| Vector<Vector<int>> build_edge_to_loop_map_resizable(Span<int> corner_edges, int edges_num); | |||||
| inline int poly_loop_prev(const MPoly &poly, int loop_i) | inline int poly_loop_prev(const MPoly &poly, int loop_i) | ||||
| { | { | ||||
| return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop; | return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop; | ||||
| } | } | ||||
| inline int poly_loop_next(const MPoly &poly, int loop_i) | inline int poly_loop_next(const MPoly &poly, int loop_i) | ||||
| { | { | ||||
| if (loop_i == poly.loopstart + poly.totloop - 1) { | if (loop_i == poly.loopstart + poly.totloop - 1) { | ||||
| return poly.loopstart; | return poly.loopstart; | ||||
| } | } | ||||
| return loop_i + 1; | return loop_i + 1; | ||||
| } | } | ||||
| } // namespace blender::bke::mesh_topology | } // namespace blender::bke::mesh_topology | ||||
| #endif | #endif | ||||