Box2D Forums

It is currently Tue Sep 02, 2014 10:28 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Dec 04, 2012 2:01 am 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
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:
File comment: The patch
ps.patch [232.21 KiB]
Downloaded 152 times
Top
 Profile  
 
PostPosted: Tue Dec 04, 2012 3:59 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1935
Location: Tokyo
Nice work! Just looking at the patch file, seems like you were about to do fluids as well...?


Top
 Profile  
 
PostPosted: Tue Dec 04, 2012 7:46 pm 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
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:


Top
 Profile  
 
PostPosted: Tue Dec 04, 2012 11:44 pm 
Offline

Joined: Wed Jul 25, 2012 5:08 am
Posts: 53
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.


Top
 Profile  
 
PostPosted: Wed Dec 05, 2012 1:40 am 
Offline

Joined: Tue Sep 25, 2007 2:22 pm
Posts: 518
I see SSE optimizations and spatial hashing for the particles.


Top
 Profile  
 
PostPosted: Wed Dec 05, 2012 1:53 am 
Offline

Joined: Wed Jul 25, 2012 5:08 am
Posts: 53
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 1497 times ]
Top
 Profile  
 
PostPosted: Wed Dec 05, 2012 2:16 am 
Offline

Joined: Wed Jul 25, 2012 5:08 am
Posts: 53
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.. ).


Top
 Profile  
 
PostPosted: Fri Dec 07, 2012 1:49 am 
Offline

Joined: Sun Mar 28, 2010 11:58 am
Posts: 16
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group