scaffolder output

This commit is contained in:
Leijurv
2023-03-07 00:52:39 -08:00
parent 1ffadf0242
commit 19eda1bfe5
3 changed files with 33 additions and 33 deletions

View File

@@ -337,7 +337,7 @@ public class DependencyGraphScaffoldingOverlay {
if (!Main.STRICT_Y || positions.isEmpty()) {
throw new IllegalStateException();
}
if (y == -1) {
if (y == -1) { // TODO won't work in 1.17+ lol
y = BetterBlockPos.YfromLong(positions.iterator().nextLong());
if (y == -1) {
throw new IllegalStateException();
@@ -376,7 +376,7 @@ public class DependencyGraphScaffoldingOverlay {
if (component.positions.isEmpty()) {
throw new IllegalStateException();
}
int y = Main.STRICT_Y ? component.y() : -1;
Integer y = Main.STRICT_Y ? component.y() : null;
for (CollapsedDependencyGraphComponent out : component.outgoingEdges) {
if (Main.STRICT_Y && out.y() < y) {
throw new IllegalStateException();

View File

@@ -55,12 +55,12 @@ public class Scaffolder {
this.rootComponents = calcRoots();
}
public static Scaffolder run(PlaceOrderDependencyGraph graph, IScaffolderStrategy strategy) {
public static Output run(PlaceOrderDependencyGraph graph, IScaffolderStrategy strategy) {
Scaffolder scaffolder = new Scaffolder(graph, strategy);
while (scaffolder.rootComponents.size() > 1) {
scaffolder.loop();
}
return scaffolder;
return scaffolder.new Output();
}
private List<CollapsedDependencyGraphComponent> calcRoots() {
@@ -121,39 +121,39 @@ public class Scaffolder {
}
}
public void enableAncillaryScaffoldingAndRecomputeRoot(LongList positions) {
System.out.println("TODO: should ancillary scaffolding even recompute the components? that scaffolding doesn't NEED to part of any component, and having all components be mutable even after the scaffolder is done is sketchy");
getRoot();
enable(positions);
getRoot();
}
public CollapsedDependencyGraphComponent getRoot() { // TODO this should probably return a new class that is not mutable in-place
if (rootComponents.size() != 1) {
throw new IllegalStateException(); // this is okay because this can only possibly be called after Scaffolder.run is completed
public class Output {
public void enableAncillaryScaffoldingAndRecomputeRoot(LongList positions) {
getRoot();
enable(positions);
getRoot();
throw new UnsupportedOperationException("TODO: should ancillary scaffolding even recompute the components? that scaffolding doesn't NEED to part of any component, and having all components be mutable even after the scaffolder is done is sketchy");
}
CollapsedDependencyGraphComponent root = rootComponents.get(0);
if (!root.getIncoming().isEmpty() || root.deleted()) {
throw new IllegalStateException();
public CollapsedDependencyGraphComponent getRoot() { // TODO this should probably return a new class that is not mutable in-place
if (rootComponents.size() != 1) {
throw new IllegalStateException(); // this is okay because this can only possibly be called after Scaffolder.run is completed
}
CollapsedDependencyGraphComponent root = rootComponents.get(0);
if (!root.getIncoming().isEmpty() || root.deleted()) {
throw new IllegalStateException();
}
return root;
}
return root;
}
public boolean real(long pos) {
return overlayGraph.real(pos);
}
// TODO should Scaffolder return a different class? "CompletedScaffolding" or something that has these methods as non-delegate, as well as getRoot returning a immutable equivalent of CollapsedDependencyGraphComponent?
public boolean real(long pos) {
return overlayGraph.real(pos);
}
public void forEachReal(Bounds.BoundsLongConsumer consumer) {
overlayGraph.forEachReal(consumer);
}
public void forEachReal(Bounds.BoundsLongConsumer consumer) {
overlayGraph.forEachReal(consumer);
}
public LongSets.UnmodifiableSet scaffolding() {
return overlayGraph.scaffolding();
}
public LongSets.UnmodifiableSet scaffolding() {
return overlayGraph.scaffolding();
}
public boolean air(long pos) {
return overlayGraph.air(pos);
public boolean air(long pos) {
return overlayGraph.air(pos);
}
}
}

View File

@@ -33,7 +33,7 @@ public class SolverEngineHarness {
private final ISolverEngine engine;
private final PackedBlockStateCuboid blocks;
private final PlaceOrderDependencyGraph graph;
private final Scaffolder scaffolder;
private final Scaffolder.Output scaffolder;
public SolverEngineHarness(ISolverEngine engine, PackedBlockStateCuboid blocks, IScaffolderStrategy scaffolderStrategy) {
this.engine = engine;