ME3Tweaks / LegendaryExplorer

Editor toolset for Mass Effect Trilogy and Mass Effect Legendary Edition
https://me3tweaks.com
GNU General Public License v3.0
125 stars 28 forks source link

StaticMeshComponent Error After Cloning and Adding Multiple Actors in LE2 #388

Open Hinciab opened 1 year ago

Hinciab commented 1 year ago

Describe the bug In LE2, when cloning and adding multiple StaticMeshActors to a cloned StaticMeshCollectionActor in let's say BioA_Nor_300, an error occurs when attempting to select either of these StaticMeshActors in the Package Editor.

To Reproduce The game is LE2 and the BioA_Nor_300 can be either from the Unofficial LE2 Patch or Basegame, the BioA_Nor_305 can be basegame or from DLC_METR_Patch01 both has the same issue but i will use the basegame BioA_Nor_305.

Go to the Engineering deck in the normandy so you will have bioa_nor_300 loaded.

First of all let's use the file BioA_Nor_300. Open it. Then open BioA_Nor_305 pcc. It's all package editor.

In BioA_Nor_305 pcc look for StaticMeshCollectionActor_977. Grab that CollectionActor and drag it into the PersistentLevel in Nor_300. Select the second option to add only StaticMeshCollectionActor_977. After that save the Nor_300 pcc. Remove the StaticMeshComponents property, add back the property so you now have 0 in the list and save.

Let's go back to BioA_Nor_305 and from StaticMeshCollectionActor_977 copy the StaticMeshActor_820_SMC and drag it under the StaticMeshCollectionActor_977 in BioA_Nor_300. Clone all references. Then add it to the StaticMeshComponent list. Save the BioA_Nor_300 PCC.

In-.game go to main menu, reload the savefile, then open the live level editor (LE2) choose BioA_Nor_300 and click Snap To Player. We gonna snap the StaticMeshCollectionActor_977:StaticMeshActor_820_SMC what we've just added.

Click in the bottom in the Level Editor to Update saved position, rotation, and scale of selected actor. Save the PCC (BioA_Nor_300).

Now let's go back to BioA_Nor_305 and again look for StaticMeshCollectionActor_977 but this time copy the StaticMeshActor_829_SMC with all references and add it under the StaticMeshCollectionActor_977 that we have added to BioA_Nor_300.

Hit save in Nor_300. Select the StaticMeshCollectionActor_977 in Nor_300 and try to add another StaticMeshComponent to the array so now you should have 2. The first one is the StaticMeshActor_820_SMC in Item 0 and now enter the newly imported one the StaticMeshActor_829_SMC so it will be Item 1.

Now save the pcc, and if you try to choose either of them in the package editor it will throw the error.

Expected behavior The Package Editor should allow selecting either StaticMeshActor_820_SMC or StaticMeshActor_829_SMC without any issues, i think but i might be wrong.

Screenshots and files used to replicate this https://drive.google.com/file/d/1i-Q3CaOXpsaEzaAIhEb3hyqUvH4Zce7O/view?usp=sharing

This pcc already has the issue after i did the reproduction steps above.

Version information: 6.3 nightly 7/12/2023

Stack trace EndOfStreamException: Unable to read beyond the end of the stream. at System.IO.BinaryReader.InternalRead(Int32 numBytes) at LegendaryExplorerCore.Gammtek.IO.EndianReader.ReadSingle() in D:\a\1\s\LegendaryExplorer\LegendaryExplorerCore\Gammtek\IO\EndianReader.cs:line 355 at LegendaryExplorerCore.Unreal.BinaryConverters.SCExt.Serialize(SerializingContainer2 sc, Matrix4x4& matrix) in D:\a\1\s\LegendaryExplorer\LegendaryExplorerCore\Unreal\BinaryConverters\StaticCollectionActor.cs:line 115 at LegendaryExplorerCore.Unreal.BinaryConverters.StaticCollectionActor.Serialize(SerializingContainer2 sc) in D:\a\1\s\LegendaryExplorer\LegendaryExplorerCore\Unreal\BinaryConverters\StaticCollectionActor.cs:line 22 at LegendaryExplorerCore.Unreal.BinaryConverters.ObjectBinary.From[T](ExportEntry export, PackageCache packageCache) in D:\a\1\s\LegendaryExplorer\LegendaryExplorerCore\Unreal\BinaryConverters\ObjectBinary.cs:line 20 at LegendaryExplorerCore.Unreal.BinaryConverters.StaticCollectionActor.TryGetStaticCollectionActorAndIndex(ExportEntry component, StaticCollectionActor& staticCollectionActor, Int32& i) in D:\a\1\s\LegendaryExplorer\LegendaryExplorerCore\Unreal\BinaryConverters\StaticCollectionActor.cs:line 51 at LegendaryExplorer.UserControls.ExportLoaderControls.CollectionActorEditorExportLoader.LoadExport(ExportEntry exportEntry) in D:\a\1\s\LegendaryExplorer\LegendaryExplorer\UserControls\ExportLoaderControls\CollectionActorEditorExportLoader.xaml.cs:line 99 at LegendaryExplorer.Tools.PackageEditor.PackageEditorWindow.Preview(Boolean isRefresh) in D:\a\1\s\LegendaryExplorer\LegendaryExplorer\Tools\PackageEditor\PackageEditorWindow.xaml.cs:line 3675

Other information

Mgamerz commented 1 year ago

I haven't reproduced your steps but if you remove the property but do not clear the binary you may get this error - the properties and binary must be kept in sync for this class as the amount of items in the properties is also used to determine how much binary data to read. Though from your description it would be reverse; if you removed binary but not properties it would try to read beyond the end of the stream.

SirCxyrtyx commented 1 year ago

The issue here is that the StaticMeshCollectionActor keeps information about its children in two places, and you have only updated one, leading it to be malformed. If you open the BinaryInterpreter tab for that export you will see that it contains a translation matrix for only one StaticMeshComponent. If you select all the bytes from 6C until the end in the hex box, then copy and paste to the end, then click Save Hex Changes at the top, that will fix the file.

This is obviously a less than ideal user experience! And it's definitely not your fault for not intuiting this. One thing that can make working with StaticMeshCollections easier is that if you clone an existing StaticMeshComponent (via the right click menu), LEX will take care of updating the StaticMeshCollectionActor for you. You may find it simpler to just clone an existing one and then edit the properties than to drag in one from another file and have to manually hex edit.