schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Remove Particle? #198

Open schteppe opened 8 years ago

schteppe commented 8 years ago

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

Fishrock123 commented 8 years ago

Hmmm, is particle any more efficient?

schteppe commented 8 years ago

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.

Scharnvirk commented 8 years ago

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:

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