MasterSplinter Posted December 30, 2015 Share Posted December 30, 2015 I was looking for a way to turn off particles in the render loop. Can't seem to get the particle.alive property to do anything other than hold a bool. Any suggestions? Thanks in advanced! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 30, 2015 Share Posted December 30, 2015 Do you want to turn a specific particle off or all the system? Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted December 30, 2015 Author Share Posted December 30, 2015 Do you want to turn a specific particle off or all the system?Not a specific particle necessarily just change the amount visible within the system. Or add/remove from the system in real time. -- Edit: not turn off the whole system. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 30, 2015 Share Posted December 30, 2015 I leave this to the SPS master (Jerome) Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted December 30, 2015 Author Share Posted December 30, 2015 Just checked the source -- Don't see a method for currently doing this... I'll probably give it a try later today and see if what I can come up with. Thanks! Quote Link to comment Share on other sites More sharing options...
jerome Posted December 30, 2015 Share Posted December 30, 2015 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. Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted December 30, 2015 Author Share Posted December 30, 2015 You da man thanks for the tips! lol "liceman" Quote Link to comment Share on other sites More sharing options...
jerome Posted December 30, 2015 Share Posted December 30, 2015 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 Quote Link to comment Share on other sites More sharing options...
MasterSplinter Posted December 30, 2015 Author Share Posted December 30, 2015 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? Quote Link to comment Share on other sites More sharing options...
jerome Posted December 30, 2015 Share Posted December 30, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.