Jump to content
  • Advertisement
Sign in to follow this  
neoaikon

Box2d Lite, One corner sinking

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been messing with the box2d lite code and was trying to do something similar in my little C#.net program. I kept having a behaviour where one corner of my box would sink into my ground box, then suddenly pop back out, sometimes launching the box into the air. So I completely copied the Box2d Lite code line by line, and even though now there is basically no difference between the two, I still get the same behaviour of the sinking corners. I believe it is something to do with the position correction, because the other options have no effect, turning OFF position correction causes the box to usually rest on a corner, but no sinking. I'm unsure as to why the behaviour is so different, you can take a look at the source here Source Code below is a couple of screen grab of it occuring before the box get kicked into the air.

Share this post


Link to post
Share on other sites
Advertisement
I'm giving up on this, I cannot seem to get it to port over to C# correctly. It appears for whatever reason, that when resting flat on the ground, only one contact is being generated. so the second corner just passes through. I've check and rechecked, and can't spot the problem. So I'm just going to move to C++, I was easily able to port my nonworking code over to that, and it worked, so I'm at a loss as to what the issue is.

Share this post


Link to post
Share on other sites
There is another Box2D spin-off project called "Box2DX" which has already been ported to C#. I've only tried out their demo project though. Their demos didn't appear to have the corner-sinking issue like what you describe.

Share this post


Link to post
Share on other sites
Check your clipping code:

1) Which face is the reference face and which is the incident face
2) Is the clip polygon from the incident face correct
3) Are the clip planes from the reference plane correct (where point the normals)
4) Does the clipping work correctly

All these phases can easily be validated using some debug drawing. If you only get one contact something is wrong in you contact generation.


HTH,
-Dirk

Share this post


Link to post
Share on other sites
I'll take a look at it again tonight, the code is basically a line for line copy of the box2d lite code, including comments. I only really changed what I had to for C#, so it shouldn't be any different from the lite code.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!