Took a look at this today--just from the outside, no internals--and wanted to report my observations. I've only skimmed the other posts, so this stuff might be irrelevant.
1) The objects seem to float upward pretty well and spin, but don't seem to be pushed left or right. Why is this?
2) I noticed an odd bug. If you use any sort of circle shape (can test easily with the bomb) the circle turns into a sort of teleport that sends particles that come in contact with it into the center of the map, in a ring shape, corresponding to where they came in contact with the circle. Here's a screenshot:
3) I ran some performance tests and it seems pretty speedy to me. I ran an optimized release build on VC++ and profiled with both precise and fast floating point operations. What I found is that the test spends more than 50% of its time in the applyLiquidConstraint function, mainly in the pressure and neighbors loops. 13% of the 50% is spent on this line:
(I moved vlen[a] out to see if it was a memory access issue.)
The interesting part is that the bottleneck isn't in the Box2D code. To improve performance further, you'll have to reduce the number of times applyLiquidConstraint is called, the number of iterations per loop, or organize the memory layout better to avoid cache misses.
4) You seem to have forgotten to post FluidDefs.h. Only seems to be missing b2Random. (I spent a good while trying to figure out why I only saw one dot. Apparently rand() / RAND_MAX isn't very random. *headdesk*)
Anyway, this thing is awesome so far. I'll see if I can help in few days maybe.
1) The objects seem to float upward pretty well and spin, but don't seem to be pushed left or right. Why is this?
2) I noticed an odd bug. If you use any sort of circle shape (can test easily with the bomb) the circle turns into a sort of teleport that sends particles that come in contact with it into the center of the map, in a ring shape, corresponding to where they came in contact with the circle. Here's a screenshot:
3) I ran some performance tests and it seems pretty speedy to me. I ran an optimized release build on VC++ and profiled with both precise and fast floating point operations. What I found is that the test spends more than 50% of its time in the applyLiquidConstraint function, mainly in the pressure and neighbors loops. 13% of the 50% is spent on this line:
Code: Select all
float factor = oneminusq * (pressure + presnear * oneminusq) / (2.0f*len);(I moved vlen[a] out to see if it was a memory access issue.)
The interesting part is that the bottleneck isn't in the Box2D code. To improve performance further, you'll have to reduce the number of times applyLiquidConstraint is called, the number of iterations per loop, or organize the memory layout better to avoid cache misses.
4) You seem to have forgotten to post FluidDefs.h. Only seems to be missing b2Random. (I spent a good while trying to figure out why I only saw one dot. Apparently rand() / RAND_MAX isn't very random. *headdesk*)
Anyway, this thing is awesome so far. I'll see if I can help in few days maybe.