This context intentionally left blank

- Move Visual*Contexts inside their respective *Visual interfaces
- Acknowledge that TickableVisual.Context has no methods
- api_impl.vert: no need to try to pack in/out variables
This commit is contained in:
Jozufozu 2024-04-03 21:23:12 -07:00
parent 833fadbbdc
commit 09cb15e2ed
26 changed files with 98 additions and 123 deletions

View file

@ -1,16 +1,32 @@
package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
import org.joml.FrustumIntersection;
import com.jozufozu.flywheel.api.task.Plan;
import net.minecraft.client.Camera;
/**
* An interface giving {@link Visual}s a hook to have a function called at
* the start of a frame. By implementing {@link DynamicVisual}, an {@link Visual}
* can animate its models in ways that could not be easily achieved by shader attribute
* parameterization.
* <p>
* If your goal is offloading work to shaders, but you're unsure exactly how you need
* to parameterize the instances, you're encouraged to implement this for prototyping.
*/
public interface DynamicVisual extends Visual {
Plan<VisualFrameContext> planFrame();
Plan<Context> planFrame();
/**
* The context passed to the frame plan.
*/
@ApiStatus.NonExtendable
interface Context {
Camera camera();
FrustumIntersection frustum();
float partialTick();
DistanceUpdateLimiter limiter();
}
}

View file

@ -1,23 +1,21 @@
package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
import com.jozufozu.flywheel.api.task.Plan;
/**
* An interface giving {@link Visual}s a hook to have a function called at
* the end of every tick. By implementing {@link TickableVisual}, an {@link Visual}
* can update frequently, but not every frame.
* <br> There are a few cases in which this should be considered over {@link DynamicVisual}:
* <ul>
* <li>
* You'd like to change something about the visual every now and then.
* eg. adding or removing instances, snapping to a different rotation, etc.
* </li>
* <li>
* Your BlockEntity does animate, but the animation doesn't have
* to be smooth, in which case this could be an optimization.
* </li>
* </ul>
* the end of every tick.
*/
public interface TickableVisual extends Visual {
Plan<VisualTickContext> planTick();
Plan<Context> planTick();
/**
* The context passed to the tick plan.
* <p>Currently this has no methods, it is reserved here for future use.</p>
*/
@ApiStatus.NonExtendable
interface Context {
}
}

View file

@ -1,17 +0,0 @@
package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
import org.joml.FrustumIntersection;
import net.minecraft.client.Camera;
@ApiStatus.NonExtendable
public interface VisualFrameContext {
Camera camera();
FrustumIntersection frustum();
float partialTick();
DistanceUpdateLimiter limiter();
}

View file

@ -1,8 +0,0 @@
package com.jozufozu.flywheel.api.visual;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.NonExtendable
public interface VisualTickContext {
// TODO: remove?
}

View file

@ -0,0 +1,12 @@
package com.jozufozu.flywheel.impl.visual;
import org.joml.FrustumIntersection;
import com.jozufozu.flywheel.api.visual.DistanceUpdateLimiter;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import net.minecraft.client.Camera;
public record DynamicVisualContextImpl(Camera camera, FrustumIntersection frustum, float partialTick,
DistanceUpdateLimiter limiter) implements DynamicVisual.Context {
}

View file

@ -0,0 +1,7 @@
package com.jozufozu.flywheel.impl.visual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
public enum TickableVisualContextImpl implements TickableVisual.Context {
INSTANCE
}

View file

@ -1,12 +0,0 @@
package com.jozufozu.flywheel.impl.visual;
import org.joml.FrustumIntersection;
import com.jozufozu.flywheel.api.visual.DistanceUpdateLimiter;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import net.minecraft.client.Camera;
public record VisualFrameContextImpl(Camera camera, FrustumIntersection frustum,
float partialTick, DistanceUpdateLimiter limiter) implements VisualFrameContext {
}

View file

@ -1,6 +0,0 @@
package com.jozufozu.flywheel.impl.visual;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
public record VisualTickContextImpl() implements VisualTickContext {
}

View file

