38 const int *vtargetmap,
39 const int direct_reverse)
41 int vert_source, first_vert_source, vert_target;
43 int i_loop_target, i_loop_target_start, i_loop_target_offset, i_loop_target_adjusted;
44 bool compare_completed =
false;
45 bool same_loops =
false;
47 MLoop *mloop_source, *mloop_target;
52 mloop_source = mloop_array + mpoly_source->
loopstart;
53 vert_source = mloop_source->
v;
55 if (vtargetmap[vert_source] != -1) {
56 vert_source = vtargetmap[vert_source];
64 mloop_target = mloop_array + mpoly_target->
loopstart;
65 for (i_loop_target = 0; i_loop_target < mpoly_target->
totloop; i_loop_target++, mloop_target++) {
66 if (mloop_target->
v == vert_source) {
72 if (i_loop_target >= mpoly_target->
totloop) {
81 i_loop_target_start = i_loop_target;
82 i_loop_target_offset = 0;
83 first_vert_source = vert_source;
85 compare_completed =
false;
88 while (!compare_completed) {
90 vert_target = mloop_target->
v;
96 if (i_loop_source == mpoly_source->
totloop) {
98 if (i_loop_target_offset == mpoly_target->
totloop - 1) {
99 compare_completed =
true;
104 compare_completed =
true;
110 vert_source = mloop_source->
v;
112 if (vtargetmap[vert_source] != -1) {
113 vert_source = vtargetmap[vert_source];
120 }
while (vert_source == vert_target);
122 if (compare_completed) {
127 i_loop_target_offset++;
129 if (i_loop_target_offset == mpoly_target->
totloop) {
132 for (; i_loop_source < mpoly_source->
totloop; i_loop_source++, mloop_source++) {
133 vert_source = vtargetmap[mloop_source->
v];
134 if (vert_source != first_vert_source) {
135 compare_completed =
true;
140 if (!compare_completed) {
148 i_loop_target_adjusted = (i_loop_target_start + direct_reverse * i_loop_target_offset) %
150 if (i_loop_target_adjusted < 0) {
151 i_loop_target_adjusted += mpoly_target->
totloop;
153 mloop_target = mloop_array + mpoly_target->
loopstart + i_loop_target_adjusted;
154 vert_target = mloop_target->
v;
156 if (vert_target != vert_source) {
193 const int *vtargetmap,
194 const int tot_vtargetmap,
195 const int merge_mode)
207 const int totvert_final = totvert - tot_vtargetmap;
244 int *poly_map_mem =
NULL;
259 for (i = 0; i < totvert; i++,
mv++) {
260 if (vtargetmap[i] == -1) {
272 for (i = 0; i < totvert; i++) {
273 if (vtargetmap[i] != -1) {
274 newv[i] = newv[vtargetmap[i]];
286 for (i = 0; i < totedge; i++, med++) {
287 const uint v1 = (vtargetmap[med->
v1] != -1) ? vtargetmap[med->
v1] : med->
v1;
288 const uint v2 = (vtargetmap[med->
v2] != -1) ? vtargetmap[med->
v2] : med->
v2;
321 for (i = 0; i < totpoly; i++, mp++, mpgh++) {
326 for (j = 0; j < mp->totloop; j++, ml++) {
343 for (i = 0; i < totpoly; i++, mp++) {
349 bool all_vertices_merged =
true;
351 for (j = 0; j < mp->
totloop; j++, ml++) {
352 if (vtargetmap[ml->
v] == -1) {
353 all_vertices_merged =
false;
363 if (
UNLIKELY(all_vertices_merged)) {
373 int i_poly, v_target;
382 for (j = 0; j < mp->
totloop; j++, ml++) {
383 v_target = vtargetmap[ml->
v];
399 v_target = vtargetmap[ml->
v];
403 for (i_poly = 0; i_poly < poly_map[v_target].
count; i_poly++) {
430 bool need_edge_from_last_valid_ml =
false;
431 bool need_edge_to_first_valid_ml =
false;
432 int created_edges = 0;
433 for (j = 0; j < mp->
totloop; j++, ml++) {
434 const uint mlv = (vtargetmap[ml->
v] != -1) ? vtargetmap[ml->
v] : ml->
v;
438 uint next_mlv = (vtargetmap[next_ml->v] != -1) ? vtargetmap[next_ml->v] : next_ml->v;
440 uint v1 = (vtargetmap[med->
v1] != -1) ? vtargetmap[med->
v1] : med->
v1;
441 uint v2 = (vtargetmap[med->
v2] != -1) ? vtargetmap[med->
v2] : med->
v2;
450 if (
UNLIKELY(last_valid_ml !=
NULL && need_edge_from_last_valid_ml)) {
454 uint v1 = (vtargetmap[last_valid_ml->
v] != -1) ? vtargetmap[last_valid_ml->
v] :
465 medge[new_eidx].
v1 = last_valid_ml->
v;
466 medge[new_eidx].
v2 = ml->
v;
472 last_valid_ml->
e = new_eidx;
474 need_edge_from_last_valid_ml =
false;
482 *last_valid_ml = *ml;
483 if (first_valid_ml ==
NULL) {
484 first_valid_ml = last_valid_ml;
491 last_valid_ml->
e = newe[ml->
e];
494 if (last_valid_ml !=
NULL) {
495 need_edge_from_last_valid_ml =
true;
498 need_edge_to_first_valid_ml =
true;
503 (need_edge_to_first_valid_ml || need_edge_from_last_valid_ml))) {
507 uint v1 = (vtargetmap[last_valid_ml->v] != -1) ? vtargetmap[last_valid_ml->v] :
509 uint v2 = (vtargetmap[first_valid_ml->v] != -1) ? vtargetmap[first_valid_ml->v] :
519 medge[new_eidx].
v1 = last_valid_ml->v;
520 medge[new_eidx].
v2 = first_valid_ml->v;
526 last_valid_ml->e = new_eidx;
528 need_edge_to_first_valid_ml = need_edge_from_last_valid_ml =
false;
538 if (created_edges > 0) {
570 for (i = 0; i <
result->totedge; i++, med++) {
572 med->v1 = newv[med->v1];
574 med->v2 = newv[med->v2];
584 for (i = 0; i <
result->totloop; i++, ml++) {
594 for (i = 0; i <
result->totvert; i++,
mv++) {
600 for (i = 0; i <
result->totpoly; i++, mp++) {
638 if (poly_map !=
NULL) {
641 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)
@ MESH_MERGE_VERTS_DUMP_IF_EQUAL
@ MESH_MERGE_VERTS_DUMP_IF_MAPPED
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)
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)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_DISABLE(_bitmap, _index)
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP free_value)
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)
EdgeHash * BLI_edgehash_new_ex(const char *info, unsigned int nentries_reserve)
void BLI_gset_flag_set(GSet *gs, unsigned int flag)
bool BLI_gset_haskey(const GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT
GSet * BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_gset_insert(GSet *gs, void *key)
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_SIZE(stack)
#define STACK_PUSH_RET_PTR(stack)
#define STACK_INIT(stack, stack_num)
_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 uint poly_gset_hash_fn(const void *key)
static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpoly_target, const int *vtargetmap, const int direct_reverse)