53 const int *vtargetmap,
54 const int direct_reverse)
56 int vert_source, first_vert_source, vert_target;
58 int i_loop_target, i_loop_target_start, i_loop_target_offset, i_loop_target_adjusted;
59 bool compare_completed =
false;
60 bool same_loops =
false;
62 MLoop *mloop_source, *mloop_target;
67 mloop_source = mloop_array + mpoly_source->
loopstart;
68 vert_source = mloop_source->
v;
70 if (vtargetmap[vert_source] != -1) {
71 vert_source = vtargetmap[vert_source];
79 mloop_target = mloop_array + mpoly_target->
loopstart;
80 for (i_loop_target = 0; i_loop_target < mpoly_target->
totloop; i_loop_target++, mloop_target++) {
81 if (mloop_target->
v == vert_source) {
87 if (i_loop_target >= mpoly_target->
totloop) {
96 i_loop_target_start = i_loop_target;
97 i_loop_target_offset = 0;
98 first_vert_source = vert_source;
100 compare_completed =
false;
103 while (!compare_completed) {
105 vert_target = mloop_target->
v;
111 if (i_loop_source == mpoly_source->
totloop) {
113 if (i_loop_target_offset == mpoly_target->
totloop - 1) {
114 compare_completed =
true;
119 compare_completed =
true;
125 vert_source = mloop_source->
v;
127 if (vtargetmap[vert_source] != -1) {
128 vert_source = vtargetmap[vert_source];
135 }
while (vert_source == vert_target);
137 if (compare_completed) {
142 i_loop_target_offset++;
144 if (i_loop_target_offset == mpoly_target->
totloop) {
147 for (; i_loop_source < mpoly_source->
totloop; i_loop_source++, mloop_source++) {
148 vert_source = vtargetmap[mloop_source->
v];
149 if (vert_source != first_vert_source) {
150 compare_completed =
true;
155 if (!compare_completed) {
163 i_loop_target_adjusted = (i_loop_target_start + direct_reverse * i_loop_target_offset) %
165 if (i_loop_target_adjusted < 0) {
166 i_loop_target_adjusted += mpoly_target->
totloop;
168 mloop_target = mloop_array + mpoly_target->
loopstart + i_loop_target_adjusted;
169 vert_target = mloop_target->
v;
171 if (vert_target != vert_source) {
240 const int *vtargetmap,
241 const int tot_vtargetmap,
242 const int merge_mode)
254 const int totvert_final = totvert - tot_vtargetmap;
291 int *poly_map_mem =
NULL;
306 for (i = 0; i < totvert; i++,
mv++) {
307 if (vtargetmap[i] == -1) {
319 for (i = 0; i < totvert; i++) {
320 if (vtargetmap[i] != -1) {
321 newv[i] = newv[vtargetmap[i]];
333 for (i = 0; i < totedge; i++, med++) {
334 const unsigned int v1 = (vtargetmap[med->
v1] != -1) ? vtargetmap[med->
v1] : med->
v1;
335 const unsigned int v2 = (vtargetmap[med->
v2] != -1) ? vtargetmap[med->
v2] : med->
v2;
368 for (i = 0; i < totpoly; i++, mp++, mpgh++) {
373 for (j = 0; j < mp->totloop; j++, ml++) {
388 for (i = 0; i < totpoly; i++, mp++) {
394 bool all_vertices_merged =
true;
396 for (j = 0; j < mp->
totloop; j++, ml++) {
397 if (vtargetmap[ml->
v] == -1) {
398 all_vertices_merged =
false;
408 if (
UNLIKELY(all_vertices_merged)) {
418 int i_poly, v_target;
427 for (j = 0; j < mp->
totloop; j++, ml++) {
428 v_target = vtargetmap[ml->
v];
444 v_target = vtargetmap[ml->
v];
448 for (i_poly = 0; i_poly < poly_map[v_target].
count; i_poly++) {
475 bool need_edge_from_last_valid_ml =
false;
476 bool need_edge_to_first_valid_ml =
false;
477 int created_edges = 0;
478 for (j = 0; j < mp->
totloop; j++, ml++) {
479 const uint mlv = (vtargetmap[ml->
v] != -1) ? vtargetmap[ml->
v] : ml->
v;
483 uint next_mlv = (vtargetmap[next_ml->v] != -1) ? vtargetmap[next_ml->v] : next_ml->v;
485 uint v1 = (vtargetmap[med->
v1] != -1) ? vtargetmap[med->
v1] : med->
v1;
486 uint v2 = (vtargetmap[med->
v2] != -1) ? vtargetmap[med->
v2] : med->
v2;
495 if (
UNLIKELY(last_valid_ml !=
NULL && need_edge_from_last_valid_ml)) {
499 uint v1 = (vtargetmap[last_valid_ml->
v] != -1) ? vtargetmap[last_valid_ml->
v] :
510 medge[new_eidx].
v1 = last_valid_ml->
v;
511 medge[new_eidx].
v2 = ml->
v;
517 last_valid_ml->
e = new_eidx;
519 need_edge_from_last_valid_ml =
false;
527 *last_valid_ml = *ml;
528 if (first_valid_ml ==
NULL) {
529 first_valid_ml = last_valid_ml;
536 last_valid_ml->
e = newe[ml->
e];
539 if (last_valid_ml !=
NULL) {
540 need_edge_from_last_valid_ml =
true;
543 need_edge_to_first_valid_ml =
true;
548 (need_edge_to_first_valid_ml || need_edge_from_last_valid_ml))) {
552 uint v1 = (vtargetmap[last_valid_ml->v] != -1) ? vtargetmap[last_valid_ml->v] :
554 uint v2 = (vtargetmap[first_valid_ml->v] != -1) ? vtargetmap[first_valid_ml->v] :
564 medge[new_eidx].
v1 = last_valid_ml->v;
565 medge[new_eidx].
v2 = first_valid_ml->v;
571 last_valid_ml->e = new_eidx;
573 need_edge_to_first_valid_ml = need_edge_from_last_valid_ml =
false;
583 if (created_edges > 0) {
615 for (i = 0; i <
result->totedge; i++, med++) {
617 med->v1 = newv[med->v1];
619 med->v2 = newv[med->v2];
629 for (i = 0; i <
result->totloop; i++, ml++) {
639 for (i = 0; i <
result->totvert; i++,
mv++) {
645 for (i = 0; i <
result->totpoly; i++, mp++) {
673 if (poly_map !=
NULL) {
676 if (poly_map_mem !=
NULL) {
CustomData interface, see also DNA_customdata_types.h.
void CustomData_copy_data(const struct CustomData *source, struct CustomData *dest, int source_index, int dest_index, int count)
void BKE_id_free(struct Main *bmain, void *idv)
struct Mesh * BKE_mesh_new_nomain_from_template(const struct Mesh *me_src, int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
@ MESH_MERGE_VERTS_DUMP_IF_EQUAL
@ MESH_MERGE_VERTS_DUMP_IF_MAPPED
void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem, const struct MPoly *mpoly, const struct MLoop *mloop, int totvert, int totpoly, int totloop)
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value)
EdgeHash * BLI_edgehash_new_ex(const char *info, const unsigned int nentries_reserve)
bool BLI_edgehash_ensure_p(EdgeHash *eh, unsigned int v0, unsigned int v1, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool BLI_edgehash_remove(EdgeHash *eh, unsigned int v0, unsigned int v1, EdgeHashFreeFP free_value)
void BLI_gset_flag_set(GSet *gs, unsigned int flag)
void BLI_gset_insert(GSet *gs, void *key)
GSet * BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define STACK_DISCARD(stack, n)
#define STACK_PUSH(stack, val)
#define STACK_DECLARE(stack)
#define STACK_INIT(stack, tot)
#define STACK_SIZE(stack)
#define STACK_PUSH_RET_PTR(stack)
_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.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
Mesh * BKE_mesh_merge_verts(Mesh *mesh, const int *vtargetmap, const int tot_vtargetmap, const int merge_mode)
static bool poly_gset_compare_fn(const void *k1, const void *k2)
static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpoly_target, const int *vtargetmap, const int direct_reverse)
static unsigned int poly_gset_hash_fn(const void *key)
struct CustomData pdata ldata