X-Hax / sa_tools

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

SADXLVL2. After importing a new level model I get this. #154

Closed Maxx-Light closed 3 years ago

Maxx-Light commented 3 years ago

It happens when I try to click on any object.

Program: SADXLVL2 Build Date: 02/10/2021 07:46:54 OS Version: Microsoft Windows NT 10.0.19042.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 122 at SonicRetro.SAModel.SADXLVL2.MainForm.PickItem(Point mouse, Item& item) in D:\Programs\sa_tools\SADXLVL2\MainForm.cs:line 2355 at SonicRetro.SAModel.SADXLVL2.MainForm.panel1_MouseDown(Object sender, MouseEventArgs e) in D:\Programs\sa_tools\SADXLVL2\MainForm.cs:line 2260 at System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e) at System.Windows.Forms.UserControl.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.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)

PiKeyAr commented 3 years ago

I need a level or a model file causing the issue to be able to investigate it.

Maxx-Light commented 3 years ago

I need a level or a model file causing the issue to be able to investigate it.

Ok, here it is. Stage.zip

PiKeyAr commented 3 years ago

The models in the landtable have more than 32767 vertices. An individual model must have less than 32767 vertices to work in the editor. The same limitation applies to the actual game. You'll need to reduce the number of vertices in these models to be able to import them.

Maxx-Light commented 3 years ago

The models in the landtable have more than 32767 vertices. An individual model must have less than 32767 vertices to work in the editor. The same limitation applies to the actual game. You'll need to reduce the number of vertices in these models to be able to import them.

So the whole level must contain less than 32767 vertices right? Is it possible to expand limitation somehow?

ItsEasyActually commented 3 years ago

The issue is you have a model that has over the limit of vertices allowed. It's a per model limitation, not per stage.

You will need to break that model into smaller models. It's likely the model already wouldn't play nice with the game's collision if it had that many vertices.

Maxx-Light commented 3 years ago

Emerald Coast.zip

The issue is you have a model that has over the limit of vertices allowed. It's a per model limitation, not per stage.

You will need to break that model into smaller models. It's likely the model already wouldn't play nice with the game's collision if it had that many vertices.

Ok, now it doesn't crash, and it's maybe a 3276 and not 32767, or I misunderstood it somehow. TY now it works, but all surface isn't solid, and I keep falling through it. In SADXLVL2 all objects have a solid flag.

PiKeyAr commented 3 years ago

I looked at the landtable and noticed some of the larger objects don't have a solid flag Also, the game's collision system may have difficulties processing complex shapes and high poly geometry. The recommended way is to have a separate layer of invisible collision objects that are made of the simplest shapes possible (see the levels in the original game for examples).

ItsEasyActually commented 3 years ago

To add to the above comment, there's a rough "size" limitation when it comes to in-game landtable objects regarding their collision. I'm not sure what the rough estimate is unfortunately, but after a certain size, the collision will simply fail to work correctly. This usually results in random spots where there's no collision even if the object is visible. Generally try to keep landtable objects sized about the same as would be seen in a level from the base game.

Also did you export this from the Blender addon by chance? If you did, you'll need to use the Calculate Bounds feature in SADXLVL2 after opening it. Unfortunately the Blender addon doesn't get bounding spheres correct at the moment and that also causes collision issues.

Maxx-Light commented 3 years ago

To add to the above comment, there's a rough "size" limitation when it comes to in-game landtable objects regarding their collision. I'm not sure what the rough estimate is unfortunately, but after a certain size, the collision will simply fail to work correctly. This usually results in random spots where there's no collision even if the object is visible. Generally try to keep landtable objects sized about the same as would be seen in a level from the base game.

Also did you export this from the Blender addon by chance? If you did, you'll need to use the Calculate Bounds feature in SADXLVL2 after opening it. Unfortunately the Blender addon doesn't get bounding spheres correct at the moment and that also causes collision issues.

Thanks!

I've tried the Blender add-on, but it crushes when I'm trying to export this level.

ItsEasyActually commented 3 years ago

Did it crash or did it error? If it crashed, it may be worth opening an issue on the Blender Addon's Github.

If all it did was error, make sure you're saving to the C drive. The addon is limited to saving to the C drive at the moment.

Also I'm going ahead and closing this issue as the core of the issue has been cleared up. If something else pops up, feel free to re-open this issue or open a new one.