38 const bool use_winding)
53 for (
a = 0;
a < totpoly;
a++, mp++) {
67 winding =
MEM_callocN(
sizeof(*winding) * totpoly,
"winding");
70 if (!vmap->
vert || !vmap->
buf) {
76 for (
a = 0;
a < totpoly;
a++, mp++) {
86 for (i = 0; i < nverts; i++) {
94 copy_v2_v2(tf_uv[i], mloopuv[mpoly[
a].loopstart + i].uv);
107 for (
a = 0;
a < totvert;
a++) {
110 const float *uv, *uv2;
119 uv = mloopuv[mpoly[
v->poly_index].
loopstart +
v->loop_of_poly_index].
uv;
129 if (
fabsf(uv[0] - uv2[0]) < limit[0] &&
fabsf(uv[1] - uv2[1]) < limit[1] &&
130 (!use_winding || winding[iterv->
poly_index] == winding[
v->poly_index])) {
137 iterv->
next = newvlist;
150 vmap->
vert[
a] = newvlist;
164 return vmap->
vert[
v];
203 for (i = 0; i < totpoly; i++) {
204 const MPoly *p = &mpoly[i];
206 for (j = 0; j < p->
totloop; j++) {
212 for (i = 0; i < totvert; i++) {
213 map[i].indices = index_iter;
214 index_iter +=
map[i].count;
221 for (i = 0; i < totpoly; i++) {
222 const MPoly *p = &mpoly[i];
224 for (j = 0; j < p->
totloop; j++) {
263 const int totlooptri,
265 const int UNUSED(totloop))
274 for (i = 0, mlt = mlooptri; i < totlooptri; mlt++, i++) {
275 for (
int j = 3; j--;) {
276 map[mloop[mlt->
tri[j]].
v].count++;
282 for (i = 0; i < totvert; i++) {
283 map[i].indices = index_step;
284 index_step +=
map[i].count;
291 for (i = 0, mlt = mlooptri; i < totlooptri; mlt++, i++) {
292 for (
int j = 3; j--;) {
303 MeshElemMap **r_map,
int **r_mem,
const MEdge *medge,
int totvert,
int totedge)
312 for (i = 0; i < totedge; i++) {
313 map[medge[i].
v1].count++;
314 map[medge[i].
v2].count++;
318 for (i = 0; i < totvert; i++) {
319 map[i].indices = i_pt;
320 i_pt +=
map[i].count;
327 for (i = 0; i < totedge; i++) {
328 const uint v[2] = {medge[i].
v1, medge[i].
v2};
330 map[
v[0]].indices[
map[
v[0]].count] = i;
331 map[
v[1]].indices[
map[
v[1]].count] = i;
342 MeshElemMap **r_map,
int **r_mem,
const MEdge *medge,
int totvert,
int totedge)
351 for (i = 0; i < totedge; i++) {
352 map[medge[i].
v1].count++;
353 map[medge[i].
v2].count++;
357 for (i = 0; i < totvert; i++) {
358 map[i].indices = i_pt;
359 i_pt +=
map[i].count;
366 for (i = 0; i < totedge; i++) {
367 const uint v[2] = {medge[i].
v1, medge[i].
v2};
369 map[
v[0]].indices[
map[
v[0]].count] = (int)
v[1];
370 map[
v[1]].indices[
map[
v[1]].count] = (int)
v[0];
396 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
399 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
400 map[ml->
e].count += 2;
406 for (i = 0; i < totedge; i++) {
407 map[i].indices = index_step;
408 index_step +=
map[i].count;
415 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
420 for (ml = &mloop[j]; j < max_loop; j++, ml++) {
421 map_ele = &
map[ml->
e];
449 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
452 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
459 for (i = 0; i < totedge; i++) {
460 map[i].indices = index_step;
461 index_step +=
map[i].count;
468 for (i = 0, mp = mpoly; i < totpoly; mp++, i++) {
471 for (ml = &mloop[mp->
loopstart]; j--; ml++) {
484 const int *final_origindex,
493 for (i = 0; i < totfinal; i++) {
496 map[final_origindex[i]].count++;
502 for (i = 0; i < totsource; i++) {
503 map[i].indices = index_step;
504 index_step +=
map[i].count;
511 for (i = 0; i < totfinal; i++) {
527 const int looptri_num)
530 int *
indices =
MEM_mallocN(
sizeof(
int) * (
size_t)looptri_num,
"poly-tessface map mem");
536 for (i = 0; i < mpoly_num; i++) {
537 map[i].indices = index_step;
542 for (i = 0; i < looptri_num; i++) {
562 const struct MLoop *mloop,
563 const struct MEdge *medge,
564 const int edge_user_count,
565 const struct MPoly *mpoly_array,
576 const bool use_bitflags,
578 void *edge_boundary_check_data,
582 int *r_totedgeborder)
588 int num_edgeborders = 0;
591 const int temp_poly_group_id = 3;
594 const int poly_group_id_overflowed = 5;
597 bool group_id_overflow =
false;
600 int *edge_poly_mem =
NULL;
604 *r_poly_groups =
NULL;
605 if (r_edge_borders) {
606 *r_edge_borders =
NULL;
607 *r_totedgeborder = 0;
612 if (r_edge_borders) {
614 *r_totedgeborder = 0;
617 if (!edge_poly_map) {
619 &edge_poly_map, &edge_poly_mem, medge, totedge, mpoly, totpoly, mloop, totloop);
622 poly_groups =
MEM_callocN(
sizeof(
int) * (
size_t)totpoly, __func__);
623 poly_stack =
MEM_mallocN(
sizeof(
int) * (
size_t)totpoly, __func__);
627 int bit_poly_group_mask = 0;
629 int ps_curr_idx = 0, ps_end_idx = 0;
631 for (poly = poly_prev; poly < totpoly; poly++) {
632 if (poly_groups[poly] == 0) {
637 if (poly == totpoly) {
642 poly_group_id = use_bitflags ? temp_poly_group_id : ++tot_group;
645 poly_prev = poly + 1;
647 poly_groups[poly] = poly_group_id;
648 poly_stack[ps_end_idx++] = poly;
650 while (ps_curr_idx != ps_end_idx) {
655 poly = poly_stack[ps_curr_idx++];
656 BLI_assert(poly_groups[poly] == poly_group_id);
661 const int me_idx = (int)ml->
e;
662 const MEdge *me = &medge[me_idx];
663 const MeshElemMap *map_ele = &edge_poly_map[me_idx];
664 const int *p = map_ele->
indices;
665 int i = map_ele->count;
666 if (!edge_boundary_check(mp, ml, me, i, mpoly, map_ele, edge_boundary_check_data)) {
671 if (poly_groups[*p] == 0) {
672 poly_groups[*p] = poly_group_id;
673 poly_stack[ps_end_idx++] = *p;
686 int bit = poly_groups[*p];
687 if (!
ELEM(bit, 0, poly_group_id, poly_group_id_overflowed) &&
688 !(bit_poly_group_mask & bit)) {
689 bit_poly_group_mask |= bit;
701 int i, *p, gid_bit = 0;
705 for (; (poly_group_id & bit_poly_group_mask) && (gid_bit < 32); gid_bit++) {
715 "Warning, could not find an available id for current smooth group, faces will me "
717 "as out of any smooth group...\n");
720 poly_group_id = poly_group_id_overflowed;
722 group_id_overflow =
true;
724 if (gid_bit > tot_group) {
728 for (i = ps_end_idx, p = poly_stack; i--; p++) {
729 poly_groups[*p] = poly_group_id;
740 int i = totpoly, *gid = poly_groups;
742 if (*gid == poly_group_id_overflowed) {
756 *r_totgroup = tot_group;
757 *r_poly_groups = poly_groups;
758 if (r_edge_borders) {
759 *r_edge_borders = edge_borders;
760 *r_totedgeborder = num_edgeborders;
767 const int edge_user_count,
768 const MPoly *mpoly_array,
776 const MPoly *mp_other = (mp == &mpoly_array[edge_poly_map->
indices[0]]) ?
777 &mpoly_array[edge_poly_map->
indices[1]] :
778 &mpoly_array[edge_poly_map->
indices[0]];
791 const bool use_bitflags)
793 int *poly_groups =
NULL;
813 #define MISLAND_DEFAULT_BUFSIZE 64
816 const short item_type,
818 const short island_type,
819 const short innercut_type)
825 island_store->
mem = mem;
862 if (island_store->
mem) {
871 if (island_store->
mem) {
879 const int *items_indices,
880 const int num_island_items,
881 int *island_item_indices,
882 const int num_innercut_items,
883 int *innercut_item_indices)
888 const int curr_island_idx = island_store->
islands_num++;
889 const size_t curr_num_islands = (size_t)island_store->
islands_num;
901 memcpy(islds, island_store->
islands,
sizeof(*islds) * (curr_num_islands - 1));
905 memcpy(innrcuts, island_store->
innercuts,
sizeof(*innrcuts) * (curr_num_islands - 1));
910 isld->
count = num_island_items;
912 memcpy(isld->
indices, island_item_indices,
sizeof(*isld->
indices) * (
size_t)num_island_items);
915 innrcut->
count = num_innercut_items;
917 sizeof(*innrcut->
indices) * (
size_t)num_innercut_items);
919 innercut_item_indices,
920 sizeof(*innrcut->
indices) * (
size_t)num_innercut_items);
938 const int UNUSED(edge_user_count),
953 const float *uvco_v1 = luvs[edge_to_loops->
indices[0]].
uv;
954 const float *uvco_v2 = luvs[edge_to_loops->
indices[1]].
uv;
955 for (
int i = 2; i < edge_to_loops->
count; i += 2) {
956 if (loops[edge_to_loops->
indices[i]].
v ==
v1) {
979 const int UNUSED(totvert),
989 int *poly_groups =
NULL;
1003 int num_pidx, num_lidx;
1009 int num_edge_borders = 0;
1010 char *edge_border_count =
NULL;
1011 int *edge_innercut_indices =
NULL;
1012 int num_einnercuts = 0;
1014 int grp_idx, p_idx, pl_idx, l_idx;
1021 &edge_poly_map, &edge_poly_mem, edges, totedge, polys, totpoly, loops, totloop);
1025 &edge_loop_map, &edge_loop_mem, edges, totedge, polys, totpoly, loops, totloop);
1026 edge_boundary_check_data.
loops = loops;
1027 edge_boundary_check_data.
luvs = luvs;
1040 luvs ? &edge_boundary_check_data :
NULL,
1046 if (!num_poly_groups) {
1057 if (num_edge_borders) {
1058 edge_border_count =
MEM_mallocN(
sizeof(*edge_border_count) * (
size_t)totedge, __func__);
1059 edge_innercut_indices =
MEM_mallocN(
sizeof(*edge_innercut_indices) * (
size_t)num_edge_borders,
1063 poly_indices =
MEM_mallocN(
sizeof(*poly_indices) * (
size_t)totpoly, __func__);
1064 loop_indices =
MEM_mallocN(
sizeof(*loop_indices) * (
size_t)totloop, __func__);
1067 for (grp_idx = 1; grp_idx <= num_poly_groups; grp_idx++) {
1068 num_pidx = num_lidx = 0;
1069 if (num_edge_borders) {
1071 memset(edge_border_count, 0,
sizeof(*edge_border_count) * (
size_t)totedge);
1074 for (p_idx = 0; p_idx < totpoly; p_idx++) {
1077 if (poly_groups[p_idx] != grp_idx) {
1082 poly_indices[num_pidx++] = p_idx;
1083 for (l_idx = mp->
loopstart, pl_idx = 0; pl_idx < mp->totloop; l_idx++, pl_idx++) {
1084 MLoop *ml = &loops[l_idx];
1085 loop_indices[num_lidx++] = l_idx;
1087 (edge_border_count[ml->
e] < 2)) {
1088 edge_border_count[ml->
e]++;
1089 if (edge_border_count[ml->
e] == 2) {
1090 edge_innercut_indices[num_einnercuts++] = (int)ml->
e;
1102 edge_innercut_indices);
1121 if (num_edge_borders) {
1139 verts, totvert, edges, totedge, polys, totpoly, loops, totloop,
NULL, r_island_store);
1155 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_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#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)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
#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 void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1)
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
ccl_gpu_kernel_postfix int ccl_global int * indices
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
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)
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)
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)
UvMapVert * BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, uint v)
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))
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)
void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store)
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)
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)
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)
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)
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)
SocketIndexByIdentifierMap * map
const MeshElemMap * edge_loop_map
struct MeshElemMap ** innercuts
struct MeshElemMap ** islands
unsigned short loop_of_poly_index