Skip to content

Commit

Permalink
added a way to opt out of auto aabb calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Lommix committed Nov 13, 2024
1 parent 4834f53 commit c08dc4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion crates/enoki2d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Shader> =
Expand Down Expand Up @@ -127,6 +129,11 @@ impl Plugin for EnokiPlugin {

pub type WithParticles = With<ParticleSpawnerState>;

/// 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)]
Expand Down
4 changes: 2 additions & 2 deletions crates/enoki2d/src/update.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<crate::NoAutoAabb>>,
) {
spawners.iter().for_each(|(entity, store)| {
let particle_count = store.len();
Expand Down

0 comments on commit c08dc4f

Please sign in to comment.