More physics in Flint

Posted on

Today, I added some key features for improving the physics in Flint. Primary among these is the addition of mass and radius properties to the particle class.

The mass property represents the mass of the particle. By default, particles have a mass of 1, meaning all behaviours remain unchanged unless you modify the particle's mass. The mass is used in the collide, friction, drag, bounding box and gravity actions.

The radius property represents the size of the particle when calculating collisions. In collisions, all particles are treated as circles (in 2D) or spheres (in 3D). The radius is used in the collide and bounding box actions.

In addition, the mass and radius are used to calculate the moment of inertia of the particle, which affects rotational friction and rotational drag.

To integrate the scaling into this, the Scale action and ScaleInit behaviours have been split into ScaleImage and ScaleAll actions and ScaleImageInit and ScaleAllInit initializers. The ScaleImage actions and initializers just alter the scale property of the particle (and hence the image size), while the ScaleAll actions and initializers alter the radius and mass as well.

I also added initializers and actions for modifying the mass and collision radius of the particle.

Finally, I updated the examples to work with these changes, and added an example that simulates brownian motion in both 2D and 3D.

Share this post or a comment online -


Also in the collection Flint Particles