Restore tutorial return placement and source terrain collision eligibility
This commit is contained in:
1 parent
ca08c468ba
commit
8d60a68511
36 files changed
+991
-69
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user