How to do curved walls in a top view racing game.

Hi everyone, I have a little problem in a top view racing game. I’m actually developing with Box2d and I would like suggestions from the community to find the best possible solution.

I’m providing the file LoopRider.h that goes in the Erin Catto’s testbed so you can see the problem in execution.

Context : I’ve made a level editor in 3dsMax to create race tracks for Box2d, the plugin create a series of rectangles from a spline to create a wall, this way we can make a complex network of race tracks very fast.

The problem : if the car grinds a wall in a curve, the car sometimes kinda “bumps” on a rectangle’s corner even if the vertex of the following rectangle has the same position!?!

Here is the result of my observation :
1- I’ve made sure that each rectangle that follows another have their vertex at the same position (until the 5th decimal)
2- The turning rectangle in the test (the looprider) will bump at different speeds. The speed only changes the frequency of the bumping: faster looping seems to bump less often.

Questioning :
1- Is there a way to avoid the looprider bumping on the rectangle corner?
2- Is there something better that I missed in Box2d to do walls than a series of rectangles? (don’t forget I’ve put a great deal of effort creating my plugin to manage the race track creation with the spline-to-rectangle technique)

Any advise would be greatly appreciated!
I tried this with a recent SVN version off of Google code and it works fine. I suggest using 2-vertex polygons instead of boxes for better performance.
Hi Erin and thank you for your fast reply.

Without knowing it you gave me a lot of job! I'm using Box2d.2.0.1 with Boris b2TensorDamper controller (wich work perfectly for my needs). So since yesterday I’m updating to the latest version of box and to do so I need to adapt
1- my API (that was almost finish)
2- my Editor.
3- the controllers
Everything is looking good for now except for the controllers. (still need to digest all these changes and figure out where is the old data and how I can access it now)

I will tell you my results as soon as I finish. I just really hope all these changes will fix my “bumping” problem 😉
4 days later,

I'm done adapting the latest box2d svn version Revision 23 (2.1.0) but now I can see very weird collision behaviour.

Observation :
1- In the testbed, in every tests, all objects go through the edges!?
2- In Dominos test for example, the dominos pass through the rectangle they start on but collide with the other ones (but fall through the ground edge in the end)
3- I made a dead simple test with only 2 rectangles, I validate they are in the same category and their mask collide with everything but the falling rect pass righth through the ground rect!?

Context :
- I had to adapt the svn box2d probject to VC6 (like I did with 2.0.1) because I'm working on old plateform consoles that use several libraries that are not VC8 compatible. (the main thing I had to adapt are the template declarations, but I didn't touch any algo in itself)
***- I tested and saw that everything is working right in VC8 so my downgrade to VC6 is really where the problem is, if your willing, I uploaded the box2d 2.1.0 revision 23 project I converted to VC6 so you can use a merge tool to see the changes I made. They are pretty simple and straight forward and I think someone who know box better than me will see easily if I made something wrong. (due to the 256k limit of file I upload the project in two seperate .zip.)

The Version 2.1.0 concept of edges and fixtures really rocks but right now I can't figure whats I might have done wrong in the conversion of the project.

Any help will be greatly appreciated!
Xaimav,

Thanks for following my advice. However, I think it is quite a stretch to ask me to debug your port. This is something you'll have to sort out yourself.

I hope you figure it out.
Xaimav, I've just taken Version 2.1.2 and converted it to compile on VS6. The conversion was quite minimal, I inlined the UpdatePairs/Query/RayCast functions to please the compiler as you did and get exactly the same problem. Did you solve the problem, any help you can give me would be appreciated.

Stu
solved

I was being lazy, as there wasn't much to change to make it compile under VS6, all it took was a little snooping around the mods. Here it is.

The problem was the bodge to overcome the "error C2374: 'i' : redefinition; multiple initialization" problem in the first while loop in b2BroadPhase::UpdatePairs(), I had simply commented out "int32 i = 0;" to get it through compilation which I now realize was affecting another peice of codes variable 'i'. A better bodge is to rename it to something that doesn't clash, I renamed 'i' to 'i2', the chunk of code in b2BroadPhase::UpdatePairs() that changes now reads:
Code:
      // Send the pairs back to the client.
      int32 i2 = 0;
      while (i2 < m_pairCount)
      {
         b2Pair* primaryPair = m_pairBuffer + i2;
         void* userDataA = m_tree.GetUserData(primaryPair->proxyIdA);
         void* userDataB = m_tree.GetUserData(primaryPair->proxyIdB);

         callback->AddPair(userDataA, userDataB);
         ++i2;

         // Skip any duplicate pairs.
         while (i2 < m_pairCount)
         {
            b2Pair* pair = m_pairBuffer + i2;
            if (pair->proxyIdA != primaryPair->proxyIdA || pair->proxyIdB != primaryPair->proxyIdB)
            {
               break;
            }
            ++i2;
         }
      }

even simpler, you could also have just put the chunk of code in it's own scope by wrapping the code in {...}, but I thought of that just!

Original thread: https://box2d.org/forum/viewtopic.php?t=3933