p2.js icon indicating copy to clipboard operation
p2.js copied to clipboard

Remove Particle?

Open schteppe opened this issue 9 years ago • 3 comments

In many cases, a small Circle can be used instead of a particle. No other 2d physics engines seem to have particle shapes. Better to save some build size?

Note: World.prototype.hitTest need to stop using Particle for intersection test, and should probably use a new method pointTest on each Shape

schteppe avatar Jan 03 '16 12:01 schteppe

Hmmm, is particle any more efficient?

Fishrock123 avatar Jan 03 '16 15:01 Fishrock123

I'd say they're about the same. The main difference is in the Narrowphase but those contact algorithms are very similar when you look closer.

The main difference is that Particle will never be able to collide with other particles, or with lines. But it will still use broadphase and so on, so it's still as bad for performance on that part. Optimizing for this special case is probably difficult (if particle && worldHasNoParticleCollidableShapes(particle))- you may then just turn off broadphase completely.

schteppe avatar Jan 04 '16 06:01 schteppe

The Particle is slightly faster than the Circle.

In my current stress test which involves shooting bodies in random directions from a centre of square, walled-off arena, I am testing performance on about 1500 of them (about because when it lags, there are less on-screen).

Current performance ranking:

  • Particle: 58-60 FPS
  • Circle radius 0 and 1: 53-60 FPS, but average 55
  • Circle radius 5: avg 35 FPS
  • Circle radius 10: avg 22 FPS
  • Circle radius 50: avg 5 FPS

I won't cry too much over these few FPS, but there certainly is a noticeable difference.

Scharnvirk avatar Feb 13 '16 21:02 Scharnvirk