Time procedural bakes in the studio with a median-of-five meter

Authors could not see what a procedural object costs generation. The Procedural view now bakes the chosen entry five times in the background, keeps the median run, and rates it Light, Moderate or Heavy against a server tick, with each stage's time in the tooltip. SceneView gains isBaked and timeBake (one run, a BakeRun); the studio asks five times so a newer choice stops the rest. No pins moved: generation bakes with BakeProfile.NONE and nothing in packs changed.

v3: 9e30508e3 7d240ddf8
This commit is contained in:
piexel committed 2026-11-10 11:22:51 +01:00
1 parent f3bf0aea4b
commit 76dcab175b
14 files changed
+448 -6

No files matched your search

@@ -53,6 +53,7 @@ import com.volmit.object.GeneratedObject;
import com.volmit.tooling.BlockPattern;
import com.volmit.tooling.PatternArea;
import com.volmit.tooling.PatternEntry;
import com.volmit.tooling.BakeRun;
import com.volmit.tooling.SceneEntry;
import java.io.IOException;
@@ -235,6 +236,7 @@ public final class StudioBridge implements AutoCloseable {
case "scene-edit" -> sendJson(exchange, STATUS_OK, sceneEdit(exchange, query));
case "scene-write" -> sendJson(exchange, STATUS_OK, sceneWrite(exchange, query));
case "scene-entries" -> sendJson(exchange, STATUS_OK, sceneEntries(get(exchange).engine(), query));
case "scene-bake" -> sendJson(exchange, STATUS_OK, sceneBake(get(exchange).engine(), query));
case "scene" -> sendBytes(exchange, "application/octet-stream", scene(get(exchange).engine(), query));
case "saved-worlds" -> sendJson(exchange, STATUS_OK, savedWorlds(exchange));
case "saved-start" -> sendJson(exchange, STATUS_OK, savedStart(exchange, query));
@@ -335,8 +337,9 @@ public final class StudioBridge implements AutoCloseable {
private static List<SceneViewInfo> sceneViews(Engine engine) {
StudioEditors editors = StudioEditors.of(engine);
return StudioScenes.of(engine).views().stream()
.map(view -> new SceneViewInfo(view.id(), view.label(), view.description(), editors.edits(view.id())))
StudioScenes scenes = StudioScenes.of(engine);
return scenes.views().stream()
.map(view -> new SceneViewInfo(view.id(), view.label(), view.description(), editors.edits(view.id()), scenes.isBaked(view.id())))
.toList();
}
@@ -398,6 +401,16 @@ public final class StudioBridge implements AutoCloseable {
}
}
private static BakeRun sceneBake(Engine engine, Query query) {
String key = query.text("key");
try {
return StudioScenes.of(engine).timeBake(query.text("view"), key)
.orElseThrow(() -> new RequestError(STATUS_NOT_FOUND, "No bake to time for " + key));
} catch (NoSuchElementException unknown) {
throw new RequestError(STATUS_NOT_FOUND, unknown.getMessage());
}
}
private byte[] scene(Engine engine, Query query) {
String key = query.text("key");
Optional<GeneratedObject> scene;
@@ -738,8 +751,8 @@ public final class StudioBridge implements AutoCloseable {
private record ErrorBody(String error) {
}
/** A scene view as the studio lists it; {@code editable} when its entries can be edited as nodes. */
private record SceneViewInfo(String id, String label, String description, boolean editable) {
/** A scene view as the studio lists it; {@code editable} when its entries can be edited as nodes, {@code baked} when their bake can be timed. */
private record SceneViewInfo(String id, String label, String description, boolean editable, boolean baked) {
}
/** A {@link SceneEntry} as the studio reads it, with a blank group for none. */
@@ -20,6 +20,7 @@ package art.arcane.iris.core.studio.scene;
import art.arcane.iris.engine.framework.Engine;
import com.volmit.object.GeneratedObject;
import com.volmit.tooling.BakeRun;
import com.volmit.tooling.SceneEntry;
import com.volmit.tooling.SceneView;
@@ -56,4 +57,18 @@ public final class StudioScenes {
public Optional<GeneratedObject> scene(String viewId, String key, int variant) {
return views.ask(viewId, "build " + key, view -> view.scene(views.world(), key, variant));
}
/** @throws NoSuchElementException when no module registered a scene view {@code viewId} */
public boolean isBaked(String viewId) {
return views.ask(viewId, "say whether it bakes", SceneView::isBaked);
}
/**
* One timed bake of an entry; empty when the view has no such entry or does not bake.
*
* @throws NoSuchElementException when no module registered a scene view {@code viewId}
*/
public Optional<BakeRun> timeBake(String viewId, String key) {
return views.ask(viewId, "time the bake of " + key, view -> view.timeBake(views.world(), key));
}
}