X-Hax / sa_tools

Sonic Adventure Toolset
http://info.sonicretro.org/SA_Tools
101 stars 24 forks source link

SADXLVL2 crashes after I save, close and reopen #175

Closed TeridaxXD001 closed 2 years ago

TeridaxXD001 commented 3 years ago

When I save a level after working on it, close the program, reopen the program and load the same level that I had open without any problems mere seconds earlier, SADXLVL2 crashes. This is what I get: Program: SADXLVL2 Build Date: 03/05/2021 06:06:40 OS Version: Microsoft Windows NT 10.0.19041.0 Log: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at SonicRetro.SAModel.SAEditorCommon.DataTypes.LevelItem.Render(Device dev, EditorCamera camera, MatrixStack transform) in D:\Programs\sa_tools\SAEditorCommon\DataTypes\LevelItem.cs:line 130 at SonicRetro.SAModel.SADXLVL2.MainForm.DrawLevel() in D:\Programs\sa_tools\SADXLVL2\MainForm.cs:line 1662 at SonicRetro.SAModel.SADXLVL2.MainForm.panel1_Paint(Object sender, PaintEventArgs e) in D:\Programs\sa_tools\SADXLVL2\MainForm.cs:line 1804 at System.Windows.Forms.Control.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.UserControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I would like to add that SALVL seems to open said file just fine.

PiKeyAr commented 3 years ago

Is this reproducible on the latest version? SADXLVL2 and SALVL were merged into one tool back in April.

TeridaxXD001 commented 3 years ago

Yes.

Program: SALVL Build Date: 06/19/2021 08:43:27 OS Version: Microsoft Windows NT 10.0.19041.0 Log: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at SonicRetro.SAModel.SAEditorCommon.DataTypes.LevelItem.Render(Device dev, EditorCamera camera, MatrixStack transform) in D:\Programs\sa_tools\SAEditorCommon\DataTypes\LevelItem.cs:line 133 at SonicRetro.SAModel.SALVL.MainForm.DrawLevel() in D:\Programs\sa_tools\SALVL\MainForm.cs:line 1711 at System.Windows.Forms.Control.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.UserControl.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I can open it by ignoring the opening prompts and manually sellecting Open>Landtable... but when I save it and reopen via the opening prompt, same problem. For clarity: I'm editing Speed Highway Act 3 by loading in a new Land Table. I can load the specific file, but picking "Speed Highway Act 3" from the map list crashes the program.

ItsEasyActually commented 3 years ago

This issue seems to pertain to level textures or materials.

When you say you're using a "new LandTable," do you mean one that was exported by the Blender addon by chance? If yes, have you updated that addon within the last month?

To specify, the addon had a material error that would cause various types of issues with invalid data, and was known to cause crashes in game and in the editors IIRC. That issue was fixed within the last 30 days.

TeridaxXD001 commented 3 years ago

I used the Blender add-on, but I only installed it on the 16th.

By the way, if I start a new project, open the vanilla Speed Highway 3, clear all data, import the new geometry from the original OBJ file, and then try to select the starting point, I get this: Program: SALVL Build Date: 06/19/2021 08:43:27 OS Version: Microsoft Windows NT 10.0.19041.0 Log: System.IndexOutOfRangeException: Index was outside the bounds of the array. at SonicRetro.SAModel.Direct3D.Mesh`1.CheckHit(Vector3 Near, Vector3 Far, Viewport Viewport, Matrix Projection, Matrix View, Matrix transform, NJS_OBJECT model) in D:\Programs\sa_tools\SAModel.Direct3D\Mesh.cs:line 351 at SonicRetro.SAModel.SAEditorCommon.DataTypes.LevelItem.CheckHit(Vector3 Near, Vector3 Far, Viewport Viewport, Matrix Projection, Matrix View) in D:\Programs\sa_tools\SAEditorCommon\DataTypes\LevelItem.cs:line 125 at SonicRetro.SAModel.SALVL.MainForm.PickItem(Point mouse, Item& item) in D:\Programs\sa_tools\SALVL\MainForm.cs:line 2210 at SonicRetro.SAModel.SALVL.MainForm.panel1_MouseDown(Object sender, MouseEventArgs e) in D:\Programs\sa_tools\SALVL\MainForm.cs:line 2115 at System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.UserControl.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

ItsEasyActually commented 3 years ago

The second one doesn't surprise me it gets messed up. Assimp (our import/export handler) is not that great and does some weird stuff.

When you used the Blender addon, did you correct all of the materials, ie press the Update Materials button so it would apply the SAShader to all of the materials? If you didn't, try that and see if it'll at least open then. Beyon that, the only way I'll be able to help is by seeing the file at this point. It sounds like a file issue rather than an issue with the tool itself.

PiKeyAr commented 3 years ago

The CheckHit error suggests you might be hitting the model format's per-model vertex count limit. A single model cannot have more than 32767 vertices. This limit applies both to the game and the tools using this model format. Also, there are two ways to import geometry. If you were using the "To Stage" option, it was importing all geometry in the OBJ file as a single level item, which may have hit the vertex limit.

Anyway, this kind of speculation is rather useless without looking at the files involved.