Page 1 of 1

crash using debug drawer

Posted: Mon Mar 30, 2015 3:19 pm
by Nablabla
hi, i run into an ArgumentOutOfRangeException in line 135 of ModelDisplayObjectBatch.cs
here:

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

DebugDrawer.Remove(_morphableRigidBody);
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.BatchListIndex--;
                DisplayObjects[i].BatchInformation.BaseVertexBufferIndex -= displayObject.BatchInformation.VertexCount;
                DisplayObjects[i].BatchInformation.BaseIndexBufferIndex -= displayObject.BatchInformation.IndexCount;
                System.Diagnostics.Debug.Assert(DisplayObjects[i].BatchInformation.BaseVertexBufferIndex >= 0);

            }
thx

Re: crash using debug drawer

Posted: Mon Mar 30, 2015 5:36 pm
by Norbo
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).