Smarter translucency sorting #42
No files matched your search
+5
@@ -86,6 +86,11 @@ public final class PartitionTree implements SortState.Resortable {
|
||||
if (planes.length > 0) break;
|
||||
}
|
||||
if (planes.length == 0) {
|
||||
// no free cut does not imply a cycle: a camera-independent order may still exist
|
||||
int[] topological = group.length <= TranslucentSorter.MAX_TOPO_QUADS ? TranslucentSorter.topologicalOrder(quads, group) : null;
|
||||
if (topological != null) {
|
||||
return new Leaf(topological);
|
||||
}
|
||||
return partitionIntersectors(quads, group, collectedCuts);
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -225,7 +225,14 @@ public final class TranslucentSorter {
|
||||
|
||||
/** returns null if the relation has a cycle */
|
||||
public static int @Nullable [] topologicalOrder(QuadSet quads) {
|
||||
int n = quads.count();
|
||||
int[] all = new int[quads.count()];
|
||||
for (int i = 0; i < all.length; i++) all[i] = i;
|
||||
return topologicalOrder(quads, all);
|
||||
}
|
||||
|
||||
/** the group's quads in an order correct from every camera, or null if their visibility relation has a cycle */
|
||||
static int @Nullable [] topologicalOrder(QuadSet quads, int[] group) {
|
||||
int n = group.length;
|
||||
|
||||
IntArrayList[] successors = new IntArrayList[n];
|
||||
int[] predecessors = new int[n];
|
||||
@@ -233,7 +240,7 @@ public final class TranslucentSorter {
|
||||
// build the graph up
|
||||
for (int quadIdx = 0; quadIdx < n; quadIdx++) {
|
||||
for (int otherIdx = 0; otherIdx < n; otherIdx++) {
|
||||
if (quadIdx != otherIdx && quads.isSeenThrough(quadIdx, otherIdx)) {
|
||||
if (quadIdx != otherIdx && quads.isSeenThrough(group[quadIdx], group[otherIdx])) {
|
||||
if (successors[quadIdx] == null) {
|
||||
successors[quadIdx] = new IntArrayList();
|
||||
}
|
||||
@@ -258,7 +265,7 @@ public final class TranslucentSorter {
|
||||
|
||||
while (!ready.isEmpty()) {
|
||||
int current = ready.dequeueInt();
|
||||
out[o++] = current;
|
||||
out[o++] = group[current];
|
||||
|
||||
IntArrayList next = successors[current];
|
||||
if (next == null) continue;
|
||||
|
||||
Reference in new issue
Block a user