Beginner: Getting going.

First post to this forum. Been lurking for a few days.

Just starting to work with JBox2D and am finding it to be quite robust. I have a couple generic questions and a quick search of the forum yielded no (comprehensible) answers to these questions.

Question 1: I am stressing this library as much as possible. I was wondering if I am reaching the limits of what JBox2D can handle, or if it is just because perhaps I am building my project in a less-than-optimal way.
"Caused by: java.lang.ArrayIndexOutOfBoundsException: 2147483647
at org.jbox2d.collision.PairManager.addPair(PairManager.java:115)"


http://www.vimeo.com/1757516

I get this error if I throw in about 1500 to 2000 circles. Is that pretty much the state of things, or is there a way to deal with this limitation?

Question 2: Just starting to use the ContactListener. Was wondering, is there a way to find out if a body is being touched by another body? So far, all I have managed is to get a list of contact points. Ideally, I would just be able to say something like if( body.isColliding ) or something similar.

http://www.vimeo.com/1798697

Anyhow, thanks in advance and I am looking forward to learning this library properly so I can have much more control. I am already impressed quite a bit.

-robert
For your first question, look at settings and increase the number of pairs and proxies.
It seems I am hitting the upper limit of int? So raising the maxProxies wouldn't actually help in this situation, right? I tried doubling maxProxies and cranking up the particle count, but it still bails at 2147483647.
flight404 wrote:
It seems I am hitting the upper limit of int? So raising the maxProxies wouldn't actually help in this situation, right? I tried doubling maxProxies and cranking up the particle count, but it still bails at 2147483647.

Whoa, I didn't notice that. ummmm it looks like you've hit some sort of limitation i can't help you with... This is not a library meant for doing what it looks like you're doing.

That said, I don't know how ~2000 bodies can cause any proxies/pairs number near 2 billion.

I would say the library should handle ~2000 circles at near interactive framerates. At least i'm pretty sure it would on my 4Ghz Core 2... Perhaps less so in JBox2d than the regular C++ version. And I have set the proxies and pairs count to insane values in the past (over a hundred thousand at least) with no ill effects.
Which is what I expected to hear. I figured I was probably doing something wrong. Still trying to grasp the Body vs. BodyDef vs. PolygonDef vs. PolygonShape vs. etc. Just getting used to how things work.
Any chance you can post an example that reproduces this? I know Ive run into it before and solved it, but I don't remember the cause off the top of my head. It's not that you're actually overflowing an int or anything, it's caused by something else (double delete or something).
I got past the 2000 particle limit. I upped the proxies and pair and made sure when I spawned the initial particles, there was little-to-no overlap.
You might want to try printing/displaying the proxy/pair counts during the simulation so you can see what happens to the values while you're stress testing. I was planning to do this for my program at some point when i go to figure out what I want to set my max values to.
Dude, you need to change the broad phase overlap detection to use spatial hashing. You could acheive real time results. I know because I had a friend who was able to get 1500 fully 3d asteroids running in his game with a constant 100 fps framerate.
Well if you want a retarded amount of bodies you'd be looking at GPU acceleration... Wasnt there some CUDA demos that had 60k bodies? in 3d?

Original thread: https://box2d.org/forum/viewtopic.php?t=1506