Number of verticies per Polygon

Jan 24, 2010 at 10:09 PM

The current limit is 8.

How big a difference does FixedArray8 actually make, over using a list or array? What would be the best way to raise this limit?

Jan 24, 2010 at 10:27 PM

On Xbox360 it makes a pretty big difference, overall switching from List<T> to FixedArray8<T> gave us about a 20% performance boost if I recall correctly.

This is mainly because the Xbox360 has a really bad version of the CLR in terms of garbage collection, so reducing garbage gave us huge perf wins.

Raising the limit should be trivial if you really need to (keep in mind that a Body can be made up of multiple fixtures, each with 8 vertices).  Just bump the setting which is set to 8 and switch references to FixedArray8<T> to List<T> or make FixedArrayX<T> for the size you want.  For sizes greater than 8 you will likely start to run into CPU overhead of copying huge structs around so switching to List<T> and incurring the garbage might actually be better.

If you are only planning on using this for Windows then switching to List<T> is the obvious choice, the CLR on Windows is generational and can handle tons of grabage per second unlike the Xbox 360 (also theh CPU bound nature of the engine means that most PC's will simply process a frame faster).

Jan 25, 2010 at 12:09 AM

I've switched to this from Farseer. While farseer has a much nicer front end, and a more C#-like interface, it's not up to date, and the next version in their repo is basically box2d.xna anyway. Your port does run much faster on the 360.


I need to break up concave polygons anyway, I think I will handle this issue at the same time, and just limit the max points in the ear-clipping algorithm to 8.


With the box2d forum down, it's hard to get information. Does Box2D (and this port) still suffer from the thin-triangle problems of the older versions?

Jan 25, 2010 at 12:23 AM

I'm not familiar witht he thin-triangle problem, what was that?  Is it something we could try to reproduce?

In general for an iterative physics engine having really thin bodies can be problematic.  Between iterations a fast moving object may teleport through a thin body simply because it's translation for that frame is larger than the width of the body in question.  Things like isBullet and upping the maxVelocityIterations and maxPositionIterations in World.Step could help (or also you could constrain b2_maxTranslation and scale things down quite a bit), but that may not be related to what you are talking about.

Jan 25, 2010 at 12:26 AM

I'm not sure about the thin triangle issue you speak of.  Box2D.XNA should behave exactly the same as the latest Box2D from googlecode, so it's probably easiest to ask on there forum.  The main index is down for me too, but I can hit the inner pages.  Try this:


Jan 25, 2010 at 4:08 AM

It happens when the polygon centroid is closer to the edge of the polygon than box2d's slop value.