Rolling weel/box character penetrates flat ground

Apr 13, 2012 at 11:16 PM

Here's my story...

I've got a 2D platformer type world that is drawn in a paint program.  In my pipeline, I do a texture to vertices, and then decompose the resulting polygons to get convex polygons, which I use to create static bodies.  This works just fine.

I have a character which is a wheel attached to a rectangular body, with a motor joint.  I can roll around left or right and jump just fine.  Everything is great.

Then I go an I update my map, and now there is a section of floor that makes my character act all wonky.  Basically, I can be rolling along, and all of a sudden the rectangular body gets kind of sucked into the floor, but the wheel doesn't.  The rectangular body goes haywire and vibrates all over the place.

Here is a link to some screenshots.

https://picasaweb.google.com/114399753612766377114/Farseer?authuser=0&authkey=Gv1sRgCOXUntOcxsK5hgE&feat=directlink

This isn't an issue with "seams" between bodies on a seemingly flat surface.  This actually is a wheel rolling across the flat part of a polygon body.  The screenshots are the result of the DebugView output, so you can very clearly see where the seams are.

Any ideas?

Apr 14, 2012 at 8:49 PM

Here's a video


http://youtu.be/oKNg0Ivq3sY

Apr 14, 2012 at 9:15 PM

Sorry, one more post...

My original plan has each of the decomposed polygons as a separate body.  So the landscape was made up of multiple bodies.  I just tried creating a CompoundPolygon from this list of vertices, and that appears to have fixed the problem.  Does that make any sense?

Apr 15, 2012 at 11:59 AM

Hi, great game hiding in plain sight btw :)

Did you debug for rogue vertices/normals? Looks to me like a wrong normal on those faces.

Also it's probably related to this:

http://box2d.org/forum/viewtopic.php?f=3&t=3048&start=0

That's why Erin Catto made loop shapes which remove ghost vertices. It's quite an ingenious solution but it's still an ad-hoc solution. Perhaps when you made them compound it was better since there was no more always-on contact between the bodies making the terrain so collision calculations end up different.

Apr 15, 2012 at 3:53 PM

Ha!  Thanks!  I didn't expect to be "recognized" here.  :)  I'm quite pleased with the response that Hidden in Plain Sight has gotten.  It's a fun little game.  :)

My problem appears to be solved.  My first iteration was using the vertices returned by the texture to physics stuff to create loopshapes.  That worked. 

Then, I wanted to introduce lighting and shadows (using the Krypton 2D lighting engine... heaven forbid I should actually write my own code!)  That required convex polygons, so I turned used the Bayezit decomposition to get a bunch of convex polygons, which I added as individual static bodies.  That resulted in the weirdness in the video.  Seemed to happen mostly on long horizontal edges.

Then, rather than having a bunch of individual polygons, I created a CompoundPolygon instead, using the list of vertices.  That appears to have solved the problem.

So... I can proceed forward with my work and there is no longer an issue.  But I bring it up in case someone else is having the same sort of issue.

Adam