BlurrrParticle  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
BlurrrParticle Documentation

BlurrrParticle (BLRParticle) is a highly optimized 2D particle system. It utilizes Data Oriented Design priniples to minimize cache misses while also employing SIMD (SSE & NEON) to maximize computation throughput. This implementation was designed with the main purpose of being fast, with the idea that this should be as efficient as possible to keep resources available to do the other work in your game, such as physics, AI, etc.

It is also renderer agnostic in that the system prepares a batched array that can be sumbitted to most hardware accelerated APIs. BlurrrParticle was designed with SDL_gpu in mind, but can still be utilized with other renderers.

BlurrrParticle embraces the Newtonian Laws of Motion for particle behaviors. Instead of arbitrary implementation specific quirks, all motion obeys several different equations.

Linear: s = s0 + v0*t + 1/2*a*t^2

Angular: theta = theta0 + omega0*t + 1/2*alpha*t^2

Linear Interpolation: (1-t)*s0 + t*s1;

By using deterministic equations instead of implementation specific quirks, particle behavior can be made more consistent across varying frame rates, and additional performance optimizations can be utilized. Additionally, because these equations are well specified, 3rd party tools can easily be made to work with BlurrrParticle.

Because these are algorithmic, Linear and Angular (Radial) motions can be added together, creating more powerful effects. They are not mutually exclusive unlike many other particle engines.

Try the Blurrr SDK particle editor "Sparkle Sparkle". Sparkle Sparkle source code is also made available as an example.

Particle properties may also be saved and loaded through JSON.

See Also
BlurrrParticle.h contains core APIs. BlurrrParticleFile.h contains file APIs.

Sample Usage:

struct BLRParticle* particle_effect = BLRParticle_Create(10000);
BLRParticle_SetVelocity(particle_effect, 10.0, 20.0);
BLRParticle_SetPosition(particle_effect, 100.0, 100.0);
// current_time is in milliseconds, provided by BlurrrTicker or SDL_GetTicks.
BLRParticle_StartEmitter(particle_effect, current_time);
// In main loop
// Other stuff like PollEvent, Update current_time, etc.
// Updates the particles
BLRParticle_Update(particle_effect, current_time);
// Other stuff for renderer
// Get the vertex array to draw
size_t num_elements = 0;
const float* vertex_array = BLRParticle_GetVertexArray(particle_effect, &num_elements);
// Draw the particles (using SDL_gpu with Blurrr convenience function)
GPU_EXT_TriangleSpriteBatch(gpu_image, gpu_target, vertex_array, num_elements);

Performance Tips:

BlurrrParticle's native/default coordinate system follows Cartesian coordinates (y-axis increases upwards, like OpenGL and math books).