A Modifier that perfoms particle against particle collisions in the Group. More...
Public Member Functions | |
Collision (float scale=1.0f, float elasticity=1.0f) | |
Constructor of the Collision modifier. | |
void | setScale (float scale) |
Sets the scale of particles to compute their radius. | |
void | setElasticity (float elasticity) |
Sets the elasticity of the collisions. | |
float | getElasticity () const |
Gets the elasticity of the collisions. | |
float | getScale () const |
Gets the scale applied on particle radius. | |
Static Public Member Functions | |
static Collision * | create (float scale=1.0f, float elasticity=1.0f) |
Creates and registers a new Collision. |
A Modifier that perfoms particle against particle collisions in the Group.
The collision between particles uses the size of the particle to determine its radius.
The radius of a particle is computed as follows : radius = size * scale * 0.5f
Moreover the mass ratio of two particles colliding is used to get realistic collision.
The collision can be set as being elastic or inelastic. This is determined thanks to the elasticity of this modifier :
Note that collision particle vs particles requires intensive processing. Moreover the algorithm has a complexity that badly scales which means processing times increase fastly as particles count increase.
Tries to limitate the number of particles to perform collision on. More than 1000 particles can require a lot of processing time even of recent hardware.
The accuracy of the collisions is better with small update steps. Therefore try to keep the update time small by for instance multiplying the number of updates per frame.
Definition at line 58 of file SPK_Collision.h.
Collision | ( | float | scale = 1.0f , |
|
float | elasticity = 1.0f | |||
) |
Constructor of the Collision modifier.
scale | : the scale of the particles | |
elasticity | : the elasticity of the collisions |
Collision * create | ( | float | scale = 1.0f , |
|
float | elasticity = 1.0f | |||
) | [static] |
Creates and registers a new Collision.
scale | : the scale of the particles | |
elasticity | : the elasticity of the collisions |
Definition at line 135 of file SPK_Collision.h.
float getElasticity | ( | ) | const |
Gets the elasticity of the collisions.
Definition at line 153 of file SPK_Collision.h.
float getScale | ( | ) | const |
Gets the scale applied on particle radius.
Definition at line 158 of file SPK_Collision.h.
void setElasticity | ( | float | elasticity | ) |
Sets the elasticity of the collisions.
The elasticity of the collisions refers to the coefficient of restitution (also called bounciness).
See the class description for more information.
elasticity | : the elasticity of the collisions |
Definition at line 142 of file SPK_Collision.h.
void setScale | ( | float | scale | ) |
Sets the scale of particles to compute their radius.
The radius of a particle is computed as follows :
radius = size * scale * 0.5f
scale | : the scale of the particles |
Definition at line 148 of file SPK_Collision.h.