World Lists in FP3

Topics: Developer Forum, User Forum
Aug 12, 2010 at 6:01 AM
What happened to the World Lists in FP3 (JointList, BodyList, etc)? I used to be able to do a "if (world.BodyList.Contains(body))", and now I can't. I'm sure there was a reason to go away from using actual lists, but I'm not sure I know why that is. I'm not a good enough programmer to understand why that changed. Can someone enlighten me?
Aug 12, 2010 at 4:28 PM

I would really like to go back to the lists instead of using linked lists as we do now. Problem is that the simulation changes it's outcome if I change it to use lists - and I have no idea why.

I created a post on Box2D forums asking what could be wrong, but it seems I'm not the only one puzzled about why the outcome changes. I suspect that the sequence of the bodies also changes, but I can't find out where when reading the code. I need to do a lot more debugging to find out why this happens, and if it is solvable, I will go back to using lists.

For now you will have to use the linked lists. Simply create a while or for loop that fetches body.Next until it reaches a null value.

Aug 13, 2010 at 1:40 PM
Good news (I think...). I discovered that the linked lists are traversed backwards - compared to the order that the bodies are created in. I reversed a single for loop and now the simulation is just as before. This means we can use array (List<>) instead of linked lists. It is a lot easier to use lists if you ask me.
Aug 13, 2010 at 7:54 PM
I agree. The linked lists are not very intuitive. This is good news! P.S. Moving from a June 12 build to the current gets me much better reacting items. My blocks stack better now than they did before (without sleeping).
Aug 13, 2010 at 9:46 PM
Could you try out changeset 75483? I've optimized it a bit and I get 30% improvement in the pyramid - both on PC and Xbox360
Aug 14, 2010 at 12:11 AM
Edited Aug 14, 2010 at 12:15 AM
Hmm, actually I get very slow pyramid performance on 75483 compared to the June 12 version I had. My current PC is on the lower end, but it used to run it well enough. I'm getting about 1FPS until they sleep.
Aug 14, 2010 at 12:22 AM
What changeset from june 12 are you using?
Aug 14, 2010 at 1:42 AM
67409 appears to be the one I was using. The pyramid blocks never sleep, but they load a ton faster and it gets a lot better FPS etc. My CPU is a Intel Prescott 2.8Ghz HT, and I have 2GB ram. I have a ton loaded right now, but I just grabbed that revision again seperately to verify and it is definitely better performing for me. I'll try them on my laptop tonight maybe and see if its noticeable. Not sure what the differences are. That being said, I can tell other things in the newer revisions are faster. It might just be my CPU being a bottleneck.
Aug 14, 2010 at 12:02 PM
That is an very old revision and I've updated Box2D several times since then. The loading might be because of the data caching I implemented in shapes. I suggested that Box2D did the same (see issue here: But to do so, it requires density to be a part of the shape. I will check the differences between the engines to see what exactly is causing the performance difference.
Aug 14, 2010 at 12:18 PM
I ran both revisions and the new one is both faster and more stable on my computer. See screenshot of it here:
As you can see it takes around 13000 ticks on the new and around 17000 ticks on the old. The old does not handle contacts well (bug) and thus the stacking ability is greatly reduced. Are you sure it was 67409?
Aug 14, 2010 at 9:06 PM
Yeah, I get between 1 million and 70 million ticks with the new version, which is like 1 FPS. The old simulation gets better ~5-10 fps (although I couldn't get the new debug panel working). The old one is definitely much less stable, though, it was just an observation which made me curious. You must be running a new Intel i7 :P.
Aug 15, 2010 at 7:01 PM

Something is very very wrong if you get up to 70 million ticks. I'm running it on a server with 2xXeon 2.33 Ghz. (But using one core only). The thing is I also get a lot better performance on Xbox360. I will test it again later today.

Aug 20, 2010 at 8:20 PM

Are you by any chance running the TitlesTest instead of the PyramidTest? The title test does also contain a pyramid, but it also creates A LOT of static tiles.

Aug 23, 2010 at 4:39 AM

Actually yes,  I noticed that but forgot to mention it because I was slightly embarrassed to :).  While I do get better performance on the PyramidTest than the TilesTest, it still wasn't as fast as it was as that older revision.