55 const bool use_winding)
70 for (
a = 0;
a < totpoly;
a++, mp++) {
84 winding =
MEM_callocN(
sizeof(*winding) * totpoly,
"winding");
87 if (!vmap->
vert || !vmap->
buf) {
93 for (
a = 0;
a < totpoly;
a++, mp++) {
103 for (i = 0; i < nverts; i++) {
111 copy_v2_v2(tf_uv[i], mloopuv[mpoly[
a].loopstart + i].uv);
124 for (
a = 0;
a < totvert;
a++) {
127 const float *uv, *uv2;
136 uv = mloopuv[mpoly[
v->poly_index].
loopstart +
v->loop_of_poly_index].
uv;
146 if (
fabsf(uv[0] - uv2[0]) < limit[0] &&
fabsf(uv[1] - uv2[1]) < limit[1] &&
147 (!use_winding || winding[iterv->
poly_index] == winding[
v->poly_index])) {
154 iterv->
next = newvlist;
167 vmap->
vert[
a] = newvlist;
181 return vmap->
vert[
v];
220 for (i = 0; i < totpoly; i++) {
221 const MPoly *p = &mpoly[i];
223 for (j = 0; j < p->
totloop; j++) {
229 for (i = 0; i < totvert; i++) {
231 index_iter += map[i].
count;
238 for (i = 0; i < totpoly; i++) {
239 const MPoly *p = &mpoly[i];
241 for (j = 0; j < p->
totloop; j++) {
295 const int totlooptri,
297 const int UNUSED(totloop))
306 for (i = 0, mlt = mlooptri; i < totlooptri; mlt++, i++) {
307 for (
int j = 3; j--;) {
314 for (i = 0; i < totvert; i++) {
316 index_step += map[i].
count;
323 for (i = 0, mlt = mlooptri; i < totlooptri; mlt++, i++) {
324 for (
int j = 3; j--;) {
340 MeshElemMap **r_map,
int **r_mem,
const MEdge *medge,
int totvert,
int totedge)
349 for (i = 0; i < totedge; i++) {
355 for (i = 0; i < totvert; i++) {
357 i_pt += map[i].
count;
364 for (i = 0; i < totedge; i++) {
365 const unsigned int v[2] = {medge[i].
v1, medge[i].
v2};
383 MeshElemMap **r_map,
int **r_mem,
const MEdge *medge,
int totvert,
int totedge)
392 for (i = 0; i < totedge; i++) {
398 for (i = 0; i < totvert; i++) {
400 i_pt += map[i].
count;
407 for (i = 0; i < totedge; i++) {
408 const unsigned int v[2] = {medge[i].
v1, medge[i].
v2};
442 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
445 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
452 for (i = 0; i < totedge; i++) {
454 index_step += map[i].
count;
461 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
466 for (ml = &mloop[j]; j < max_loop; j++, ml++) {
467 map_ele = &map[ml->
e];
500 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
503 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
510 for (i = 0; i < totedge; i++) {
512 index_step += map[i].
count;
519 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
522 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
549 const int *final_origindex,
558 for (i = 0; i < totfinal; i++) {
561 map[final_origindex[i]].
count++;
567 for (i = 0; i < totsource; i++) {
569 index_step += map[i].
count;
576 for (i = 0; i < totfinal; i++) {
596 const int looptri_num)
599 int *
indices =
MEM_mallocN(
sizeof(
int) * (
size_t)looptri_num,
"poly-tessface map mem");
605 for (i = 0; i < mpoly_num; i++) {
611 for (i = 0; i < looptri_num; i++) {
631 const struct MLoop *mloop,
632 const struct MEdge *medge,
633 const int nbr_egde_users,
634 const struct MPoly *mpoly_array,
645 const bool use_bitflags,
647 void *edge_boundary_check_data,
651 int *r_totedgeborder)
657 int num_edgeborders = 0;
660 const int temp_poly_group_id = 3;
663 const int poly_group_id_overflowed = 5;
666 bool group_id_overflow =
false;
669 int *edge_poly_mem =
NULL;
673 *r_poly_groups =
NULL;
674 if (r_edge_borders) {
675 *r_edge_borders =
NULL;
676 *r_totedgeborder = 0;
681 if (r_edge_borders) {
683 *r_totedgeborder = 0;
686 if (!edge_poly_map) {
688 &edge_poly_map, &edge_poly_mem, medge, totedge, mpoly, totpoly, mloop, totloop);
691 poly_groups =
MEM_callocN(
sizeof(
int) * (
size_t)totpoly, __func__);
692 poly_stack =
MEM_mallocN(
sizeof(
int) * (
size_t)totpoly, __func__);
696 int bit_poly_group_mask = 0;
698 int ps_curr_idx = 0, ps_end_idx = 0;
700 for (poly = poly_prev; poly < totpoly; poly++) {
701 if (poly_groups[poly] == 0) {
706 if (poly == totpoly) {
711 poly_group_id = use_bitflags ? temp_poly_group_id : ++tot_group;
714 poly_prev = poly + 1;
716 poly_groups[poly] = poly_group_id;
717 poly_stack[ps_end_idx++] = poly;
719 while (ps_curr_idx != ps_end_idx) {
724 poly = poly_stack[ps_curr_idx++];
725 BLI_assert(poly_groups[poly] == poly_group_id);
730 const int me_idx = (int)ml->
e;
731 const MEdge *me = &medge[me_idx];
732 const MeshElemMap *map_ele = &edge_poly_map[me_idx];
733 const int *p = map_ele->
indices;
734 int i = map_ele->count;
735 if (!edge_boundary_check(mp, ml, me, i, mpoly, map_ele, edge_boundary_check_data)) {
740 if (poly_groups[*p] == 0) {
741 poly_groups[*p] = poly_group_id;
742 poly_stack[ps_end_idx++] = *p;
755 int bit = poly_groups[*p];
756 if (!
ELEM(bit, 0, poly_group_id, poly_group_id_overflowed) &&
757 !(bit_poly_group_mask & bit)) {
758 bit_poly_group_mask |= bit;
770 int i, *p, gid_bit = 0;
774 for (; (poly_group_id & bit_poly_group_mask) && (gid_bit < 32); gid_bit++) {
784 "Warning, could not find an available id for current smooth group, faces will me "
786 "as out of any smooth group...\n");
789 poly_group_id = poly_group_id_overflowed;
791 group_id_overflow =
true;
793 if (gid_bit > tot_group) {
797 for (i = ps_end_idx, p = poly_stack; i--; p++) {
798 poly_groups[*p] = poly_group_id;
809 int i = totpoly, *gid = poly_groups;
811 if (*gid == poly_group_id_overflowed) {
825 *r_totgroup = tot_group;
826 *r_poly_groups = poly_groups;
827 if (r_edge_borders) {
828 *r_edge_borders = edge_borders;
829 *r_totedgeborder = num_edgeborders;
836 const int nbr_egde_users,
837 const MPoly *mpoly_array,
845 const MPoly *mp_other = (mp == &mpoly_array[edge_poly_map->
indices[0]]) ?
846 &mpoly_array[edge_poly_map->
indices[1]] :
847 &mpoly_array[edge_poly_map->
indices[0]];
868 const bool use_bitflags)
870 int *poly_groups =
NULL;
890 #define MISLAND_DEFAULT_BUFSIZE 64
893 const short item_type,
895 const short island_type,
896 const short innercut_type)
902 island_store->
mem = mem;
939 if (island_store->
mem) {
948 if (island_store->
mem) {
956 const int *items_indices,
957 const int num_island_items,
958 int *island_item_indices,
959 const int num_innercut_items,
960 int *innercut_item_indices)
965 const int curr_island_idx = island_store->
islands_num++;
966 const size_t curr_num_islands = (size_t)island_store->
islands_num;
978 memcpy(islds, island_store->
islands,
sizeof(*islds) * (curr_num_islands - 1));
982 memcpy(innrcuts, island_store->
innercuts,
sizeof(*innrcuts) * (curr_num_islands - 1));
987 isld->
count = num_island_items;
989 memcpy(isld->
indices, island_item_indices,
sizeof(*isld->
indices) * (
size_t)num_island_items);
992 innrcut->
count = num_innercut_items;
994 sizeof(*innrcut->
indices) * (
size_t)num_innercut_items);
996 innercut_item_indices,
997 sizeof(*innrcut->
indices) * (
size_t)num_innercut_items);
1015 const int UNUSED(nbr_egde_users),
1028 const unsigned int v1 = loops[edge_to_loops->
indices[0]].
v;
1029 const unsigned int v2 = loops[edge_to_loops->
indices[1]].
v;
1030 const float *uvco_v1 = luvs[edge_to_loops->
indices[0]].
uv;
1031 const float *uvco_v2 = luvs[edge_to_loops->
indices[1]].
uv;
1032 for (
int i = 2; i < edge_to_loops->
count; i += 2) {
1033 if (loops[edge_to_loops->
indices[i]].
v ==
v1) {
1056 const int UNUSED(totvert),
1066 int *poly_groups =
NULL;
1067 int num_poly_groups;
1080 int num_pidx, num_lidx;
1086 int num_edge_borders = 0;
1087 char *edge_border_count =
NULL;
1088 int *edge_innercut_indices =
NULL;
1089 int num_einnercuts = 0;
1091 int grp_idx, p_idx, pl_idx, l_idx;
1098 &edge_poly_map, &edge_poly_mem, edges, totedge, polys, totpoly, loops, totloop);
1102 &edge_loop_map, &edge_loop_mem, edges, totedge, polys, totpoly, loops, totloop);
1103 edge_boundary_check_data.
loops = loops;
1104 edge_boundary_check_data.
luvs = luvs;
1117 luvs ? &edge_boundary_check_data :
NULL,
1123 if (!num_poly_groups) {
1134 if (num_edge_borders) {
1135 edge_border_count =
MEM_mallocN(
sizeof(*edge_border_count) * (
size_t)totedge, __func__);
1136 edge_innercut_indices =
MEM_mallocN(
sizeof(*edge_innercut_indices) * (
size_t)num_edge_borders,
1140 poly_indices =
MEM_mallocN(
sizeof(*poly_indices) * (
size_t)totpoly, __func__);
1141 loop_indices =
MEM_mallocN(
sizeof(*loop_indices) * (
size_t)totloop, __func__);
1144 for (grp_idx = 1; grp_idx <= num_poly_groups; grp_idx++) {
1145 num_pidx = num_lidx = 0;
1146 if (num_edge_borders) {
1148 memset(edge_border_count, 0,
sizeof(*edge_border_count) * (
size_t)totedge);
1151 for (p_idx = 0; p_idx < totpoly; p_idx++) {
1154 if (poly_groups[p_idx] != grp_idx) {
1159 poly_indices[num_pidx++] = p_idx;
1160 for (l_idx = mp->
loopstart, pl_idx = 0; pl_idx < mp->totloop; l_idx++, pl_idx++) {
1161 MLoop *ml = &loops[l_idx];
1162 loop_indices[num_lidx++] = l_idx;
1164 (edge_border_count[ml->
e] < 2)) {
1165 edge_border_count[ml->
e]++;
1166 if (edge_border_count[ml->
e] == 2) {
1167 edge_innercut_indices[num_einnercuts++] = (int)ml->
e;
1179 edge_innercut_indices);
1198 if (num_edge_borders) {
1220 verts, totvert, edges, totedge, polys, totpoly, loops, totloop,
NULL, r_island_store);
1249 verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store);
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
#define BLI_buffer_reinit_data(buffer_, type_, new_count_)
#define BLI_buffer_declare_static(type_, name_, flag_, static_count_)
#define BLI_buffer_free(name_)
float cross_poly_v2(const float verts[][2], unsigned int nr)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE bool equals_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
#define BLI_MEMARENA_STD_BUFSIZE
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(const size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2) ATTR_MALLOC
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
#define UNUSED_VARS_NDEBUG(...)
#define ME_POLY_TRI_TOT(mp)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
return(oflags[bm->toolflag_index].f &oflag) !=0
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
bool(* MeshRemap_CheckIslandBoundary)(const struct MPoly *mpoly, const struct MLoop *mloop, const struct MEdge *medge, const int nbr_egde_users, const struct MPoly *mpoly_array, const struct MeshElemMap *edge_poly_map, void *user_data)
struct MeshCheckIslandBoundaryUv MeshCheckIslandBoundaryUv
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)
UvMapVert * BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v)
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)
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)
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_origindex_map_create(MeshElemMap **r_map, int **r_mem, const int totsource, const int *final_origindex, const int totfinal)
void BKE_mesh_vert_edge_vert_map_create(MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
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)
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)
#define MISLAND_DEFAULT_BUFSIZE
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)
UvVertMap * BKE_mesh_uv_vert_map_create(const MPoly *mpoly, const MLoop *mloop, const MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, const float limit[2], const bool selected, const bool use_winding)
void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store)
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_uv_vert_map_free(UvVertMap *vmap)
static bool mesh_check_island_boundary_uv(const MPoly *UNUSED(mp), const MLoop *ml, const MEdge *me, const int UNUSED(nbr_egde_users), const MPoly *UNUSED(mpoly_array), const MeshElemMap *UNUSED(edge_poly_map), void *user_data)
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_edge_map_create(MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int totedge)
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_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)
static bool poly_is_island_boundary_smooth_cb(const MPoly *mp, const MLoop *UNUSED(ml), const MEdge *me, const int nbr_egde_users, const MPoly *mpoly_array, const MeshElemMap *edge_poly_map, void *UNUSED(user_data))
void BKE_mesh_loop_islands_free(MeshIslandStore *island_store)
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)
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)
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)
const MeshElemMap * edge_loop_map
struct MeshElemMap ** innercuts
struct MeshElemMap ** islands
unsigned short loop_of_poly_index