Sorry for the multiple replies. It would appear the problem is in the for loops that generate the vertices. At least on my machine, anyway...
TerrainProcessor.cs:
// Create the individual triangles that make up our terrain.
for (int y = 0; y < heightfield.Height - 1; y++)
{
for (int x = 0; x < heightfield.Width - 1; x++)
{
AddVertex(builder, texCoordId, heightfield.Width, x, y);
AddVertex(builder, texCoordId, heightfield.Width, x + 1, y);
AddVertex(builder, texCoordId, heightfield.Width, x + 1, y + 1);
AddVertex(builder, texCoordId, heightfield.Width, x, y);
AddVertex(builder, texCoordId, heightfield.Width, x + 1, y + 1);
AddVertex(builder, texCoordId, heightfield.Width, x, y + 1);
}
}
I found that I could fix this problem by, oddly enough, dividing the heightfield.Height and heightfield.Width variables by 1.01f . Why this works...? I have no idea. lol. My best guess is that maybe it tries to create too many verts without the division??? I'm just getting off of a lunch break, so I don't have any more time to mess with it. But I thought you would like to know that you can run the demo by simply changing the for loop to :
// Create the individual triangles that make up our terrain.
for (int y = 0; y < heightfield.Height / 1.01f - 1; y++)
{
for (int x = 0; x < heightfield.Width / 1.01f - 1; x++)
{
AddVertex(builder, texCoordId, heightfield.Width, x, y);
AddVertex(builder, texCoordId, heightfield.Width, x + 1, y);
AddVertex(builder, texCoordId, heightfield.Width, x + 1, y + 1);
AddVertex(builder, texCoordId, heightfield.Width, x, y);
AddVertex(builder, texCoordId, heightfield.Width, x + 1, y + 1);
AddVertex(builder, texCoordId, heightfield.Width, x, y + 1);
}
}
It appears on my end that you don't even have to change the portion of the code that makes the collision areas...so I'm guessing the terrain generated is very close to the original.
Hope this helps!