# Large Tiled Maps And Box2D.

This topic is 1321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm using the libGDX Box2D implementation to create a rather large tiled map (i.e. ~5000m x 5000m). Originally, I was just creating all of the bodies without trying to limit them to a certain area around the player. This actually seemed to work fairly well, even though there are a very large number of tiles. But I've implemented a chunk system now so that only the 9 closest chunks have bodies assigned and, as the player moves around, old bodies are removed from the world. I'm getting random little errors with the native Box2D calls like this:

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x7d345da0, pid=13635, tid=2143865664

JRE version: Java(TM) SE Runtime Environment (8.0_20-b26) (build 1.8.0_20-b26)

Java VM: Java HotSpot(TM) Server VM (25.20-b23 mixed mode linux-x86 )

Problematic frame:

C  [libgdx-box2d.so+0x34da0]  b2World::Solve(b2TimeStep const&)+0x290


Sometimes the error is with initializing a body, and sometimes the error is with destroying a body, but they don't seem to be connected to missing body references or anything like that. I'm wondering if removing/adding large chunks of bodies from an even larger world is overwhelming the Box2D system. I've read that a world of this size should be alright, but I'm thinking I may be messing around with the world tree too much. Should I be leaving the bodies in place and just putting them to sleep or making them inactive instead of trying to actually remove them and rebuild them as the player walks around? Or should I be trying to combine them all into larger polygons, instead of keeping the individual tile bodies?

Any suggestions on a better approach in general would be appreciated. Thanks!

##### Share on other sites

Couldn't you store all of your large tile map in an outside source and only manipulate an array of say, 100X100? (you could pool whatever you need in the far reaches of that map once it becomes relevant and remove when not, which would minimize how much you rely on memory and refer to an actual file).

##### Share on other sites

Its important you mark the bodies only which you want to remove for this frame and remove it in the next frame, but before box2d´s update steps is called!

• 19
• 10
• 19
• 14
• 19