Skip to content

Commit

Permalink
Partial progress on new FREX events
Browse files Browse the repository at this point in the history
  • Loading branch information
grondag committed Nov 22, 2020
1 parent 408c052 commit d009baa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/main/java/grondag/canvas/render/CanvasWorldRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
import grondag.canvas.varia.WorldDataManager;
import grondag.fermion.sc.unordered.SimpleUnorderedArrayList;
import grondag.frex.api.event.WorldRenderEvent;
import grondag.frex.impl.event.WorldRenderContextImpl;

public class CanvasWorldRenderer extends WorldRenderer {
public static final int MAX_REGION_COUNT = (32 * 2 + 1) * (32 * 2 + 1) * 16;
Expand Down Expand Up @@ -153,6 +154,7 @@ public class CanvasWorldRenderer extends WorldRenderer {
private final RenderContextState contextState = new RenderContextState();
public final CanvasImmediate worldRenderImmediate = new CanvasImmediate(new BufferBuilder(256), CanvasImmediate.entityBuilders(), contextState);
private final CanvasParticleRenderer particleRenderer = new CanvasParticleRenderer();
private final WorldRenderContextImpl eventContext = new WorldRenderContextImpl();

public CanvasWorldRenderer(MinecraftClient client, BufferBuilderStorage bufferBuilders) {
super(client, bufferBuilders);
Expand Down Expand Up @@ -443,6 +445,8 @@ public void renderWorld(MatrixStack matrixStack, float tickDelta, long limitTime
profiler.swap("terrain_setup");

setupTerrain(camera, wr.canvas_getAndIncrementFrameIndex(), shouldCullChunks(camera.getBlockPos()));
eventContext.setFrustum(frustum);
WorldRenderEvent.AFTER_TERRAIN_SETUP.invoker().onRender(eventContext);
LitematicaHolder.litematicaTerrainSetup.accept(frustum);

profiler.swap("updatechunks");
Expand Down Expand Up @@ -625,6 +629,7 @@ public void renderWorld(MatrixStack matrixStack, float tickDelta, long limitTime

immediate.drawCollectors(MaterialTarget.MAIN);

WorldRenderEvent.AFTER_ENTITIES.invoker().onRender(eventContext);
SatinHolder.onEntitiesRenderedEvent.onEntitiesRendered(camera, frustum, tickDelta);
LitematicaHolder.litematicaEntityHandler.handle(matrixStack, tickDelta);
DynocapsHolder.handler.render(profiler, matrixStack, immediate, cameraVec3d);
Expand Down Expand Up @@ -689,6 +694,7 @@ public void renderWorld(MatrixStack matrixStack, float tickDelta, long limitTime

RenderSystem.pushMatrix();
RenderSystem.multMatrix(matrixStack.peek().getModel());
WorldRenderEvent.BEFORE_DEBUG_RENDER.invoker().onRender(eventContext);
ClothHolder.clothDebugPreEvent.run();
mc.debugRenderer.render(matrixStack, immediate, cameraX, cameraY, cameraZ);
RenderSystem.popMatrix();
Expand Down Expand Up @@ -1151,10 +1157,11 @@ public void render(MatrixStack matrices, float tickDelta, long limitTime, boolea
wr.canvas_mc().getProfiler().swap("dynamic_lighting");
LambDynLightsHolder.updateAll.accept(this);

WorldRenderEvent.BEFORE_WORLD_RENDER.invoker().beforeWorldRender(matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f);
eventContext.prepare(this, matrices, tickDelta, limitTime, renderBlockOutline, camera, matrix4f, worldRenderImmediate);
WorldRenderEvent.BEFORE_START.invoker().onRender(eventContext);
renderWorld(matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f);
VoxelMapHolder.postRenderHandler.render(this, matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f);
WorldRenderEvent.AFTER_WORLD_RENDER.invoker().afterWorldRender(matrices, tickDelta, limitTime, renderBlockOutline, camera, gameRenderer, lightmapTextureManager, matrix4f);
WorldRenderEvent.AFTER_END.invoker().onRender(eventContext);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/grondag/canvas/terrain/ChunkColorCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import grondag.canvas.mixinterface.BiomeAccessExt;
import grondag.canvas.mixinterface.WorldChunkExt;

//TODO: per-vertex blending (quality)
//FEAT: per-vertex blending (quality)
@Environment(value = EnvType.CLIENT)
public class ChunkColorCache implements BiomeAccess.Storage {
private static final MinecraftClient mc = MinecraftClient.getInstance();
Expand Down

0 comments on commit d009baa

Please sign in to comment.