1
0
mirror of synced 2025-02-26 06:49:45 +01:00

GFBMDL : Fix removing existing mesh nodes on model import.

This commit is contained in:
KillzXGaming 2019-12-21 14:27:39 -05:00
parent 7c396674f0
commit e2499bd864

View File

@ -173,11 +173,24 @@ namespace FirstPlugin
public ToolStripItem[] GetContextMenuItems() public ToolStripItem[] GetContextMenuItems()
{ {
List<ToolStripItem> Items = new List<ToolStripItem>(); List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new ToolStripMenuItem("Save", null, SaveAction, Keys.Control | Keys.S));
Items.Add(new ToolStripMenuItem("Export Model", null, ExportAction, Keys.Control | Keys.E)); Items.Add(new ToolStripMenuItem("Export Model", null, ExportAction, Keys.Control | Keys.E));
Items.Add(new ToolStripMenuItem("Replace Model", null, ReplaceAction, Keys.Control | Keys.R)); Items.Add(new ToolStripMenuItem("Replace Model", null, ReplaceAction, Keys.Control | Keys.R));
return Items.ToArray(); return Items.ToArray();
} }
private void SaveAction(object sender, EventArgs args)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = Utils.GetAllFilters(this);
sfd.FileName = FileName;
if (sfd.ShowDialog() == DialogResult.OK)
{
STFileSaver.SaveFileFormat(this, sfd.FileName);
}
}
private void ExportAction(object sender, EventArgs args) private void ExportAction(object sender, EventArgs args)
{ {
SaveFileDialog sfd = new SaveFileDialog(); SaveFileDialog sfd = new SaveFileDialog();
@ -377,9 +390,8 @@ namespace FirstPlugin
} }
} }
Dictionary<string, int> NodeIndices = new Dictionary<string, int>();
//Go through each bone and remove the original mesh node //Go through each bone and remove the original mesh node
List<STBone> bonesToRemove = new List<STBone>();
for (int i = 0; i < Model.Skeleton.bones.Count; i++) for (int i = 0; i < Model.Skeleton.bones.Count; i++)
{ {
//Reset bone as rigid //Reset bone as rigid
@ -398,13 +410,9 @@ namespace FirstPlugin
} }
} }
if (Model.GenericMeshes.Any(x => x.Text == node.Text)) if (Model.GenericMeshes.Any(x => x.Text == node.Text)) {
{ bonesToRemove.Add(node);
if (!NodeIndices.ContainsKey(node.Text))
NodeIndices.Add(node.Text, i);
Model.Model.Bones.Remove(node.Bone); Model.Model.Bones.Remove(node.Bone);
Model.Skeleton.bones.Remove(node);
} }
/* if (Model.Model.CollisionGroups?.Count != 0) /* if (Model.Model.CollisionGroups?.Count != 0)
@ -420,6 +428,11 @@ namespace FirstPlugin
}*/ }*/
} }
foreach (var bone in bonesToRemove)
Model.Skeleton.bones.Remove(bone);
bonesToRemove.Clear();
Model.Model.CollisionGroups = new List<CollisionGroup>(); Model.Model.CollisionGroups = new List<CollisionGroup>();
List<int> skinningIndices = Model.GenerateSkinningIndices(); List<int> skinningIndices = Model.GenerateSkinningIndices();