BRLYT : Fix removing texture maps.

This commit is contained in:
KillzXGaming 2020-10-10 13:07:48 -04:00
parent a22557b18c
commit 5f9493839e
3 changed files with 26 additions and 2 deletions

View file

@ -2470,6 +2470,12 @@ namespace LayoutBXLYT
return false;
}
public virtual void RemoveTexture(int index)
{
if (index < TextureMaps.Length)
TextureMaps = TextureMaps.RemoveAt(index);
}
public virtual BxlytMaterial Clone()
{
return (BxlytMaterial)this.MemberwiseClone();

View file

@ -88,6 +88,24 @@ namespace LayoutBXLYT.Revolution
return mat;
}
public override void RemoveTexture(int index)
{
base.RemoveTexture(index);
if (TexCoordGens.Count > index)
TexCoordGens.RemoveAt(index);
if (IndirectTexTransforms.Count > index)
IndirectTexTransforms.RemoveAt(index);
if (TextureTransforms.Length > index)
TextureTransforms = TextureTransforms.RemoveAt(index);
RemoveTexCoordSources(index);
Console.WriteLine($"TexCoordGens {TexCoordGens.Count}");
Console.WriteLine($"TextureMaps {TextureMaps.Length}");
Console.WriteLine($"TextureTransforms {TextureTransforms.Length}");
Console.WriteLine($"IndirectTexTransforms {IndirectTexTransforms.Count}");
}
public override bool RemoveTexCoordSources(int index)
{
foreach (var texGen in TexCoordGens)

View file

@ -364,14 +364,14 @@ namespace LayoutBXLYT
{
if (ActiveMaterial.TextureMaps.Length > SelectedIndex && SelectedIndex >= 0)
{
ActiveMaterial.TextureMaps = ActiveMaterial.TextureMaps.RemoveAt(SelectedIndex);
ActiveMaterial.RemoveTexture(SelectedIndex);
//Apply to all selected panes
foreach (BasePane pane in ParentEditor.SelectedPanes)
{
var mat = pane.TryGetActiveMaterial();
if (mat != null && mat != ActiveMaterial && mat.TextureMaps?.Length > SelectedIndex)
mat.TextureMaps = mat.TextureMaps.RemoveAt(SelectedIndex);
mat.RemoveTexture(SelectedIndex);
}
}