Skip to content

Instantly share code, notes, and snippets.

@Lucent
Last active August 21, 2018 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lucent/2663406 to your computer and use it in GitHub Desktop.
Save Lucent/2663406 to your computer and use it in GitHub Desktop.
Create lists of nonoverlapping plane datablocks
function move_overlaps_higher(overlaps) {
cycle_list[0] = overlaps;
var another_row_needed = true;
for (var cyclerow = 0; another_row_needed; cyclerow++) {
another_row_needed = false;
var this_row = cycle_list[cyclerow];
for (var ident = 0; ident < this_row.length; ident++) {
for (var x = ident - 1; x >= 0; x--) {
if (x < 0) continue;
if (in_array(this_row[ident], covers_pairs[this_row[x]]) || in_array(this_row[ident], covered_pairs[this_row[x]])) {
if (cycle_list.length === cyclerow + 1) cycle_list[cyclerow + 1] = [];
cycle_list[cyclerow + 1].push(this_row[ident]);
this_row.splice(ident, 1);
ident--;
another_row_needed = true;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment