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
...
Code: Select all
DebugDrawer.Remove(_morphableRigidBody);
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);
}