mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Baseline IrisApi draft before stage-graph redesign
This commit is contained in:
commit
9043d93fbd
91 files changed
+4045
No files matched your search
@@ -0,0 +1,52 @@
|
||||
package com.volmit.generation;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
/** Immutable ordering declarations referencing modifier IDs, not feature IDs.
|
||||
* Requirements must exist and finish first. Optional constraints apply only when present.
|
||||
* Nothing here activates a feature. The host resolves and validates the graph at pack load.
|
||||
*/
|
||||
public record Dependencies(Set<String> required, Set<String> after, Set<String> before) {
|
||||
public Dependencies {
|
||||
required = validatedCopy(required);
|
||||
after = validatedCopy(after);
|
||||
before = validatedCopy(before);
|
||||
}
|
||||
|
||||
public static Dependencies none() {
|
||||
return new Dependencies(Set.of(), Set.of(), Set.of());
|
||||
}
|
||||
|
||||
public static Dependencies requires(String... ids) {
|
||||
return none().andRequires(ids);
|
||||
}
|
||||
|
||||
/** Adds required predecessors without changing this declaration. */
|
||||
public Dependencies andRequires(String... ids) {
|
||||
return new Dependencies(adding(required, ids), after, before);
|
||||
}
|
||||
|
||||
public Dependencies afterIfPresent(String... ids) {
|
||||
return new Dependencies(required, adding(after, ids), before);
|
||||
}
|
||||
|
||||
public Dependencies beforeIfPresent(String... ids) {
|
||||
return new Dependencies(required, after, adding(before, ids));
|
||||
}
|
||||
|
||||
private static Set<String> adding(Set<String> existing, String[] ids) {
|
||||
var result = new HashSet<>(existing);
|
||||
for (String id : ids) result.add(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Set<String> validatedCopy(Set<String> ids) {
|
||||
var copy = Set.copyOf(ids);
|
||||
for (String id : copy) {
|
||||
ResourceId.parse(id);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.generation;
|
||||
|
||||
import com.volmit.mantle.Mantle;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
|
||||
/** Per-invocation state. Must not be retained by a modifier after execution. */
|
||||
public interface GenerationContext extends InvocationContext {
|
||||
/** World block coordinates corresponding to local volume coordinates (0, 0, 0). */
|
||||
int originX();
|
||||
int originY();
|
||||
int originZ();
|
||||
|
||||
TerrainSampler terrain();
|
||||
FeatureSettings settings();
|
||||
|
||||
/** Non-null mantle access scoped to this invocation; the host owns its lifetime. */
|
||||
Mantle mantle();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.volmit.generation;
|
||||
|
||||
import com.volmit.hunk.Hunk;
|
||||
|
||||
/** Bound to one configured feature instance.
|
||||
* Calls may occur concurrently for different volumes. Keep settings read-only and temporary
|
||||
* state local to modify(). Exceptions propagate: the host must not publish partial output.
|
||||
*/
|
||||
public abstract class GenerationModifier<T> {
|
||||
/** Stable, nonblank namespaced modifier identity, independent of feature identity.
|
||||
* Configured instances of the same modifier share this ID and dependency declaration.
|
||||
* Different modifier implementations must not claim the same ID.
|
||||
*/
|
||||
public abstract String id();
|
||||
|
||||
/** Stable requirements read at pack load, not per invocation. Constructors must not
|
||||
* depend on prerequisite modifiers having run. Ordering does not guarantee that
|
||||
* a prerequisite changed blocks at the current location.
|
||||
*/
|
||||
public Dependencies depends() {
|
||||
return Dependencies.none();
|
||||
}
|
||||
|
||||
/** Nonnegative horizontal reach in blocks beyond the output footprint; zero by default.
|
||||
* Read once per configured instance at pack load. The host must prepare this area and
|
||||
* required predecessor work before invocation, bound vertical access to the world, and
|
||||
* serialize overlapping writes. It must reject negative or unsupported reach, not clip it.
|
||||
*/
|
||||
public int mantleRadius() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract void modify(GenerationContext context, Hunk<T> output);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.generation;
|
||||
|
||||
import com.volmit.resource.PackResources;
|
||||
import java.util.random.RandomGenerator;
|
||||
|
||||
/** Host-owned invocation inputs. RNG and views must not be retained or used by detached tasks.
|
||||
* The host derives streams from world seed, stable feature/occurrence identity and position;
|
||||
* module discovery order must not affect them. Keeping legacy random behavior is adapter work.
|
||||
*/
|
||||
public interface InvocationContext {
|
||||
long worldSeed();
|
||||
PackResources resources();
|
||||
RandomGenerator random();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.volmit.generation;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
|
||||
/** Connects a feature's decoded options to its executable modifier. */
|
||||
@FunctionalInterface
|
||||
public interface ModifierFactory<F extends IrisFeature, T> {
|
||||
GenerationModifier<T> create(F feature);
|
||||
}
|
||||
Reference in new issue
Block a user