Hello,
Context:
I'm making a game with an horizontal scrolling.
When the game scrolls, the next part of the world may be needed. World parts are called "tracks". Their width is 3 screen large.
I have a limited number of tracks, maybe 100, but the world itslef has no limits since a new track is picked as soon as needed.
The tracks use many b2EdgeShape (with adjacency) to represent the ground. Generaly about 100 edges per tracks, but my maximum is 275 b2EdgeShape. (the ground looks like a bezier spline)

My goal is to get the shortest CPU usage when a new track is added.
Current technic used:
All the tracks and their ground bodies are created at loading time. The bodies are deactivated.
When a track is needed, its body is moved to the correct position and activated.
When a track is no longer needed, its body is deactivated and is left at its current position.
(the same track is never used 2 time in a row)
Issue:
Activating the body may take quite some time when there is a lot of edge shapes.
The screenshot track has 270 edges and takes 11ms just to activate the body in release mode.
I use a Q6600 2.4 Ghz. Windows evaluation : 5.0
Box2D revision 131.
My mesurement may be wrong though.
Questions:
Does anyone know a better strategy that this one ?
Would you make something completly different ?
Thanks !
Context:
I'm making a game with an horizontal scrolling.
When the game scrolls, the next part of the world may be needed. World parts are called "tracks". Their width is 3 screen large.
I have a limited number of tracks, maybe 100, but the world itslef has no limits since a new track is picked as soon as needed.
The tracks use many b2EdgeShape (with adjacency) to represent the ground. Generaly about 100 edges per tracks, but my maximum is 275 b2EdgeShape. (the ground looks like a bezier spline)

My goal is to get the shortest CPU usage when a new track is added.
Current technic used:
All the tracks and their ground bodies are created at loading time. The bodies are deactivated.
When a track is needed, its body is moved to the correct position and activated.
When a track is no longer needed, its body is deactivated and is left at its current position.
(the same track is never used 2 time in a row)
Issue:
Activating the body may take quite some time when there is a lot of edge shapes.
The screenshot track has 270 edges and takes 11ms just to activate the body in release mode.
I use a Q6600 2.4 Ghz. Windows evaluation : 5.0
Box2D revision 131.
My mesurement may be wrong though.
Questions:
Does anyone know a better strategy that this one ?
Would you make something completly different ?
Thanks !