Farseer physics Texture to Body problem

First off heres what I’m doing:
I create a tilemap in Tiled, and one of the layers is the “collision mask”, I draw the collision mask onto a rendertarget/texture and pass it into a texture to body method(will post the method later in this post) and then it turns my mask into a polygon in which my player can now walk on, great!.

The problem:
I was using my actual tileset that should be drawn as the the graphic not the collision mask, which has a lot of ruff edges on the textures, I decided for maybe some extra performance I would create a mask(both pictures will be uploaded later in the post), once I set the collision mask as a actual collision mask I got an error in the farseer physics class “TextureConverter” “Nullable object must have a value.”. I decided to replace the collision mask back to the normal tileset, and it worked again, I then placed a break point where I got this error and changed back to the collision mask and it never gets called… The line is 395. The variable “polygonEntrance” is null but the Value part of it says the error message, so I’m decently sure its coming from this variable. I noticed when the texture doesn’t have anything actually on it I also get this error, but I can confirm that stuff is getting drawn.

Now for the pictures!
Collision mask:
Tile set:
make sure to click on the image before saving if you do choose to download

The texture to body(I am using the most up to date source code of farseer physics, however edited but all I did was made the classes needed for this method public in order to work) Code and method is from http://scott-franks.blogspot.com/2011/12/creating-farseer-physics-body-from.html however updated to tilesharp)

        public static Body LayerToBody(Texture2D texture, GraphicsDevice device, World world, float meterInPixels, string layer) {

        var polygonTexture = texture;

        var data = new uint[polygonTexture.Width * polygonTexture.Height];

        var verts = PolygonTools.CreatePolygon(data, polygonTexture.Width, true);

        //These 2 seem to work the best with tile maps
        verts = SimplifyTools.CollinearSimplify(verts);

        verts = SimplifyTools.DouglasPeuckerSimplify(verts, 0f);

        var list = BayazitDecomposer.ConvexPartition(verts);

        var vertScale = new Vector2(1f / meterInPixels);
        foreach (var vertices in list) {
            vertices.Scale(ref vertScale);

        //Create a body from the poly
        var body = BodyFactory.CreateCompoundPolygon(world, list, 1);

        return body;

Greatly appreciate anyone who is willing to help :smile:

Update: Everything is okay with the texture to body method, the problem is with my draw method, its not doing something right. When I use the collision mask it draws little lines, and the sourcerectangle seems to be misplaced.

internal class specialtile : Cludo_Engine.IDrawable{
    public TmxLayerTile tmxtile { get; set; }
    public TileMapInformation info { get; set; }
    public void Draw(SpriteBatch sb) {
        var destination = new Rectangle(
        tmxtile.X * info.TileWidth,
        tmxtile.Y * info.TileHeight,
        int gid = tmxtile.Gid;
        int tileFrame = gid - 1;
        int column = tileFrame % 100;
        int row = (tileFrame + 1 > 100) ? tileFrame - column * 100 : 0;
        Rectangle tilesetRec = new Rectangle(64 * column, 64 * row, 64, 64);
        sb.Draw(info.tileset, destination, tilesetRec, Color.White);
    public void AddToTarget() {

So tiled uses this thing called a “gid” which to my understanding is the number of the tile, if I have two spritesheets and the last tile on the first sprite sheet was #25 my gid on the first tile of the next sheet, is in fact, #26, I assumed it should be #1 again, therfore messed up my source rectangle and caused weird lines that farseer had no clue what to do with.