Restore tutorial return placement and source terrain collision eligibility

This commit is contained in:
UnixNight committed 2026-10-25 01:30:09 -04:00
1 parent ca08c468ba
commit 8d60a68511
36 files changed
+991 -69

No files matched your search

+17 -2
View File
@@ -39,11 +39,23 @@ public sealed record Mesh(MeshVertex[] Vertices, uint[] Indices)
var indices = root.GetProperty("indices").EnumerateArray().Select(p => p.GetUInt32()).ToArray();
if (indices.Length % 3 != 0 || indices.Any(i => i >= vertices.Length)) throw new InvalidDataException("Invalid scene triangle indices.");
if (vertices.Length == 0 || indices.Length == 0) throw new InvalidDataException("Empty scene mesh.");
// Level loaders omit NC-prefixed SHAPE names from terrain registration
// (LV1B44DD2F..44DD70). Material names and draw visibility are separate.
var shapeNames = new Dictionary<int, string>();
if (root.TryGetProperty("meshes", out var shapeMeshes))
foreach (var shape in shapeMeshes.EnumerateArray())
{
if (!shape.TryGetProperty("shapeId", out var id) || !shape.TryGetProperty("name", out var name)) continue;
var text = name.GetString() ?? "";
if (shapeNames.TryGetValue(id.GetInt32(), out var existing) && existing != text)
throw new InvalidDataException("Conflicting source shape names");
shapeNames[id.GetInt32()] = text;
}
var collisionPolygons = root.TryGetProperty("collisionPolygons", out var polygonList)
? polygonList.EnumerateArray().Select(p => new MeshPolygonSource(p.GetProperty("shapeId").GetInt32(),
p.GetProperty("polygonIndex").GetInt32(),
new Vector3(p.GetProperty("normal")[0].GetSingle(), p.GetProperty("normal")[1].GetSingle(), p.GetProperty("normal")[2].GetSingle()),
p.GetProperty("materialName").GetString())).ToArray() : [];
p.GetProperty("materialName").GetString(), shapeNames.GetValueOrDefault(p.GetProperty("shapeId").GetInt32()))).ToArray() : [];
if (collisionPolygons.Length != 0 && (collisionPolygons.Length != indices.Length / 3
|| collisionPolygons.Any(p => !float.IsFinite(p.Normal.X + p.Normal.Y + p.Normal.Z))))
throw new InvalidDataException("Invalid source collision polygon metadata");
@@ -84,7 +96,10 @@ public sealed record Mesh(MeshVertex[] Vertices, uint[] Indices)
}
}
public readonly record struct MeshPolygonSource(int ShapeId, int PolygonIndex, Vector3 Normal, string? MaterialName);
public readonly record struct MeshPolygonSource(int ShapeId, int PolygonIndex, Vector3 Normal, string? MaterialName, string? ShapeName = null)
{
public bool TerrainCollision => ShapeName?.StartsWith("nc", StringComparison.OrdinalIgnoreCase) != true;
}
public sealed record MeshDraw(uint FirstIndex,uint IndexCount,int TextureId)
{
+2 -1
View File
@@ -6,7 +6,8 @@ namespace GamePort.Assets;
public sealed record SavedTask(string Name, int State);
/// <summary>Original TSK wire layout recovered at EXE0x45FEE0/0x4603F0; unknown fields retained.</summary>
/// <summary>Original TSK wire layout at EXE0x45FEE0/0x4603F0; unknown fields retained.
/// StoredVector is the transition departure root, not Jimmy42AF00's separate checkpoint.</summary>
public sealed record OriginalSave(string LevelCode, float PlayerValue, short Counter,
int Score, int OtherCounter, int[] ItemStates, int[] LevelCounters,
string StartPoint, string ReservedName, string ReturnLevel, string ReturnStart,