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;
210 topo_hash[edge[0]]++;
211 topo_hash[edge[1]]++;
217 tot_unique_prev = -1;
218 tot_unique_edges_prev = -1;
222 tot_unique_edges = 0;
228 topo_hash[i1] += topo_hash_prev[i2] * topo_pass;
229 topo_hash[i2] += topo_hash_prev[i1] * topo_pass;
230 tot_unique_edges += (topo_hash[i1] != topo_hash[i2]);
235 const int i1 = edge[0], i2 = edge[1];
236 topo_hash[i1] += topo_hash_prev[i2] * topo_pass;
237 topo_hash[i2] += topo_hash_prev[i1] * topo_pass;
238 tot_unique_edges += (topo_hash[i1] != topo_hash[i2]);
241 memcpy(topo_hash_prev, topo_hash,
sizeof(
MirrTopoHash_t) * totvert);
247 for (a = 1; a < totvert; a++) {
248 if (topo_hash_prev[a - 1] != topo_hash_prev[a]) {
253 if ((tot_unique <= tot_unique_prev) && (tot_unique_edges <= tot_unique_edges_prev)) {
258 tot_unique_prev = tot_unique;
259 tot_unique_edges_prev = tot_unique_edges;
261 memcpy(topo_hash_prev, topo_hash,
sizeof(
MirrTopoHash_t) * totvert);
270 intptr_t *index_lookup =
static_cast<intptr_t *
>(
271 MEM_mallocN(totvert *
sizeof(*index_lookup),
"mesh_topo_lookup"));
274 if (skip_em_vert_array_init ==
false) {
279 for (a = 0; a < totvert; a++) {
280 topo_pairs[a].
hash = topo_hash[a];
284 index_lookup[a] = -1;
296 for (a = 1; a <= totvert; a++) {
299 if ((a == totvert) || (topo_pairs[a - 1].
hash != topo_pairs[a].
hash)) {
300 const int match_count = a - last;
301 if (match_count == 2) {
302 const int j = topo_pairs[a - 1].
v_index, k = topo_pairs[a - 2].
v_index;
303 index_lookup[j] = intptr_t(vtable[k]);
304 index_lookup[k] = intptr_t(vtable[j]);
306 else if (match_count == 1) {
308 const int j = topo_pairs[a - 1].
v_index;
309 index_lookup[j] = intptr_t(vtable[j]);
317 for (a = 1; a <= totvert; a++) {
318 if ((a == totvert) || (topo_pairs[a - 1].
hash != topo_pairs[a].
hash)) {
319 const int match_count = a - last;
320 if (match_count == 2) {
321 const int j = topo_pairs[a - 1].
v_index, k = topo_pairs[a - 2].
v_index;
325 else if (match_count == 1) {
327 const int j = topo_pairs[a - 1].
v_index;
336 topo_pairs =
nullptr;