This project has moved and is read-only. For the latest updates, please go here.

Issue with static and non static objects

Topics: Developer Forum
Oct 4, 2009 at 5:51 AM

I have a player object (a triangle), that can have forces applied within a single screen display.  A number of random static triangles are placed within the confines of the screen.  The player object seems to quite often rotate through parts of the static triangles.

If I make the static triangles non-static, and a massive mass, then things effectively work "fine", no points go inside other points.

Is there a common mistake I am making conceptually?

Oct 4, 2009 at 9:10 PM

You are experiencing the triangle interpenetrates the other triangles? That is "normal".

If you are using the distance grid narrow phase collider (default one), you need to adjust the resolution of the distance grid (collisionGridCellSize). It is one of the arguments when you pass the triangle vertices to the GeomFactory.Instance.CreatePolygonGeom() method.

Triangles are also hard to use because they can have a very small angle (narrow triangle) and thus they don't work too good with the distance grid. If the grid cell size thing don't work. Try using adding more vertices along the sides of the triangle (near the angles) or use the SAT narrow phase collider.

Oct 5, 2009 at 12:18 PM

Thanks for the response,

I am using the SAT narrow phase collider and when I make the triangles I am colliding my "player" triangle with non static, then there is no penetration of points, and they "bounce" correctly.  Is there a very simple mistake that is common, or am I probably guilty of some subtle bit of bad programming on my part?


Oct 5, 2009 at 12:58 PM

There is a bug in SAT that causes some weird behavior. You can try using the distance grid instead. The SAT bug will probably not be fixed until version 3.0 comes out.

Oct 5, 2009 at 1:05 PM

Is the bug with penertrating triangles in SAT for non static on static only?
It has occered to me that i have only ever tested it in that senario... so perhaps it might be...

If so would it be a performance optimization for statics that is the cause?
If so would making the object ignore gravity and have infinate mass work? or will this cause issues?

"Im on my phone now otherwise i would try it"

Oct 5, 2009 at 1:13 PM

The new SAT implementation goes crazy in the test Matt made in AdvancedSamples - and because I'm about to release and I got no answer from Matt, I have to include the old implementation. I received 2 patches to fix some bugs with static geometries in the old SAT implementation - I'm not sure those got included, so I'm finding that out now.

I can see some static geometry checks in the new code that is commented out. It might have been some performance checks.

Oct 5, 2009 at 1:24 PM

I should probably tell you that the SAT in the svn is leagues ahead of the SAT in the current release... The SAT in the svn is not only many times faster (Under some cercomstances) but it also seems to be able to create more stable physics simulations.
It seems like a bit of a waste to not include the new sat implimenation, maybe both could be included somehow? So there would be DistanceGrid, SAT and ExperimentalSAT?

I dont know just my thoughts.

Oct 5, 2009 at 1:32 PM

I would rather have a stable SAT implementation that is slow than a fast unstable implementation. SAT performance is not very high at the moment - if I change the pyramid sample to use SAT, i get a 400% slowdown compared to the distance grid. SAT is great for constantly changing geometries (that includes breakdowns/decomposition) but the distance grid still beats it in performance.

The support on SAT is non-existing right now. I am unable myself to support it mainly because I have not worked with SAT that much and I'm constantly running low on time. I will try to contact some people and see if they would like to help out. Otherwise the new SAT implementation will be thrown out.

By the way, do you have a sample that has the static triangle problem? I would like use it as a test.

Oct 6, 2009 at 1:13 AM

Hi everyone, sorry I haven't been able to finish the new SAT implementation, I've been super busy moving and working at my new job. I hope to have time to help soon as my life settles down a little.

Oct 6, 2009 at 1:17 AM

That would be amazingly awesome, the new implimentation is very very fast and good but just has a few small issues...

Oct 6, 2009 at 1:18 AM

Great to hear from you Matt. I know you have been busy with moving and all but I really have to release a new version soon. I've asked Andrew Russel to take a look at the new SAT implementation and see if he can work something out. I'll wait a little before releasing - It would be a shame to let your hard work go to waste. It is not easy fitting a SAT narrow phase algorithm into an engine never designed to have such a thing.

I will let you know if Andrew comes up with something and be sure to keep me posted on any updates. :)

Oct 7, 2009 at 7:50 AM

I'd be willing to look at the SAT implementation as well, if that would help. I haven't tried the latest patches so I'm not familiar with what sort of issues there are in the latest implementation. Can anyone describe the issues or what portion of the code is likely the culprit?