PolygonShape not precise

Hey,
I'm starting with Box2d in Flash. Is there an option to get collisions directly with a movieClip or bitmap? I found no example. So I tried to programm a Class witch transforms movieClips directly while the runtime to a PolygonShape. It works fine, but the collision is extremly unprecise and other shapes "digging" through. What's the reason?
Example
Thanks for Tipps.
Best regards.
Clemi
Is this a single polygon? It's not a convex shape, so you would need to make it up from smaller convex polygons.
You could also use a chain/loop shape if it's enough just to have the outline of the shape.
Thank you for your hints. I changed my Landscape-Generation-Class to create seperated, smaller, convex polygons, but the Circle-Shapes already "digging" through the surface:
Example

Did I use the wrong paramters?

Ball/Charakter (Circle-Shapes):
Code:
         fixtureDef.density = 1;
         fixtureDef.friction = 0.1;
         fixtureDef.restitution = 0.1;
         fixtureDef.filter.categoryBits = 1;
         fixtureDef.filter.maskBits = 65535;
         fixtureDef.filter.groupIndex = 1;


Landscape (Polygon-Shape):
Code:
         fixtureDef.density = 2;
         fixtureDef.friction = 1;
         fixtureDef.restitution = 0.2;
         fixtureDef.filter.categoryBits = 1;
         fixtureDef.filter.maskBits = 65535;
         fixtureDef.filter.groupIndex = 1;


I will be glad for further hints.
Thank you very much.
Clemi
The fixture settings look fine. Are the polygon vertices given in counter-clockwise order?
I tried it in both directions. If I make it in CCW order, the "hill" is also out of "quicksand" 😀
Is there perhaps an other criteria (start with the lowest/highest point, or something else)?
Thank you,
Clemi
So in one case the hill part is ok (as it seems in the swf) and the flat part is bad, and if you reverse the winding these are the other way around? Are you sure you are getting the windings right for both areas?
Also, the circles do not seems to be colliding correctly, but maybe you have intentionally set it to be like that?
Is this showing the output from Box2D's debug draw?
Thank you sort your fast response. In the reverse chicle the flat part is also like quicksand. And correct: it shows the debug draw 🙁 I will try and test other forms to understand the problem. So stay interested 😀 Thanks a lot. Clemi
The flat (horizontal) parts are the only places the circles go weird and have that quicksand effect. The circles collide fine with the angled parts. How are you making the polygon shapes? There may be something that's making some parts in a weird way that would create that quicksand effect.
OK, i was wrong with my guess.

But i have similar question. I want to make compound object from rectangle, circle and triangle. But i have problem illustrated on this picture. Is it possible to make this working?

Image

I only added this code to original source to make a test.

Code:
circ.radius = 20 / m_physScale;
circ.density = 0.0;
circ.friction = 0.4;
circ.restitution = 0.3;
bd = new b2BodyDef();
bd.position.Set(2*((10*j) / m_physScale), (160 + 20*j) / m_physScale);
head = m_world.CreateBody(bd);
head.CreateShape(circ);
head.SetMassFromShapes();
box.density = 0.0;
box.friction = 0.4;
box.restitution = 0.3;
box.vertexCount = 3;
box.vertices[0].Set(0, 0);
z = Math.sqrt(2*Math.pow(20,2))/(2*m_physScale);
box.vertices[1].Set(z, 0);
box.vertices[2].Set(0,-z);
bd = new b2BodyDef();
bd.position.Set(2*((10*j) / m_physScale) + z, (160 + 20*j) / m_physScale);
head = m_world.CreateBody(bd);
head.CreateShape(box);
head.SetMassFromShapes();


Oops, it works fine when i draw triangle clockwise.

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