mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-14 00:06:12 +01:00
parent
53c732c3f6
commit
55a88a89bd
8 changed files with 29 additions and 54 deletions
|
@ -1,30 +0,0 @@
|
|||
package com.jozufozu.flywheel.api.backend;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.api.BackendImplemented;
|
||||
import com.jozufozu.flywheel.api.context.Context;
|
||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.instance.Instancer;
|
||||
import com.jozufozu.flywheel.api.instance.InstancerProvider;
|
||||
import com.jozufozu.flywheel.api.model.Model;
|
||||
|
||||
@BackendImplemented
|
||||
@ApiStatus.Experimental
|
||||
public interface DirectInstancerProvider {
|
||||
/**
|
||||
* Get an instancer for the given instance type, model, and render stage.
|
||||
*
|
||||
* <p>Calling this method twice with the same arguments will return the same instancer.</p>
|
||||
*
|
||||
* <p>If you are writing a visual you should probably be using
|
||||
* {@link InstancerProvider#instancer(InstanceType, Model)}, which will decide the {@code RenderStage}
|
||||
* based on what type of visual is getting the instancer as well as hide the Context.</p>
|
||||
*
|
||||
* @return An instancer for the given instance type, model, and render stage.
|
||||
* @see InstancerProvider
|
||||
*/
|
||||
<I extends Instance> Instancer<I> instancer(InstanceType<I> type, Context context, Model model, RenderStage stage);
|
||||
}
|
|
@ -3,9 +3,14 @@ package com.jozufozu.flywheel.api.backend;
|
|||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.api.BackendImplemented;
|
||||
import com.jozufozu.flywheel.api.context.Context;
|
||||
import com.jozufozu.flywheel.api.event.RenderContext;
|
||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
import com.jozufozu.flywheel.api.instance.InstanceType;
|
||||
import com.jozufozu.flywheel.api.instance.Instancer;
|
||||
import com.jozufozu.flywheel.api.instance.InstancerProvider;
|
||||
import com.jozufozu.flywheel.api.model.Model;
|
||||
import com.jozufozu.flywheel.api.task.Plan;
|
||||
import com.jozufozu.flywheel.api.task.TaskExecutor;
|
||||
|
||||
|
@ -14,7 +19,21 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Vec3i;
|
||||
|
||||
@BackendImplemented
|
||||
public interface Engine extends DirectInstancerProvider {
|
||||
public interface Engine {
|
||||
/**
|
||||
* Get an instancer for the given instance type, model, and render stage.
|
||||
*
|
||||
* <p>Calling this method twice with the same arguments will return the same instancer.</p>
|
||||
*
|
||||
* <p>If you are writing a visual you should probably be using
|
||||
* {@link InstancerProvider#instancer(InstanceType, Model)}, which will decide the {@code RenderStage}
|
||||
* based on what type of visual is getting the instancer.</p>
|
||||
*
|
||||
* @return An instancer for the given instance type, model, and render stage.
|
||||
* @see InstancerProvider
|
||||
*/
|
||||
<I extends Instance> Instancer<I> instancer(InstanceType<I> type, Context context, Model model, RenderStage stage);
|
||||
|
||||
/**
|
||||
* Create a plan that will be executed every frame.
|
||||
* @return A new plan.
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.jozufozu.flywheel.api.instance;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.api.backend.DirectInstancerProvider;
|
||||
import com.jozufozu.flywheel.api.model.Model;
|
||||
|
||||
public interface InstancerProvider {
|
||||
|
@ -14,17 +11,4 @@ public interface InstancerProvider {
|
|||
* @return An instancer for the given instance type rendering the given model.
|
||||
*/
|
||||
<I extends Instance> Instancer<I> instancer(InstanceType<I> type, Model model);
|
||||
|
||||
/**
|
||||
* Get the {@link DirectInstancerProvider} this provider is built on top of.
|
||||
*
|
||||
* <p>The direct provider allows for explicit control over the
|
||||
* {@link com.jozufozu.flywheel.api.context.Context Context} and
|
||||
* {@link com.jozufozu.flywheel.api.event.RenderStage RenderStage}.
|
||||
* Generally this is a safe operation, though compatibility issues basically guaranteed
|
||||
* if you mess with the Context <em>and</em> nest visuals.</p>
|
||||
* @return A DirectInstancerProvider.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
DirectInstancerProvider _directProvider();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
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();
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.jozufozu.flywheel.api.visual;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
public interface VisualTickContext {
|
||||
// TODO: remove?
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.jozufozu.flywheel.api.visualization;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import com.jozufozu.flywheel.api.instance.InstancerProvider;
|
||||
|
||||
import net.minecraft.core.Vec3i;
|
||||
|
@ -7,6 +9,7 @@ import net.minecraft.core.Vec3i;
|
|||
/**
|
||||
* A context object passed on visual creation.
|
||||
*/
|
||||
@ApiStatus.NonExtendable
|
||||
public interface VisualizationContext {
|
||||
/**
|
||||
* @return The {@link InstancerProvider} that the visual can use to get instancers to render models.
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.jozufozu.flywheel.impl.visualization;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.jozufozu.flywheel.api.backend.DirectInstancerProvider;
|
||||
import com.jozufozu.flywheel.api.backend.Engine;
|
||||
import com.jozufozu.flywheel.api.event.RenderStage;
|
||||
import com.jozufozu.flywheel.api.instance.Instance;
|
||||
|
@ -20,11 +19,6 @@ public record InstancerProviderImpl(Engine engine,
|
|||
return engine.instancer(type, Contexts.DEFAULT, model, renderStage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DirectInstancerProvider _directProvider() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisualizationContext get() {
|
||||
return new VisualizationContextImpl(this, engine.renderOrigin());
|
||||
|
|
|
@ -12,6 +12,6 @@ import net.minecraft.core.Vec3i;
|
|||
* @param renderOrigin The origin of the renderer as a world position.
|
||||
* All models render as if this position is (0, 0, 0).
|
||||
*/
|
||||
public record VisualizationContextImpl(InstancerProviderImpl instancerProvider,
|
||||
public record VisualizationContextImpl(InstancerProvider instancerProvider,
|
||||
Vec3i renderOrigin) implements VisualizationContext {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue