Sign in to follow this  
Gumgo

Particle system AABB?

Recommended Posts

Particle systems in my game can have the following properties (related to motion/position): size_life = size when particle is first created size_death = size when particle is about to be destroyed speed_min = minimum random speed speed_max = maximum random speed initial_direction (vector) = direction when particle is created spread (0-180) = initial_direction randomness - 0 degrees = all particles shooting in one direction, 180 degrees = particles shoot out in any direction gravity_direction (vector) = pretty obvious gravity_strength = also pretty obvious life_min = minimum possible random life of a particle life_max = maximum possible random life of a particle It is easy to determine the "radius" of a particle system (by radius I mean the maximum distance any particle could travel, assuming the initial direction is the same direction as gravity): half the diagonal of the quad "distance": (max( size_life, size_death ) * sqrt( .5 )) speed of particle "distance": (life_max * initial_speed) gravity "distance": (gravity_strength * (life_max + life_max * life_max) * 0.5) total: (max( size_life, size_death ) * sqrt( .5 )) + (life_max * initial_speed) + (gravity_strength * (life_max + life_max * life_max) * 0.5) That is the maximum distance a particle could possibly travel assuming it traveled in a straight path and only sped up due to gravity. However, that usually wouldn't happen, so that isn't a very good representation of the size of the particle system. So, is it reasonable to, and if so how would I, calculate the axis aligned bounding box of a particle system with these given parameters for the system? I'd have to combine all these into an equation/equations to determine the minimum and maximum x, y, and z that a particle could be. This sounds fairly... not fun... so is there a better way to estimate the bounding box?

Share this post


Link to post
Share on other sites
Unless you're doing some fancy GPGPU stuff, you already need to process each particle once per frame (or at least once per particle system update). I see no better way than to just get min/max coordinate values during this processing.

On x86 you can always try to speed this up with SSE using following intrinsics:

__m128 _mm_minps(__m128 a, __m128 b); // element-wise minimum, maps to MINPS SSE instruction
__m128 _mm_maxps(__m128 a, __m128 b); // element-wise maximum, maps to MAXPS SSE instruction

Both are original SSE instructions that should be supported on pretty much any CPU.

Share this post


Link to post
Share on other sites
Ah, good point, thanks. I suppose the radius could be used to test when a particle system would need to be updated (when the update could move particles into view), however since I'm using a quadtree and portal system then it doesn't really have much use I guess.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this