From c08dc4f07b9ac3c6c8c74688395e5d08ba91ce98 Mon Sep 17 00:00:00 2001 From: Lorenz Mielke Date: Wed, 13 Nov 2024 21:20:21 +0100 Subject: [PATCH] added a way to opt out of auto aabb calculation --- crates/enoki2d/src/lib.rs | 9 ++++++++- crates/enoki2d/src/update.rs | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/enoki2d/src/lib.rs b/crates/enoki2d/src/lib.rs index 35e9bf3..95f0f90 100644 --- a/crates/enoki2d/src/lib.rs +++ b/crates/enoki2d/src/lib.rs @@ -32,7 +32,9 @@ pub mod prelude { pub use super::sprite::SpriteParticle2dMaterial; pub use super::update::{OneShot, ParticleEffectInstance, ParticleSpawnerState, ParticleStore}; pub use super::values::{Random, Rval}; - pub use super::{EmissionShape, Particle2dEffect, ParticleEffectHandle, ParticleSpawner}; + pub use super::{ + EmissionShape, NoAutoAabb, Particle2dEffect, ParticleEffectHandle, ParticleSpawner, + }; } pub(crate) const PARTICLE_VERTEX_OUT: Handle = @@ -127,6 +129,11 @@ impl Plugin for EnokiPlugin { pub type WithParticles = With; +/// adding this component will disabled auto +/// aabb caluclation. Aabb resolves to it's default size. +#[derive(Component)] +pub struct NoAutoAabb; + /// The main particle spawner components /// has required components #[derive(Component, DerefMut, Deref, Clone)] diff --git a/crates/enoki2d/src/update.rs b/crates/enoki2d/src/update.rs index 399068e..28f243e 100644 --- a/crates/enoki2d/src/update.rs +++ b/crates/enoki2d/src/update.rs @@ -1,4 +1,4 @@ -use super::{prelude::EmissionShape, ParticleEffectHandle, Particle2dEffect}; +use super::{prelude::EmissionShape, Particle2dEffect, ParticleEffectHandle}; use crate::values::Random; use bevy::{prelude::*, render::primitives::Aabb}; use std::time::Duration; @@ -259,7 +259,7 @@ fn update_particle(particle: &mut Particle, effect: &Particle2dEffect, delta: f3 pub(crate) fn calculcate_particle_bounds( mut cmd: Commands, - spawners: Query<(Entity, &ParticleStore)>, + spawners: Query<(Entity, &ParticleStore), Without>, ) { spawners.iter().for_each(|(entity, store)| { let particle_count = store.len();