163 const bool skip_em_vert_array_init)
168 const bool is_editmode = (em !=
nullptr);
175 int totvert, totedge;
176 int tot_unique = -1, tot_unique_prev = -1;
177 int tot_unique_edges = 0, tot_unique_edges_prev;
192 totvert = mesh->verts_num;
209 totedge = mesh->edges_num;
211 topo_hash[edge[0]]++;
212 topo_hash[edge[1]]++;
218 tot_unique_prev = -1;
219 tot_unique_edges_prev = -1;
223 tot_unique_edges = 0;
229 topo_hash[i1] += topo_hash_prev[i2] * topo_pass;
230 topo_hash[i2] += topo_hash_prev[i1] * topo_pass;
231 tot_unique_edges += (topo_hash[i1] != topo_hash[i2]);
236 const int i1 = edge[0], i2 = edge[1];
237 topo_hash[i1] += topo_hash_prev[i2] * topo_pass;
238 topo_hash[i2] += topo_hash_prev[i1] * topo_pass;
239 tot_unique_edges += (topo_hash[i1] != topo_hash[i2]);
242 memcpy(topo_hash_prev, topo_hash,
sizeof(
MirrTopoHash_t) * totvert);
248 for (a = 1; a < totvert; a++) {
249 if (topo_hash_prev[a - 1] != topo_hash_prev[a]) {
254 if ((tot_unique <= tot_unique_prev) && (tot_unique_edges <= tot_unique_edges_prev)) {
259 tot_unique_prev = tot_unique;
260 tot_unique_edges_prev = tot_unique_edges;
262 memcpy(topo_hash_prev, topo_hash,
sizeof(
MirrTopoHash_t) * totvert);
273 MEM_mallocN(totvert *
sizeof(*index_lookup),
"mesh_topo_lookup"));
276 if (skip_em_vert_array_init ==
false) {
281 for (a = 0; a < totvert; a++) {
282 topo_pairs[a].
hash = topo_hash[a];
286 index_lookup[a] = -1;
298 for (a = 1; a <= totvert; a++) {
301 if ((a == totvert) || (topo_pairs[a - 1].
hash != topo_pairs[a].
hash)) {
302 const int match_count = a - last;
303 if (match_count == 2) {
304 const int j = topo_pairs[a - 1].
v_index, k = topo_pairs[a - 2].
v_index;
305 index_lookup[j] =
intptr_t(vtable[k]);
306 index_lookup[k] =
intptr_t(vtable[j]);
308 else if (match_count == 1) {
310 const int j = topo_pairs[a - 1].
v_index;
311 index_lookup[j] =
intptr_t(vtable[j]);
319 for (a = 1; a <= totvert; a++) {
320 if ((a == totvert) || (topo_pairs[a - 1].
hash != topo_pairs[a].
hash)) {
321 const int match_count = a - last;
322 if (match_count == 2) {
323 const int j = topo_pairs[a - 1].
v_index, k = topo_pairs[a - 2].
v_index;
327 else if (match_count == 1) {
329 const int j = topo_pairs[a - 1].
v_index;
338 topo_pairs =
nullptr;