A particle system patch and testbed

Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

A particle system patch and testbed

Postby kenneth_g » Tue Dec 04, 2012 2:01 am

Hello all

For some time now, I have been working on a particle system, that would work along with Box2D. This turned out to be much harder than I first anticipated, especially when I both wanted it to be fast and accurate. In the end, however, I managed to achieve both, and I'm therefore releasing the source, in case anyone else might find it useful. The testbed shows most of what it can do, and what it can't do.

Bug-reports and suggestions/improvements are most welcome!

Btw. the patch is for r251.

- Kenneth G.
Attachments
ps.patch
The patch
(232.21 KiB) Downloaded 178 times

irresistible force
Posts: 1988
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: A particle system patch and testbed

Postby irresistible force » Tue Dec 04, 2012 3:59 pm

Nice work! Just looking at the patch file, seems like you were about to do fluids as well...?

kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

Re: A particle system patch and testbed

Postby kenneth_g » Tue Dec 04, 2012 7:46 pm

I actually started with fluids, but quickly realized that making a solid, base, particle system would be more prudent in the long run. The needs of the fluids also dictated some of the design decisions that went into the particle system, like the use of a grid to manage the particles, and the ability to add custom attributes to the particles (as demonstrated in the Custom Particle testbed entry).

Now that that's done, I can return to the fluids. And the 97.3mb of fluid-related pdfs I have on my desktop :shock:

ait
Posts: 53
Joined: Wed Jul 25, 2012 5:08 am

Re: A particle system patch and testbed

Postby ait » Tue Dec 04, 2012 11:44 pm

I seems working fine with about 30k particles(in stress test, above 30FPS?). Have you done something to improve broadphase?
Looking forward to the version finished calculating the forces between particles.

pTymN
Posts: 518
Joined: Tue Sep 25, 2007 2:22 pm

Re: A particle system patch and testbed

Postby pTymN » Wed Dec 05, 2012 1:40 am

I see SSE optimizations and spatial hashing for the particles.

ait
Posts: 53
Joined: Wed Jul 25, 2012 5:08 am

Re: A particle system patch and testbed

Postby ait » Wed Dec 05, 2012 1:53 am

In fact I have tried something simular, about 36fps with 1000 particles on iPhone4. (about 450fps on my PC. icore5, GTS450)
I'm tring to improve the rendering effect, it's not so comfortable for me..
Attachments
2012-12-5 16-55-58.png
2012-12-5 16-55-58.png (66.81 KiB) Viewed 2052 times

ait
Posts: 53
Joined: Wed Jul 25, 2012 5:08 am

Re: A particle system patch and testbed

Postby ait » Wed Dec 05, 2012 2:16 am

pTymN wrote:I see SSE optimizations and spatial hashing for the particles.


I'm using hashing for calculating forces between particles, and use collision filtering between particles. But currently could not deprecate the world broadphase (avoiding AABB testing will completely disable the box2d world, and you would have to do those jobs yourself.. ).

kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

Re: A particle system patch and testbed

Postby kenneth_g » Fri Dec 07, 2012 1:49 am

ait wrote:Have you done something to improve broadphase?

No I havn't, I'm using my own broadphase. I only use Box2D to query fixtures, and do raycasts.

ait wrote:Looking forward to the version finished calculating the forces between particles.

I don't have any plans to do inter-particle collisions in the particle system, but it is easy to extend it to do so.

pTymN wrote:I see SSE optimizations and spatial hashing for the particles.

Actually, it is just a regular grid, with cells created and destroyed as-needed.
As for the SSE, it is not enabled by default, since it was just some experiments I was doing. In an earlier incarnation of this particle system, I was doing so much aabb testing that it started to show up in my profiling, mostly because of all the branching that took place in the aabb functions. I used SSE to remove most of the branching that occurred, and it did give a speed boost as a result.


Return to “General Discussion”



Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests