[Bug?] Exception in ModelDisplayObjectBatch.Remove
Posted: Sun May 15, 2011 7:07 am
I'm using a MorphableEntity with a CompoundCollision object. In order to force the InstancedModelDrawer to update the vertex information for my MorphableEntity, I'm removing the entity from the drawer, making my modifications and then adding it back in.
This works fine, but after doing that a few times (anywhere from 8 to 20 times usually), I get the following exception:
Here's the problematic code from ModelDisplayObjectBatch.cs:
The exception occurs on the line marked with "==>". What's happening is that at run time "displayObject.BatchInformation.BaseVertexBufferIndex" is greater than "vertices.Length - displayObject.BatchInformation.VertexCount".
Somewhere along the way something is getting messed up. I haven't yet been able to diagnose exactly where yet.
Norbo, is there anything off the top of your head that I may be doing wrong that would cause this? I'm debugging it now, but if you have some insight on where to look closer, it would be appreciated.
Thanks,
Twig
This works fine, but after doing that a few times (anywhere from 8 to 20 times usually), I get the following exception:
Code: Select all
ArgumentException: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
Code: Select all
public void Remove(ModelDisplayObjectBase 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);
//Copy the second part back (after the display object)
Array.Copy(vertices, displayObject.BatchInformation.BaseVertexBufferIndex + displayObject.BatchInformation.VertexCount,
newVertices, displayObject.BatchInformation.BaseVertexBufferIndex,
vertices.Length - (displayObject.BatchInformation.BaseVertexBufferIndex + displayObject.BatchInformation.VertexCount));
vertices = newVertices;
*snip*
}
Somewhere along the way something is getting messed up. I haven't yet been able to diagnose exactly where yet.
Norbo, is there anything off the top of your head that I may be doing wrong that would cause this? I'm debugging it now, but if you have some insight on where to look closer, it would be appreciated.
Thanks,
Twig