diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs
index 9cfe0739..841eff4c 100644
--- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs
+++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs
@@ -1,3 +1,4 @@
+using Lumina.Data.Parsing;
using OtterGui;
using Penumbra.GameData;
using Penumbra.GameData.Files;
@@ -161,6 +162,13 @@ public partial class ModEditWindow
if (ImportKeepAttributes)
MergeAttributes(newMdl, Mdl);
+ // Until someone works out how to actually author these, unconditionally merge element ids.
+ MergeElementIds(newMdl, Mdl);
+
+ // TODO: Add flag editing.
+ newMdl.Flags1 = Mdl.Flags1;
+ newMdl.Flags2 = Mdl.Flags2;
+
Initialize(newMdl);
_dirty = true;
}
@@ -210,6 +218,29 @@ public partial class ModEditWindow
}
}
+ /// Merge element ids from the source onto the target.
+ /// Model that will be updated. >
+ /// Model to copy element ids from.
+ private static void MergeElementIds(MdlFile target, MdlFile source)
+ {
+ var elementIds = new List();
+
+ foreach (var sourceElement in source.ElementIds)
+ {
+ var sourceBone = source.Bones[sourceElement.ParentBoneName];
+ var targetIndex = target.Bones.IndexOf(sourceBone);
+ // Given that there's no means of authoring these at the moment, this should probably remain a hard error.
+ if (targetIndex == -1)
+ throw new Exception($"Failed to merge element IDs. Original model contains element IDs targeting bone {sourceBone}, which is not present on the imported model.");
+ elementIds.Add(sourceElement with
+ {
+ ParentBoneName = (uint)targetIndex,
+ });
+ }
+
+ target.ElementIds = [.. elementIds];
+ }
+
private void RecordIoExceptions(Exception? exception)
{
IoExceptions = exception switch {