diff --git a/src/main/java/com/jozufozu/flywheel/api/visual/DynamicVisual.java b/src/main/java/com/jozufozu/flywheel/api/visual/DynamicVisual.java index d246974fc..f128ada4e 100644 --- a/src/main/java/com/jozufozu/flywheel/api/visual/DynamicVisual.java +++ b/src/main/java/com/jozufozu/flywheel/api/visual/DynamicVisual.java @@ -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. - *

- * 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 planFrame(); + Plan planFrame(); + + /** + * The context passed to the frame plan. + */ + @ApiStatus.NonExtendable + interface Context { + Camera camera(); + + FrustumIntersection frustum(); + + float partialTick(); + + DistanceUpdateLimiter limiter(); + } } diff --git a/src/main/java/com/jozufozu/flywheel/api/visual/TickableVisual.java b/src/main/java/com/jozufozu/flywheel/api/visual/TickableVisual.java index e9e3c0087..8d25ef0a8 100644 --- a/src/main/java/com/jozufozu/flywheel/api/visual/TickableVisual.java +++ b/src/main/java/com/jozufozu/flywheel/api/visual/TickableVisual.java @@ -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. - *
There are a few cases in which this should be considered over {@link DynamicVisual}: - *

+ * the end of every tick. */ public interface TickableVisual extends Visual { - Plan planTick(); + Plan planTick(); + + /** + * The context passed to the tick plan. + *

Currently this has no methods, it is reserved here for future use.

+ */ + @ApiStatus.NonExtendable + interface Context { + } } diff --git a/src/main/java/com/jozufozu/flywheel/api/visual/VisualFrameContext.java b/src/main/java/com/jozufozu/flywheel/api/visual/VisualFrameContext.java deleted file mode 100644 index 84e5dff56..000000000 --- a/src/main/java/com/jozufozu/flywheel/api/visual/VisualFrameContext.java +++ /dev/null @@ -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(); -} diff --git a/src/main/java/com/jozufozu/flywheel/api/visual/VisualTickContext.java b/src/main/java/com/jozufozu/flywheel/api/visual/VisualTickContext.java deleted file mode 100644 index b74294d23..000000000 --- a/src/main/java/com/jozufozu/flywheel/api/visual/VisualTickContext.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.jozufozu.flywheel.api.visual; - -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.NonExtendable -public interface VisualTickContext { - // TODO: remove? -} diff --git a/src/main/java/com/jozufozu/flywheel/impl/visual/DynamicVisualContextImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visual/DynamicVisualContextImpl.java new file mode 100644 index 000000000..6b729d94c --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/impl/visual/DynamicVisualContextImpl.java @@ -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 { +} diff --git a/src/main/java/com/jozufozu/flywheel/impl/visual/TickableVisualContextImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visual/TickableVisualContextImpl.java new file mode 100644 index 000000000..c613d37ff --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/impl/visual/TickableVisualContextImpl.java @@ -0,0 +1,7 @@ +package com.jozufozu.flywheel.impl.visual; + +import com.jozufozu.flywheel.api.visual.TickableVisual; + +public enum TickableVisualContextImpl implements TickableVisual.Context { + INSTANCE +} diff --git a/src/main/java/com/jozufozu/flywheel/impl/visual/VisualFrameContextImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visual/VisualFrameContextImpl.java deleted file mode 100644 index f794c119a..000000000 --- a/src/main/java/com/jozufozu/flywheel/impl/visual/VisualFrameContextImpl.java +++ /dev/null @@ -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 { -} diff --git a/src/main/java/com/jozufozu/flywheel/impl/visual/VisualTickContextImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visual/VisualTickContextImpl.java deleted file mode 100644 index e17eb7bc0..000000000 --- a/src/main/java/com/jozufozu/flywheel/impl/visual/VisualTickContextImpl.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.jozufozu.flywheel.impl.visual; - -import com.jozufozu.flywheel.api.visual.VisualTickContext; - -public record VisualTickContextImpl() implements VisualTickContext { -} diff --git a/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java index a53e0ff37..84d4e6bd9 100644 --- a/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java +++ b/src/main/java/com/jozufozu/flywheel/impl/visualization/VisualizationManagerImpl.java @@ -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 entities; private final VisualManagerImpl effects; - private final Plan tickPlan; + private final Plan tickPlan; private final Plan 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); } /** diff --git a/src/main/java/com/jozufozu/flywheel/impl/visualization/manager/VisualManagerImpl.java b/src/main/java/com/jozufozu/flywheel/impl/visualization/manager/VisualManagerImpl.java index 0c9a2fcd5..2bbf64382 100644 --- a/src/main/java/com/jozufozu/flywheel/impl/visualization/manager/VisualManagerImpl.java +++ b/src/main/java/com/jozufozu/flywheel/impl/visualization/manager/VisualManagerImpl.java @@ -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> implements VisualManager } } - public Plan framePlan() { - return SimplePlan.of(context -> processQueue(context.partialTick())) + public Plan framePlan() { + return SimplePlan.of(context -> processQueue(context.partialTick())) .then(storage.framePlan()); } - public Plan tickPlan() { - return SimplePlan.of(context -> processQueue(1)) + public Plan tickPlan() { + return SimplePlan.of(context -> processQueue(1)) .then(storage.tickPlan()); } } diff --git a/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/LitVisualStorage.java b/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/LitVisualStorage.java index 3c9649e2a..b61c38d4a 100644 --- a/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/LitVisualStorage.java +++ b/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/LitVisualStorage.java @@ -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 plan() { - return (SimplyComposedPlan) (TaskExecutor taskExecutor, VisualFrameContext context, Runnable onCompletion) -> { + public Plan plan() { + return (SimplyComposedPlan) (TaskExecutor taskExecutor, DynamicVisual.Context context, Runnable onCompletion) -> { processMoved(); if (sectionsUpdatedThisFrame.isEmpty()) { diff --git a/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/Storage.java b/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/Storage.java index a3da7fd51..266ed7c71 100644 --- a/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/Storage.java +++ b/src/main/java/com/jozufozu/flywheel/impl/visualization/storage/Storage.java @@ -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 { protected final Supplier visualizationContextSupplier; - protected final PlanMap dynamicVisuals = new PlanMap<>(); - protected final PlanMap tickableVisuals = new PlanMap<>(); + protected final PlanMap dynamicVisuals = new PlanMap<>(); + protected final PlanMap tickableVisuals = new PlanMap<>(); protected final List simpleDynamicVisuals = new ArrayList<>(); protected final List simpleTickableVisuals = new ArrayList<>(); protected final LitVisualStorage litVisuals = new LitVisualStorage(); @@ -127,11 +125,11 @@ public abstract class Storage { @Nullable protected abstract Visual createRaw(T obj); - public Plan framePlan() { + public Plan framePlan() { return NestedPlan.of(dynamicVisuals, litVisuals.plan(), ForEachPlan.of(() -> simpleDynamicVisuals, SimpleDynamicVisual::beginFrame)); } - public Plan tickPlan() { + public Plan tickPlan() { return NestedPlan.of(tickableVisuals, ForEachPlan.of(() -> simpleTickableVisuals, SimpleTickableVisual::tick)); } diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/AbstractBlockEntityVisual.java b/src/main/java/com/jozufozu/flywheel/lib/visual/AbstractBlockEntityVisual.java index fcde2a34d..d314da066 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/AbstractBlockEntityVisual.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/AbstractBlockEntityVisual.java @@ -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 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())); } diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/EntityComponent.java b/src/main/java/com/jozufozu/flywheel/lib/visual/EntityComponent.java index d47ca3145..be229ce4e 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/EntityComponent.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/EntityComponent.java @@ -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(); } diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleDynamicVisual.java b/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleDynamicVisual.java index 36c2436ee..9e3220c44 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleDynamicVisual.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleDynamicVisual.java @@ -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 { *
* {@link Instancer}/{@link Instance} creation/acquisition is safe here. */ - void beginFrame(VisualFrameContext ctx); + void beginFrame(Context ctx); @Override - default Plan planFrame() { + default Plan planFrame() { return RunnablePlan.of(this::beginFrame); } } diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleEntityVisual.java b/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleEntityVisual.java index 9654e2adc..e75d3702a 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleEntityVisual.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/SimpleEntityVisual.java @@ -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 extends AbstractEntityVisual * {@link Instancer}/{@link Instance} creation/acquisition is safe here. */ - void tick(VisualTickContext ctx); + void tick(); @Override - default Plan planTick() { + default Plan planTick() { return RunnablePlan.of(this::tick); } } diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/components/FireComponent.java b/src/main/java/com/jozufozu/flywheel/lib/visual/components/FireComponent.java index be919e41f..70af3ae2e 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/components/FireComponent.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/components/FireComponent.java @@ -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()); diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/components/HitboxComponent.java b/src/main/java/com/jozufozu/flywheel/lib/visual/components/HitboxComponent.java index 4503002f9..bdcdb23c4 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/components/HitboxComponent.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/components/HitboxComponent.java @@ -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() diff --git a/src/main/java/com/jozufozu/flywheel/lib/visual/components/ShadowComponent.java b/src/main/java/com/jozufozu/flywheel/lib/visual/components/ShadowComponent.java index 486fb5794..8c735bc7c 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/visual/components/ShadowComponent.java +++ b/src/main/java/com/jozufozu/flywheel/lib/visual/components/ShadowComponent.java @@ -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()); diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java index 29e21cda3..5c0f1ce80 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java @@ -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 imple } @Override - public void beginFrame(VisualFrameContext context) { + public void beginFrame(Context context) { if (doDistanceLimitThisFrame(context) || !isVisible(context.frustum())) { return; } diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java index 6fdf12a83..f03b19ae9 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java @@ -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 extends Abstrac } @Override - public void beginFrame(VisualFrameContext context) { + public void beginFrame(Context context) { if (doDistanceLimitThisFrame(context) || !isVisible(context.frustum())) { return; } diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java index 8c7f8d8a5..a31f82da0 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java @@ -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 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 extends SimpleEntityVisu } @Override - public void beginFrame(VisualFrameContext context) { + public void beginFrame(DynamicVisual.Context context) { super.beginFrame(context); if (!isVisible(context.frustum())) { diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java index 8f205bc26..12eda7ca7 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java @@ -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 planTick() { - Plan beginTick = ForEachPlan.of(() -> boids, Boid::beginTick); + public Plan planTick() { + Plan beginTick = ForEachPlan.of(() -> boids, Boid::beginTick); return beginTick.then(ForEachPlan.of(() -> effects, boid -> boid.self.tick(boids))); } @Override - public Plan planFrame() { + public Plan 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); diff --git a/src/main/resources/assets/flywheel/flywheel/internal/api_impl.vert b/src/main/resources/assets/flywheel/flywheel/internal/api_impl.vert index 18128f125..d9934d42e 100644 --- a/src/main/resources/assets/flywheel/flywheel/internal/api_impl.vert +++ b/src/main/resources/assets/flywheel/flywheel/internal/api_impl.vert @@ -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;