@ -20,8 +20,6 @@ import com.jozufozu.flywheel.api.task.TaskExecutor;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.Effect;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
import com.jozufozu.flywheel.api.visualization.VisualManager;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.api.visualization.VisualizationLevel;
@ -29,8 +27,8 @@ import com.jozufozu.flywheel.api.visualization.VisualizationManager;
import com.jozufozu.flywheel.config.FlwConfig;
import com.jozufozu.flywheel.impl.extension.LevelExtension;
import com.jozufozu.flywheel.impl.task.FlwTaskExecutor;
import com.jozufozu.flywheel.impl.visual.VisualFrameContextImpl;
import com.jozufozu.flywheel.impl.visual.VisualTickContextImpl;
import com.jozufozu.flywheel.impl.visual.DynamicVisualContextImpl;
import com.jozufozu.flywheel.impl.visual.TickableVisualContextImpl;
import com.jozufozu.flywheel.impl.visualization.manager.BlockEntityStorage;
import com.jozufozu.flywheel.impl.visualization.manager.EffectStorage;
import com.jozufozu.flywheel.impl.visualization.manager.EntityStorage;
@ -69,7 +67,7 @@ public class VisualizationManagerImpl implements VisualizationManager {
private final VisualManagerImpl<Entity, EntityStorage> entities;
private final VisualManagerImpl<Effect, EffectStorage> effects;
private final Plan<VisualTickContext> tickPlan;
private final Plan<TickableVisual.Context> tickPlan;
private final Plan<RenderContext> framePlan;
private final Flag tickFlag = new NamedFlag("tick");
@ -122,7 +120,7 @@ public class VisualizationManagerImpl implements VisualizationManager {
return () -> context;
}
private VisualFrameContext createVisualFrameContext(RenderContext ctx) {
private DynamicVisual.Context createVisualFrameContext(RenderContext ctx) {
Vec3i renderOrigin = engine.renderOrigin();
var cameraPos = ctx.camera()
.getPosition();
@ -131,7 +129,7 @@ public class VisualizationManagerImpl implements VisualizationManager {
viewProjection.translate((float) (renderOrigin.getX() - cameraPos.x), (float) (renderOrigin.getY() - cameraPos.y), (float) (renderOrigin.getZ() - cameraPos.z));
FrustumIntersection frustum = new FrustumIntersection(viewProjection);
return new VisualFrameContextImpl(ctx.camera(), frustum, ctx.partialTick(), frameLimiter);
return new DynamicVisualContextImpl(ctx.camera(), frustum, ctx.partialTick(), frameLimiter);
}
protected DistanceUpdateLimiterImpl createUpdateLimiter() {
@ -225,7 +223,7 @@ public class VisualizationManagerImpl implements VisualizationManager {
taskExecutor.syncUntil(tickFlag::isRaised);
tickFlag.lower();
tickPlan.execute(taskExecutor, new VisualTickContextImpl());
tickPlan.execute(taskExecutor, TickableVisualContextImpl.INSTANCE);
}
/**

View file

@ -4,8 +4,8 @@ import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import com.jozufozu.flywheel.api.task.Plan;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visualization.VisualManager;
import com.jozufozu.flywheel.impl.visualization.storage.Storage;
import com.jozufozu.flywheel.impl.visualization.storage.Transaction;
@ -64,13 +64,13 @@ public class VisualManagerImpl<T, S extends Storage<T>> implements VisualManager
}
}
public Plan<VisualFrameContext> framePlan() {
return SimplePlan.<VisualFrameContext>of(context -> processQueue(context.partialTick()))
public Plan<DynamicVisual.Context> framePlan() {
return SimplePlan.<DynamicVisual.Context>of(context -> processQueue(context.partialTick()))
.then(storage.framePlan());
}
public Plan<VisualTickContext> tickPlan() {
return SimplePlan.<VisualTickContext>of(context -> processQueue(1))
public Plan<TickableVisual.Context> tickPlan() {
return SimplePlan.<TickableVisual.Context>of(context -> processQueue(1))
.then(storage.tickPlan());
}
}

View file

@ -9,8 +9,8 @@ import java.util.concurrent.atomic.AtomicLong;
import com.jozufozu.flywheel.api.task.Plan;
import com.jozufozu.flywheel.api.task.TaskExecutor;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.LitVisual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.lib.task.Distribute;
import com.jozufozu.flywheel.lib.task.SimplyComposedPlan;
import com.jozufozu.flywheel.lib.task.Synchronizer;
@ -37,8 +37,8 @@ public class LitVisualStorage {
private long updateId = INITIAL_UPDATE_ID;
public Plan<VisualFrameContext> plan() {
return (SimplyComposedPlan<VisualFrameContext>) (TaskExecutor taskExecutor, VisualFrameContext context, Runnable onCompletion) -> {
public Plan<DynamicVisual.Context> plan() {
return (SimplyComposedPlan<DynamicVisual.Context>) (TaskExecutor taskExecutor, DynamicVisual.Context context, Runnable onCompletion) -> {
processMoved();
if (sectionsUpdatedThisFrame.isEmpty()) {

View file

@ -13,8 +13,6 @@ import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.LitVisual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visual.Visual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.task.ForEachPlan;
import com.jozufozu.flywheel.lib.task.NestedPlan;
@ -26,8 +24,8 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
public abstract class Storage<T> {
protected final Supplier<VisualizationContext> visualizationContextSupplier;
protected final PlanMap<DynamicVisual, VisualFrameContext> dynamicVisuals = new PlanMap<>();
protected final PlanMap<TickableVisual, VisualTickContext> tickableVisuals = new PlanMap<>();
protected final PlanMap<DynamicVisual, DynamicVisual.Context> dynamicVisuals = new PlanMap<>();
protected final PlanMap<TickableVisual, TickableVisual.Context> tickableVisuals = new PlanMap<>();
protected final List<SimpleDynamicVisual> simpleDynamicVisuals = new ArrayList<>();
protected final List<SimpleTickableVisual> simpleTickableVisuals = new ArrayList<>();
protected final LitVisualStorage litVisuals = new LitVisualStorage();
@ -127,11 +125,11 @@ public abstract class Storage<T> {
@Nullable
protected abstract Visual createRaw(T obj);
public Plan<VisualFrameContext> framePlan() {
public Plan<DynamicVisual.Context> framePlan() {
return NestedPlan.of(dynamicVisuals, litVisuals.plan(), ForEachPlan.of(() -> simpleDynamicVisuals, SimpleDynamicVisual::beginFrame));
}
public Plan<VisualTickContext> tickPlan() {
public Plan<TickableVisual.Context> tickPlan() {
return NestedPlan.of(tickableVisuals, ForEachPlan.of(() -> simpleTickableVisuals, SimpleTickableVisual::tick));
}

View file

@ -9,7 +9,6 @@ import com.jozufozu.flywheel.api.visual.BlockEntityVisual;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.LitVisual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visualization.VisualManager;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.math.MoreMath;
@ -98,7 +97,7 @@ public abstract class AbstractBlockEntityVisual<T extends BlockEntity> extends A
* @param context The current frame context.
* @return {@code true} if this visual shouldn't be updated this frame based on its distance from the camera.
*/
public boolean doDistanceLimitThisFrame(VisualFrameContext context) {
public boolean doDistanceLimitThisFrame(DynamicVisual.Context context) {
return !context.limiter()
.shouldUpdate(pos.distToCenterSqr(context.camera().getPosition()));
}

View file

@ -1,9 +1,9 @@
package com.jozufozu.flywheel.lib.visual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
public interface EntityComponent {
void beginFrame(VisualFrameContext context);
void beginFrame(DynamicVisual.Context context);
void delete();
}

View file

@ -5,7 +5,6 @@ import com.jozufozu.flywheel.api.instance.Instancer;
import com.jozufozu.flywheel.api.task.Plan;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.lib.task.RunnablePlan;
public interface SimpleDynamicVisual extends DynamicVisual {
@ -19,10 +18,10 @@ public interface SimpleDynamicVisual extends DynamicVisual {
* <br>
* {@link Instancer}/{@link Instance} creation/acquisition is safe here.
*/
void beginFrame(VisualFrameContext ctx);
void beginFrame(Context ctx);
@Override
default Plan<VisualFrameContext> planFrame() {
default Plan<Context> planFrame() {
return RunnablePlan.of(this::beginFrame);
}
}

View file

@ -3,7 +3,6 @@ package com.jozufozu.flywheel.lib.visual;
import java.util.ArrayList;
import java.util.List;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import net.minecraft.world.entity.Entity;
@ -20,7 +19,7 @@ public class SimpleEntityVisual<T extends Entity> extends AbstractEntityVisual<T
}
@Override
public void beginFrame(VisualFrameContext ctx) {
public void beginFrame(Context ctx) {
for (EntityComponent component : components) {
component.beginFrame(ctx);
}

View file

@ -5,7 +5,6 @@ import com.jozufozu.flywheel.api.instance.Instancer;
import com.jozufozu.flywheel.api.task.Plan;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
import com.jozufozu.flywheel.lib.task.RunnablePlan;
public interface SimpleTickableVisual extends TickableVisual {
@ -20,10 +19,10 @@ public interface SimpleTickableVisual extends TickableVisual {
* <br>
* {@link Instancer}/{@link Instance} creation/acquisition is safe here.
*/
void tick(VisualTickContext ctx);
void tick();
@Override
default Plan<VisualTickContext> planTick() {
default Plan<Context> planTick() {
return RunnablePlan.of(this::tick);
}
}

View file

@ -6,7 +6,7 @@ import org.joml.Vector4fc;
import com.jozufozu.flywheel.api.material.Material;
import com.jozufozu.flywheel.api.model.Model;
import com.jozufozu.flywheel.api.vertex.MutableVertexList;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.TransformedInstance;
@ -63,12 +63,12 @@ public class FireComponent implements EntityComponent {
/**
* Update the fire instances. You'd typically call this in your visual's
* {@link com.jozufozu.flywheel.api.visual.DynamicVisual#beginFrame(VisualFrameContext) beginFrame} method.
* {@link com.jozufozu.flywheel.api.visual.DynamicVisual#beginFrame(DynamicVisual.Context) beginFrame} method.
*
* @param context The frame context.
*/
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(DynamicVisual.Context context) {
recycler.resetCount();
if (entity.displayFireAnimation()) {
@ -78,7 +78,7 @@ public class FireComponent implements EntityComponent {
recycler.discardExtra();
}
private void setupInstances(VisualFrameContext context) {
private void setupInstances(DynamicVisual.Context context) {
double entityX = Mth.lerp(context.partialTick(), entity.xOld, entity.getX());
double entityY = Mth.lerp(context.partialTick(), entity.yOld, entity.getY());
double entityZ = Mth.lerp(context.partialTick(), entity.zOld, entity.getZ());

View file

@ -3,7 +3,7 @@ package com.jozufozu.flywheel.lib.visual.components;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.model.Model;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.TransformedInstance;
@ -81,7 +81,7 @@ public class HitboxComponent implements EntityComponent {
}
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(DynamicVisual.Context context) {
recycler.resetCount();
var shouldRenderHitBoxes = Minecraft.getInstance()

View file

@ -9,7 +9,7 @@ import com.jozufozu.flywheel.api.material.Transparency;
import com.jozufozu.flywheel.api.material.WriteMask;
import com.jozufozu.flywheel.api.model.Model;
import com.jozufozu.flywheel.api.vertex.MutableVertexList;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.ShadowInstance;
@ -108,12 +108,12 @@ public class ShadowComponent implements EntityComponent {
/**
* Update the shadow instances. You'd typically call this in your visual's
* {@link com.jozufozu.flywheel.api.visual.DynamicVisual#beginFrame(VisualFrameContext) beginFrame} method.
* {@link com.jozufozu.flywheel.api.visual.DynamicVisual#beginFrame(DynamicVisual.Context) beginFrame} method.
*
* @param context The frame context.
*/
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(DynamicVisual.Context context) {
instances.resetCount();
boolean shadowsEnabled = Minecraft.getInstance().options.entityShadows()
@ -125,7 +125,7 @@ public class ShadowComponent implements EntityComponent {
instances.discardExtra();
}
private void setupInstances(VisualFrameContext context) {
private void setupInstances(DynamicVisual.Context context) {
double entityX = Mth.lerp(context.partialTick(), entity.xOld, entity.getX());
double entityY = Mth.lerp(context.partialTick(), entity.yOld, entity.getY());
double entityZ = Mth.lerp(context.partialTick(), entity.zOld, entity.getZ());

View file

@ -7,7 +7,6 @@ import org.joml.Quaternionf;
import org.joml.Vector3f;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.OrientedInstance;
@ -54,7 +53,7 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
}
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(Context context) {
if (doDistanceLimitThisFrame(context) || !isVisible(context.frustum())) {
return;
}

View file

@ -8,7 +8,6 @@ import java.util.function.Consumer;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.OrientedInstance;
@ -117,7 +116,7 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
}
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(Context context) {
if (doDistanceLimitThisFrame(context) || !isVisible(context.frustum())) {
return;
}

View file

@ -2,8 +2,7 @@ package com.jozufozu.flywheel.vanilla;
import org.jetbrains.annotations.Nullable;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.TransformedInstance;
@ -100,7 +99,7 @@ public class MinecartVisual<T extends AbstractMinecart> extends SimpleEntityVisu
}
@Override
public void tick(VisualTickContext context) {
public void tick() {
BlockState displayBlockState = entity.getDisplayBlockState();
if (displayBlockState != blockState) {
@ -115,7 +114,7 @@ public class MinecartVisual<T extends AbstractMinecart> extends SimpleEntityVisu
}
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(DynamicVisual.Context context) {
super.beginFrame(context);
if (!isVisible(context.frustum())) {

View file

@ -5,7 +5,6 @@ import java.util.function.Consumer;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
import com.jozufozu.flywheel.lib.instance.TransformedInstance;
@ -95,7 +94,7 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual<ShulkerBoxBlockE
}
@Override
public void beginFrame(VisualFrameContext context) {
public void beginFrame(Context context) {
if (doDistanceLimitThisFrame(context) || !isVisible(context.frustum())) {
return;
}

View file

@ -11,8 +11,6 @@ import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.Effect;
import com.jozufozu.flywheel.api.visual.EffectVisual;
import com.jozufozu.flywheel.api.visual.TickableVisual;
import com.jozufozu.flywheel.api.visual.VisualFrameContext;
import com.jozufozu.flywheel.api.visual.VisualTickContext;
import com.jozufozu.flywheel.api.visualization.VisualizationContext;
import com.jozufozu.flywheel.api.visualization.VisualizationManager;
import com.jozufozu.flywheel.lib.instance.InstanceTypes;
@ -123,13 +121,13 @@ public class ExampleEffect implements Effect {
}
@Override
public Plan<VisualTickContext> planTick() {
Plan<VisualTickContext> beginTick = ForEachPlan.of(() -> boids, Boid::beginTick);
public Plan<TickableVisual.Context> planTick() {
Plan<TickableVisual.Context> beginTick = ForEachPlan.of(() -> boids, Boid::beginTick);
return beginTick.then(ForEachPlan.of(() -> effects, boid -> boid.self.tick(boids)));
}
@Override
public Plan<VisualFrameContext> planFrame() {
public Plan<DynamicVisual.Context> planFrame() {
return ForEachPlan.of(() -> effects, BoidVisual::beginFrame);
}
@ -279,7 +277,7 @@ public class ExampleEffect implements Effect {
instance.delete();
}
public void beginFrame(VisualFrameContext context) {
public void beginFrame(DynamicVisual.Context context) {
float partialTick = context.partialTick();
var x = Mth.lerp(partialTick, self.lastPosition.x, self.position.x);
var y = Mth.lerp(partialTick, self.lastPosition.y, self.position.y);

View file

@ -1,7 +1,6 @@
#include "flywheel:internal/material.glsl"
#include "flywheel:internal/uniforms/uniforms.glsl"
// TODO: can we combine some of these internally to use fewer in/out slots?
out vec4 flw_vertexPos;
out vec4 flw_vertexColor;
out vec2 flw_vertexTexCoord;