Stupid Triangle

Topics: User Forum
Jun 23, 2009 at 1:20 AM
Edited Jun 23, 2009 at 1:21 AM

You'd think I'd figure this out by now, but I have a geom that keeps on getting into places it shouldn't, and I've been modifing values and it still keeps on getting in there:

What was once I little triangle is now:

            Vertices verts = new Vertices();
            // added extra verts to eliminate 120degree edges
            verts.Add(new Vector2(0, 20));
            verts.Add(new Vector2(0, 19)); 
            verts.Add(new Vector2(9.4f, 0));
            verts.Add(new Vector2(10.6f, 0));
            verts.Add(new Vector2(20, 19)); 
            verts.Add(new Vector2(20, 20));
            graphicsCenter = verts.GetCentroid();
            verts.Translate(graphicsCenter);

            baseBody = BodyFactory.Instance.CreatePolygonBody(verts, 1000);
            baseBody.LinearDragCoefficient = 480f;
            baseBody.RotationalDragCoefficient = 40000f;
            verts.SubDivideEdges(.7f);

            // the natural collision grid cell size is 2, but there was issues.
            baseGeom = GeomFactory.Instance.CreatePolygonGeom(baseBody, verts, .9f);

As you can see, I blunted the endges of the triangle, I've subDivided the edges by a large portion, and I've reduced the CollisionGridCellSize, and I still get the little f'er sliding into things.  Any advice folks? 

Developer
Jun 24, 2009 at 2:24 AM

Is it sliding into things easily? Also why such a small body with such a huge mass? If you send me a Demo of your problem I'd be glad to help.  mattbettcher@gmail.com

Jun 24, 2009 at 3:05 AM
Edited Jun 24, 2009 at 3:13 AM

Is the mass too much?  I just kind of play with numbers until they all feel right together.

The little triangle slides into things 1 out of every 10,000 instances, which drives me nuts.  Because I think I've solved it, upload it, test it for an hour, everything ok, then I play it again for fun and it happens.

It definitely happens when it goes in head first at hi speed.  BOY!  It just happened to me twice in a row, I will send you a video tommorow. 

I suppose I'm just looking for a direction on what to change, either make the verts less triangly, subdivide the verts more, or decrease collisiongridcellsize more.  It is sort of hard to debug when something happens 1 in 10,000 and you're guessing at what needs to be changed.  What's best in the case of my object?

(haven't seen the problem on FP2.1 btw, but I have other issues with it)

Coordinator
Jun 24, 2009 at 3:08 AM
Edited Jun 24, 2009 at 3:16 AM

Did you get my mail about the latest bugfixes? Cloning did not work correctly in 2.1, it will be fixed in the bugfix release 2.1.1 - coming soon.

Edit: Your problem (in this thread) might be because of tunneling. A triangle can easily tunnel because its nose is made of one point and it's very narrow at the point. We will have CCD in Farseer Physics Engine 3.0 that will prevent tunneling - until then can look at some of the alternatives listed in the manual.

Edit2: Your values are quite high. You could scale everything by a factor of 100. I don't think that they are the cause of your problem. Large mass ratios can give instabilities when a constant force is applied (like gravity), but after i've played your game I don't think it will be a problem.

Jun 24, 2009 at 4:37 AM
Edited Jun 24, 2009 at 4:38 AM

I think i know why those valuse are very high: if they aren't then the geometry will shoot off at the slightest force. I suspect it's because he (and me) is not setting the MOI.

Jun 24, 2009 at 1:29 PM

It looks like both my problems went away with the latest version of the code you have there genbox.  Do you think scaling will find it's way back in?

Coordinator
Jun 24, 2009 at 5:51 PM

Scaling will work again in 2.1.1, I'm going to take a look at it today.

Jun 24, 2009 at 6:27 PM

There used to be a donate link, what happened to that?

Coordinator
Jun 24, 2009 at 6:36 PM
Edited Jun 24, 2009 at 6:44 PM

Actually never thought of that... Jeff added a donate link a while back. I don't know what happened with it or if he just gave it up. I know that codeplex support some kind of donation system. I've not tried any donation system before and I'm not sure if it is worth it.

Might take a look at it in the near future, I know there are some people who really want to give back to the project, but are not able to contribute code. (might be new to programming or developing on a closed-source project) It would be great to have a beer now and then donated by the community. ;)

Edit: Seems like Codeplex only support advertisements from "The Lounge". Donations could be done via third-party systems.

Jun 24, 2009 at 6:58 PM

There used to be a donate link that was from Amazon.com.  I searched for it, but it doesn't work anymore.  I'd donate again if something was up.

Coordinator
Jun 24, 2009 at 11:27 PM
Edited Jun 24, 2009 at 11:28 PM

Just to try it out I've created a PayPal donate link on the frontpage. I'm thinking about creating a donations wiki page where we can list those who donated and their amount (if they wish to be included of course). I donated 200 dkk (~36 US dollars) to wikipedia last year and I was proud to be on the donations list. Others might feel different about it tho.

Coordinator
Jun 24, 2009 at 11:59 PM

Just had a look at the scaling controller. Used your game to test it, I hope you don't mind.

It should be fixed now and you just have to add the following lines to GameManager.cs:

ScalingController cont = new ScalingController(.001f, .01f);
cont.UpdateInterval = .001f;
cont.MaximumUpdateInterval = .001f;
Simulator.ControllerList.Add(cont);

It's fixed in the latest source control checkin.

Jun 25, 2009 at 3:28 AM

Is that working linking?  If so I'd be happy to donate.  And yeah, put my name on something why the heck not?  People can opt out of that if they want to, but I think if somebody sees a list of people who have donated they might be more inclined to donate.

Coordinator
Jun 25, 2009 at 5:34 PM

I've made a donations list in the wiki. You can reach it by clicking the link on the front page. I would have tested the system to see if I can see the names of those who donated, but apparently I can't donate because I use my email for the PayPal account.

I guess that if you donate, you will be the first tester. Thanks for bringing this up by the way. I'm sure that Matthew like myself, appreciate any donations made to this project.