Fix adjusting vertex attribute buffer indices when one is removed.

This commit is contained in:
KillzXGaming 2020-03-18 19:21:52 -04:00
parent c36eb67acf
commit dc96965440

View file

@ -117,6 +117,11 @@ namespace FirstPlugin.Forms
if (result == DialogResult.Yes)
{
var attriubte = attributeListView.SelectedItems[0];
if (attriubte.Text == "_p0")
{
MessageBox.Show("Cannot remove position attribute! You should remove a mesh instead or hide by materials.");
return;
}
for (int att = 0; att < activeShape.vertexAttributes.Count; att++)
{
@ -124,7 +129,17 @@ namespace FirstPlugin.Forms
if (CurrentAttribute.Name == attriubte.Text)
{
var buffer = CurrentAttribute.BufferIndex;
activeShape.vertexAttributes.Remove(CurrentAttribute);
//Check if the index is no longer used for any attribute
if (!activeShape.vertexAttributes.Any(x => x.BufferIndex == buffer))
{
foreach (var attr in activeShape.vertexAttributes)
if (attr.BufferIndex > buffer)
attr.BufferIndex -= 1;
}
attributeListView.Items.Remove(attriubte);
}
}