Expandable Solid Particle System

There’s an expectation about the SPS (Solid Particle System) that is as old as the SPS itself : the ability to add solid particles in the system once this one is built.

Well, waiting for the team to merge the PR, the feature is now on the stage and it’s called “expandable SPS”.

Usage :

// create an expandable SPS with 500 particles
var sps = new BABYLON.SolidParticleSystem('sps', scene, {expandable: true});
sps.addShape(model, 500);
sps.buildMesh();

// ... further in the code
// add 60 more particles
sps.addShape(otherModel, 30);
sps.addShape(thirdModel, 30);
sps.buildMesh();   // again, that simple

// and you can do it as many times you need

Under the hood, the difference with a fixed SPS is :

  • the dynamic array storing just created particles is never freed (so more memory used)
  • a new VertexData, so a new VertexBuffer, is created each time sps.buildMesh() is called, so the Garbage Collector can trigger when it wants then.

PG and documentation to come soon.

5 Likes

This literally rocks!! Furthermore I’m glad you are back to business my friend!

2 Likes

https://playground.babylonjs.com/#X1T859

Each click, 20 new depth sorted transparent particles are added to the expandable SPS.

2 Likes

https://playground.babylonjs.com/#X1T859#1

stress test : 100 new animated solid particles added each click. Open the console to check the current particle number.

3 Likes

Coming soon : an even better feature, even more expected … try to guess :wink:

1 Like

Can’t wait now!!!

re

mo

va

ble

par

ti
(to be continued)

Wuuuuut!!! This one is definitely an expected one!

1 Like

Usage

    var sps = new BABYLON.SolidParticleSystem("sps", scene, {expandable: true});
    var model = BABYLON.MeshBuilder.CreateBox("m", {}, scene);
    sps.addShape(model, 1000);
    sps.buildMesh();

     // ... further in the code
    sps.removeParticles(700, 999);  // removes the last 300 particles
    sps.removeParticles(0, 9);      // then removes the first 10
    sps.buildMesh();                // like for adding particles after the sps creation,
                                    // the call to buildMesh() is required

Documentation and PG example to come soon

1 Like

PG (once the build is merged) : Babylon.js Playground
Each click removes the 100 first and 2 last particles from the SPS until it remains less than 102 ones.
Open the console to check the remaining number.

Rock and roll!

1 Like

yeah, its online :slight_smile:
https://playground.babylonjs.com/#0MXVDK

click to remove the particles

2 Likes

You rock !!!

1 Like

Still two features to add to the expandable SPS and it will be done (before writting the doc, my favorite part :unamused: )
I think then it will maybe be usable to build some simple vortex engine or some dynamic maze generator.

1 Like