Skip to content

Commit

Permalink
Improve efficiency of Flywheel instancing checks on 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Oct 13, 2023
1 parent 43f3178 commit 22d7b8e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ public static void filterBlockEntityList(Collection<BlockEntity> blockEntities)
}
}

public static boolean isSkipped(BlockEntity be) {
if(!SodiumClientMod.flywheelLoaded)
return false;
if(!Backend.getInstance().canUseInstancing())
return false;
return InstancedRenderRegistry.getInstance().shouldSkipRender(be);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,6 @@ public void onChunkRemoved(int x, int z) {

public void onChunkRenderUpdated(int x, int y, int z, ChunkRenderData meshBefore, ChunkRenderData meshAfter) {
ListUtil.updateList(this.globalBlockEntities, meshBefore.getGlobalBlockEntities(), meshAfter.getGlobalBlockEntities());

FlywheelCompat.filterBlockEntityList(this.globalBlockEntities);

this.chunkRenderManager.onChunkRenderUpdates(x, y, z, meshAfter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ private void addEntitiesToRenderLists(ChunkRenderContainer<T> render) {

if (!blockEntities.isEmpty()) {
this.visibleBlockEntities.addAll(blockEntities);
FlywheelCompat.filterBlockEntityList(this.visibleBlockEntities);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Map;

import me.jellysquid.mods.sodium.client.SodiumClientMod;
import me.jellysquid.mods.sodium.client.compat.FlywheelCompat;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers;
Expand Down Expand Up @@ -151,7 +152,8 @@ public ChunkBuildResult<T> performBuild(ChunkRenderCacheLocal cache, ChunkBuildB
BlockEntityRenderer<BlockEntity> renderer = BlockEntityRenderDispatcher.INSTANCE.get(entity);

if (renderer != null) {
renderData.addBlockEntity(entity, !renderer.rendersOutsideBoundingBox(entity));
if (!FlywheelCompat.isSkipped(entity))
renderData.addBlockEntity(entity, !renderer.rendersOutsideBoundingBox(entity));

bounds.addBlock(relX, relY, relZ);
}
Expand Down

0 comments on commit 22d7b8e

Please sign in to comment.