Polygon physics problems

Aug 8, 2008 at 5:32 AM

I've created a plus-shaped block using the Polygon BodyFactory, and it interacts well enough with circles and squares, but for some reason will simply not work with other objects of the same type.
Two cross-shaped bodies using the same vertex set go through each other.

 

vertexSet =

new Vertices();

 

vertexSet.Add(

new Vector2(0, 28));

 

vertexSet.Add(

new Vector2(0, 46));

 

vertexSet.Add(

new Vector2(27, 46));

 

vertexSet.Add(

new Vector2(27, 75));

 

vertexSet.Add(

new Vector2(48, 75));

 

vertexSet.Add(

new Vector2(48, 46));

 

vertexSet.Add(

new Vector2(75, 46));

 

vertexSet.Add(

new Vector2(75, 28));

 

vertexSet.Add(

new Vector2(48, 28));

 

vertexSet.Add(

new Vector2(48, 0));

 

vertexSet.Add(

new Vector2(27, 0));

 

vertexSet.Add(

new Vector2(27, 28));

 

vertexSet.SubDivideEdges(500);

Aug 8, 2008 at 7:09 PM
Try changing the timestep, But... Ive never used SubDivide, but im pretty sure that it should be lower than the max edge youve already got. Try changing it to something like: 7 and it should work
Coordinator
Aug 9, 2008 at 12:20 AM
As Treacles said, try turning down the value in SubDivideEdges(). As I understand it, SubDivideEdges() divides an edge from (example) 400 pixels in length into 400 divided by let's say 10. So 500 should only be used when you have some very big polygons. I could be wrong on this.

If that does not solve your problem, you could try setting a collision grid size that is smaller than the default.
Aug 9, 2008 at 3:09 AM
Thank you for the input.
I've tried to lower the subdivide edges count, and it didn't work. Again, there is only a collision problem between two crosses, and the collision works fine between a cross and a square or a circle for instance.
Aug 9, 2008 at 2:47 PM
Hmmmmm, ill try to recreate your shape on BlitzMax and then see how it turns out... Ill tell you if it works for me
Aug 9, 2008 at 11:19 PM
Nope, It seems the Plus shape is pretty fucked up lol... Ive even tried making it pretty huge but it doesnt work?
Aug 10, 2008 at 11:28 PM
Just noticed that all my Polygons are doing it lol?
Coordinator
Aug 11, 2008 at 2:48 AM
I have not tried the provided polygon shape by the original poster, but I wanted to show there there is nothing wrong with a polygon that is formed as a plus sign.
I do know about the problem of polygons sliding into each other, but it does not seem to be the case with the plus signs.

Here is a picture of one of my games with some quickly made plus signs:
http://img526.imageshack.us/my.php?image=plusfarseernc7.png

The reason I did it in the game was that I just provide it with a picture of a plus sign, and it will convert it into a farseer object with a texture. It was the easiest.
Aug 11, 2008 at 7:33 PM
Hmmmm, Have you changed Collision properties? Cos on my one i could change anything to have like 400 vertices, be half the size of the page and they still slip in as if there was only basic Vertices...

Also, what game is that???
Coordinator
Aug 12, 2008 at 11:58 AM
This is my settings:

PhysicsSimulator = new PhysicsSimulator(new Vector2(0, 150));
PhysicsSimulator.MaxContactsToDetect = 5;
PhysicsSimulator.MaxContactsToResolve = 2;
PhysicsSimulator.Iterations = 10;
PhysicsSimulator.BiasFactor = .4f;

If I remember correctly, It's the same settings as the demoes from Farseer.

The game is something i build upon the Farseer demoes with the "spider" (the claw in my game).
I've taken the spider, made it into a claw on a crane. The game is about collecting ingredients for diffrent recipes. It's a childrens game.

 

Aug 12, 2008 at 9:30 PM
Well, It has physics so you should post it to FM Eventually...
Coordinator
Aug 12, 2008 at 10:41 PM
What is FM?
Aug 12, 2008 at 11:00 PM
Fun-Motion?
Coordinator
Aug 13, 2008 at 1:16 AM
Oh, okay. Did not know about that one. Looks fun.