Merge pull request #768 from CalamityTeam/ParticleCulling

particle culling
This commit is contained in:
mountaindrew10 authored and GitHub committed 2023-09-22 19:22:45 -05:00
commit ded7d8a5b1
1 file changed
+6
+6
View File
@@ -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<Texture2D>(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)