forked from FiniteReality/embeddium
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ain/java/me/jellysquid/mods/sodium/mixin/features/particle/cull/MixinParticleManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.jellysquid.mods.sodium.mixin.features.particle.cull; | ||
|
||
import com.llamalad7.mixinextras.injector.WrapWithCondition; | ||
import me.jellysquid.mods.sodium.client.SodiumClientMod; | ||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; | ||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.particle.ParticleManager; | ||
import net.minecraft.client.renderer.BufferBuilder; | ||
import net.minecraft.client.renderer.culling.Frustum; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.util.math.AxisAlignedBB; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ParticleManager.class) | ||
public class MixinParticleManager { | ||
|
||
private Frustum cullingFrustum; | ||
|
||
@Inject(method = {"renderParticles", "renderLitParticles"}, at = @At("HEAD")) | ||
private void preRenderParticles(Entity entity, float partialTicks, CallbackInfo ci) { | ||
Frustum frustum = SodiumWorldRenderer.getInstance().getFrustum(); | ||
boolean useCulling = SodiumClientMod.options().advanced.useParticleCulling; | ||
|
||
// Setup the frustum state before rendering particles | ||
if (useCulling && frustum != null) { | ||
this.cullingFrustum = frustum; | ||
} else { | ||
this.cullingFrustum = null; | ||
} | ||
} | ||
|
||
@WrapWithCondition(method = {"renderParticles", "renderLitParticles"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/particle/Particle;renderParticle(Lnet/minecraft/client/renderer/BufferBuilder;Lnet/minecraft/entity/Entity;FFFFFF)V")) | ||
private boolean filterParticleList(Particle particle, BufferBuilder f8, Entity f9, float f10, float f11, float f12, float vec3d, float v, float buffer) { | ||
AxisAlignedBB box = particle.getBoundingBox(); | ||
|
||
// Hack: Grow the particle's bounding box in order to work around mis-behaved particles | ||
return this.cullingFrustum.isBoxInFrustum(box.minX - 1.0D, box.minY - 1.0D, box.minZ - 1.0D, box.maxX + 1.0D, box.maxY + 1.0D, box.maxZ + 1.0D); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Should probably add
this.cullingFrustum != null
here.