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

_aabb.Width used in grid's vertical size calculation in Grid.cs

Topics: Developer Forum, Project Management Forum
Oct 2, 2008 at 6:42 PM
I added an issue about this under the Issue Tracker yesterday, but I'm not sure if those are looked at.

There's a simple bug in line 62 of Grid.cs in FarseerGames.FarseerPhysics.Collisions.
_aabb.Width is used to derive the grid's vertical size. _aabb.Height should be used.
This is causing an index out of range exception when accessing the _nodes array when two objects collide.

Current code:
int ySize = (int)Math.Ceiling((double)_aabb.Width * _gridCellSizeInv) + 1;

Corrected code:
int ySize = (int)Math.Ceiling((double)_aabb.Height * _gridCellSizeInv) + 1;

Oct 2, 2008 at 6:51 PM
Edited Oct 2, 2008 at 6:52 PM
Oh no! There is was!
Thanks for spotting that! I can't believe I did'ent see it, I had the problem just after releasing 2.0 Alpha. I could not figure out why it took such a long time to generate the grid (compared to normal) and why it had an index out of range exception.

I reverted the grid.cs code back to the version the 29 september, I forgot to update the alpha releases.

EDIT: I do not receive email notifications on issues. I will look at it more often in the future.