crash using debug drawer

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Posts: 14
Joined: Wed Mar 18, 2015 12:36 am

crash using debug drawer

Post by Nablabla » Mon Mar 30, 2015 3:19 pm

hi, i run into an ArgumentOutOfRangeException in line 135 of ModelDisplayObjectBatch.cs

Code: Select all

        public void Remove(ModelDisplayObject displayObject, InstancedModelDrawer drawer)
            //Modify vertex buffer
            var newVertices = new VertexPositionNormalTexture[vertices.Length - displayObject.BatchInformation.VertexCount];
            //Copy the first part back (before the display object)
            Array.Copy(vertices, 0, newVertices, 0, displayObject.BatchInformation.BaseVertexBufferIndex); <----- here
when I try to remove an object from the DebugDrawer like this:

Code: Select all

This only happenes when I put so much things into the DebugDrawer that he does not draw all of them any more.
The value of displayObject.BatchInformation.BaseVertexBufferIndex is then -65248

The value got set to that negative value some lines underneath:
where BaseIndexBufferIndex is zero and IndexCount is somewhat huge

Code: Select all

//Move the subsequent display objects list indices and base vertices/indices.
            for (int i = displayObject.BatchInformation.BatchListIndex; i < DisplayObjects.Count; i++)
                DisplayObjects[i].BatchInformation.BaseVertexBufferIndex -= displayObject.BatchInformation.VertexCount;
                DisplayObjects[i].BatchInformation.BaseIndexBufferIndex -= displayObject.BatchInformation.IndexCount;
                System.Diagnostics.Debug.Assert(DisplayObjects[i].BatchInformation.BaseVertexBufferIndex >= 0);


Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: crash using debug drawer

Post by Norbo » Mon Mar 30, 2015 5:36 pm

This sounds like a problem with an object being added which is larger than the 16 bit indices of the drawer permit. There does appear to be some missing validation to catch this, though I'm hesitant to spend any time on this due to the impending full rewrite (the demos are going to drop XNA pretty soon).

Post Reply