Smarter translucency sorting #42
+7
-7
@@ -242,12 +242,12 @@ public final class TranslucentSorter {
|
||||
int[] out = new int[n];
|
||||
int finished = 0;
|
||||
|
||||
for (int root = 0; root < n; root++) {
|
||||
for (int root = n - 1; root >= 0; root--) {
|
||||
if (state[root] != 0) continue;
|
||||
|
||||
int depth = 0;
|
||||
stack[0] = root;
|
||||
next[0] = 0;
|
||||
next[0] = n - 1;
|
||||
state[root] = 1;
|
||||
|
||||
while (depth >= 0) {
|
||||
@@ -255,12 +255,12 @@ public final class TranslucentSorter {
|
||||
int candidate = next[depth];
|
||||
|
||||
// advance to the next quad that must be drawn after the current one
|
||||
while (candidate < n && (state[candidate] == 2 || candidate == current
|
||||
while (candidate >= 0 && (state[candidate] == 2 || candidate == current
|
||||
|| !quads.isSeenThrough(group[current], group[candidate]))) {
|
||||
candidate++;
|
||||
candidate--;
|
||||
}
|
||||
|
||||
if (candidate == n) {
|
||||
if (candidate < 0) {
|
||||
state[current] = 2;
|
||||
out[n - 1 - finished++] = group[current]; // reverse postorder: predecessors first
|
||||
depth--;
|
||||
@@ -271,10 +271,10 @@ public final class TranslucentSorter {
|
||||
return null; // back edge: a cycle
|
||||
}
|
||||
|
||||
next[depth] = candidate + 1;
|
||||
next[depth] = candidate - 1;
|
||||
depth++;
|
||||
stack[depth] = candidate;
|
||||
next[depth] = 0;
|
||||
next[depth] = n - 1;
|
||||
state[candidate] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user