Jump to content

Solid Particle System particle.alive question


MasterSplinter
 Share

Recommended Posts

well, as you understood, the property alive is just a boolean.

No pre-implemented process handles it as I wanted the SPS the most agnostic possible.

In other terms, there's no provided method to "turn off" a given particle.

 

Remember also that the SPS is a real mesh and the particles are its parts. So once the SPS is built ( buildMesh() ), you can't add nor remove particles from the system, only change their status.

 

That said, you can obviously set the wanted particles as dead (alive = false) and implement your own behavior for dead particles.

Example :

the dead particles won't be treated in term of position, velocity, color, etc, just skip them in the call to updateParticles() : 

if ( !particle.alive ) { return; }

if you don't want them to be visible, you can scale them to zero, position them behind the cam or outside the frustrum

 

In brief, do whatever fits the best to your needs, knowing that you can't add or remove facets (particles) from the whole mesh  ;)

Iiceman did something like this in one of his demo.

 

 

[EDIT] for now and for performance reasons, I don't implement something to modify the global mesh geometry on air, because it would be very expensive to re-compute everything and re-instantiate all the float32 arrays.

All the work in the SPS was done to focus on the performance, trying to get close to the legacy particle system perfs.

Link to comment
Share on other sites

On 12/29/2015 at 10:53 AM, jerome said:

Remember also that you can force the SPS to process only some sub-arrays of the whole particle arrays if you need more speed in your render loop :

http://doc.babylonjs.com/overviews/Solid_Particle_System#start-and-end-indexes-for-setparticles

So scale to zero and not calculate unless you want to return them to the global pool would be the most efficient method of turn them off?

Link to comment
Share on other sites

Well, just skipping them with "if (!particle.alive) {return; }" should be enough in term of performance, unless you're dealing with dozens of thousands particles.

In this case, you could reduce the computation to some only.

 

Or if you manage something like many pools of particles within the same SPS and you want to compute things each call only for one pool (this could be the pools of deads and alives if they are sorted), the sub-array call could be useful.

 

Scaling them to zero is an easy way to make them invisible, you could even set them at the cam position, or behind it, depending on what type of cam you're using.

You can also make them fully transparent.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...