Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am developing a small racing gam, the track is generated from a curve.

As said above, the track is generated, but not infinite. The track of one level could fit with no problem in memory and will contain a reasonably small amount of triangles.

For collisions, I would like to use Bullet physics engine and know what is the best way to handle collisions with the track efficiently.

NOTE : The track will be stored as a static rigid body (mass = 0). The player will be represented by a sphere shape for collisions.

Here is some possibilities i have in mind :

  1. Create one rigid body, then, put all triangles of the track (except non collidable stuff) into it. Result : 1 body with many triangles (eg : 30000 triangles)

  2. Split the track into several sections (eg: 10 sections). Then, for each section, create a rigid body and put corresponding triangles in it. Result : small amount of bodies with relatively small amount of triangles (eg : 1500 triangles per section).

  3. Split the track into many sub-sections (eg : 1200 sections). Here one subsection = very small step when generating the curve. Again for each sub-section, create a body and put triangles in it. Result : many bodies with very small amount of triangles (eg : 20 triangles). Advantage : it could be possible to "extra data" to each of the subsection, that could be used when handling collisions.

  4. Same as 2, but only put sections N and N+1 in physics engine (where N = current section where the player is). When player reach section N+1, unload section N and load section N+2 and so on... Issue : harder to implement, problems if the player suddenly "jump" from one section to another (eg : player fly away from section N, and fall on section N + 4 that was underneath : no collision handled, player will fall into void )

  5. Same as 4, but with many sub-sections. Issues : since subsections are very small there will be constantly new bodies added and removed to physics engine at runtime. Possibilities for player to accidently skip some sections and fall into the void are higher than 4.

share|improve this question
BvhTriangleShape should handle the whole track mesh properly, it was made for cases like this. The documentation even suggests you put all triangles into as few triangle mesh shapes as possible. You should try that and switch to something else only if there are problems. –  snake5 Nov 6 '12 at 8:54
Thanks for suggestion. I already think about "code, profile and try something else if it dont work well". However, testing all possibilities take time and i prefer to ask here before, with hoping that somes would discard immediately some of theses suggestions. I was also hoping that somebody here work on a similar game (with generated track or not) that use a physical engine and how he does it. –  tigrou Nov 6 '12 at 9:50
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.