Fun with MSTerrain. Assert error?

Topics: Developer Forum
Apr 14, 2011 at 10:34 PM

I had another discussion going on and was pointed to a destructable terrain demo.  I want to use the ideas located in here to replace my current level with my little hackings into farseer with something like this destructable terrain.  So I was using the ground as defined in the car sample. but now I am using MSTerrain with the same Terrain.png file.  Though when I add the few lines of code to my project, I get a Debug.Assert error:

 public void Add(Contact contact) { 
Debug.Assert(ContactCount < _contactCapacity);
_contacts[ContactCount++] = contact;

The error is that the ContactCount and _contactCapacity is both 32.  If I comment out this Debug.Assert things work well, or at least seem to.  I can only "see" my terrain if I turn on debug view.  How can i draw a texture thats based off my terrain texture right over it that follows rules of camera etc.

This is the one thing thats vexing me, oh and any ideas why I triggered the assert?  I literrally didn't do much to my code just added to SimpleDemo7.cs:


private MSTerrain _terrain;
public void LoadContent()
     _terrain = new MSTerrain(World, new AABB(new Vector2(100, 0), 80, 80))
                PointsPerUnit = 10,
                CellSize = 50,
                SubCellSize = 5,
                Decomposer = Decomposer.Earclip,
                Iterations = 2,


 private void StartUpTerrain()
            Texture2D texture = ScreenManager.Content.Load<Texture2D>("Samples/Terrain");

            _terrain.ApplyTexture(texture, new Vector2(400, 0), InsideTerrainTest);


private bool InsideTerrainTest(Color color)
       return color == Color.Black;