ArrayIndexOutOfBounds from jBox2d when trying to create bodies with joints

112 views
Skip to first unread message

scurv...@gmail.com

unread,
Jun 15, 2012, 12:19:43 PM6/15/12
to pl...@googlegroups.com
Ok, I'm kind of at a lose for what is happening and I'm hoping someone can help point me in the direction of my problem.

I'm getting the following error when I'm trying to create a chain to attach two bodies.  It only happens randomly, so I can create and destroy the chain a number of times just fine but I eventually get the error.  It doesn't seem like it's due to not cleaning up either because at times it will happen right away and other time it will take a while.

Exception in thread "AWT-EventQueue-0"
java.lang.ArrayIndexOutOfBoundsException: 74
       at org.jbox2d.dynamics.Island.add(Island.java:423)
       at org.jbox2d.dynamics.World.solve(World.java:976)
       at org.jbox2d.dynamics.World.step(World.java:560) 

That line in the Island.add() method is where it is trying to add a joint to the Island's array of joints.
I create the chain based on a touch event.
Initially I tried to create it "slowly" and I was using the update() method on an entity to add more links (this seemed wrong but I couldn't think of another way to handle this easily).  I ran into this error so I changed it to create the entire chain on the initial touch event and still randomly got the error.

Any help would be appreciated.

Philip Rogers

unread,
Jun 15, 2012, 12:43:30 PM6/15/12
to pl...@googlegroups.com
You may want to try the Box2D forum here:

I found some nice undocumented gotchas dealing with convexity and NPEing if I got it wrong. JBox2d can be finicky :)

Philip
Reply all
Reply to author
Forward
0 new messages