Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Destroy particle on collision
#4
(29-09-2017, 12:30 PM)Kalidor Wrote: Thank you for the support!

Mmh, i'am trying to kill all particles in the collision loop.
At the beginning it works. Later the wrong particles get killed. 
(maybe second time new created particles cause the problem) 

Yes! you're 100% right, my apologies. Since dead particles are swapped with the last living particle for better cache locality, this will cause successive calls to KillParticle() to fail if they're done in the wrong order.

The solution to this is to set the particle's life to zero, instead of calling KillParticle() (in fact, I will make this method private in the future to avoid other users -and myself- to fall in this trap again). This will ensure the emitter itself kills the correct particles as soon as the next frame starts.

Code:
emitter.life[solver.particleToActor[contact.particle].indexInActor] = 0;

In addition to this, there was a bug in the emitter in version 3.2, emitters did not update the particleToActor array correctly when spawning new particles. Attached you'll find an updated ObiEmitter.cs script, you must replace yours with this one.

Thanks a lot for pointing out this issue!


Attached Files
.cs   ObiEmitter.cs (Size: 11.1 KB / Downloads: 29)
Reply


Messages In This Thread
Destroy particle on collision - by Kalidor - 29-09-2017, 10:50 AM
RE: Destroy particle on collision - by josemendez - 29-09-2017, 12:01 PM
RE: Destroy particle on collision - by Kalidor - 29-09-2017, 12:30 PM
RE: Destroy particle on collision - by josemendez - 29-09-2017, 02:09 PM
RE: Destroy particle on collision - by KalidorH8r - 26-10-2018, 04:28 PM
RE: Destroy particle on collision - by Kalidor - 29-09-2017, 02:45 PM
RE: Destroy particle on collision - by josemendez - 29-09-2017, 03:03 PM
RE: Destroy particle on collision - by Kalidor - 29-09-2017, 03:54 PM
RE: Destroy particle on collision - by Kalidor - 02-10-2017, 01:40 PM
RE: Destroy particle on collision - by Jaydena - 03-05-2018, 07:28 AM
RE: Destroy particle on collision - by josemendez - 03-05-2018, 08:32 AM
RE: Destroy particle on collision - by Jaydena - 04-05-2018, 01:44 AM
RE: Destroy particle on collision - by josemendez - 18-10-2021, 08:22 AM