particle culling

This commit is contained in:
AquaSG committed 2023-09-22 19:46:57 -04:00
1 parent e306d0eb4e
commit c2256d9ab3
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)