From c2256d9ab33fa9aecc62d1f0a4cbf59d2a8b9edf Mon Sep 17 00:00:00 2001 From: AquaSG Date: Fri, 22 Sep 2023 19:46:57 -0400 Subject: [PATCH] particle culling --- Particles/GeneralParticleHandler.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index f32211b4b8..8f62d00e11 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -119,12 +119,18 @@ namespace CalamityMod.Particles sb.End(); + Rectangle screenRect = new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y, Main.screenWidth, Main.screenHeight); //Batch the particles to avoid constant restarting of the spritebatch foreach (Particle particle in particles) { if (particle == null) continue; + Texture2D texture = ModContent.Request(particle.Texture).Value; + Rectangle particleRect = new Rectangle((int)particle.Position.X, (int)particle.Position.Y, (int)(texture.Width * particle.Scale), (int)(texture.Height * particle.Scale)); + if (!particleRect.Intersects(screenRect)) + continue; + if (particle.UseAdditiveBlend) batchedAdditiveBlendParticles.Add(particle); else if (particle.UseHalfTransparency)