diff --git a/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs b/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs index 7945f5d..4472491 100644 --- a/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs +++ b/src/DotRecast.Recast.Demo/Geom/DemoInputGeomProvider.cs @@ -36,7 +36,7 @@ public class DemoInputGeomProvider : InputGeomProvider private readonly Vector3f bmax; private readonly List _convexVolumes = new(); private readonly List offMeshConnections = new(); - private readonly ChunkyTriMesh chunkyTriMesh; + private readonly TriMesh _mesh; public DemoInputGeomProvider(List vertexPositions, List meshFaces) : this(mapVertices(vertexPositions), mapFaces(meshFaces)) @@ -81,7 +81,7 @@ public class DemoInputGeomProvider : InputGeomProvider RecastVectors.max(ref bmax, vertices, i * 3); } - chunkyTriMesh = new ChunkyTriMesh(vertices, faces, faces.Length / 3, 256); + _mesh = new TriMesh(vertices, faces); } public Vector3f getMeshBoundsMin() @@ -130,7 +130,7 @@ public class DemoInputGeomProvider : InputGeomProvider public IEnumerable meshes() { - return ImmutableArray.Create(new TriMesh(vertices, faces)); + return ImmutableArray.Create(_mesh); } public List getOffMeshConnections() @@ -166,7 +166,7 @@ public class DemoInputGeomProvider : InputGeomProvider q[0] = src[0] + (dst[0] - src[0]) * btmax; q[1] = src[2] + (dst[2] - src[2]) * btmax; - List chunks = chunkyTriMesh.getChunksOverlappingSegment(p, q); + List chunks = _mesh.chunkyTriMesh.getChunksOverlappingSegment(p, q); if (0 == chunks.Count) { return null; diff --git a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs index cb3cea8..d67cfa9 100644 --- a/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SimpleInputGeomProvider.cs @@ -32,7 +32,8 @@ namespace DotRecast.Recast.Geom public readonly float[] normals; private Vector3f bmin; private Vector3f bmax; - readonly List volumes = new List(); + private readonly List volumes = new List(); + private readonly TriMesh _mesh; public SimpleInputGeomProvider(List vertexPositions, List meshFaces) : this(mapVertices(vertexPositions), mapFaces(meshFaces)) @@ -76,6 +77,8 @@ namespace DotRecast.Recast.Geom RecastVectors.min(ref bmin, vertices, i * 3); RecastVectors.max(ref bmax, vertices, i * 3); } + + _mesh = new TriMesh(vertices, faces); } public Vector3f getMeshBoundsMin() @@ -105,7 +108,7 @@ namespace DotRecast.Recast.Geom public IEnumerable meshes() { - return ImmutableArray.Create(new TriMesh(vertices, faces)); + return ImmutableArray.Create(_mesh); } public void calculateNormals() diff --git a/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs b/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs index 1cf2986..347f9a3 100644 --- a/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs +++ b/src/DotRecast.Recast/Geom/SingleTrimeshInputGeomProvider.cs @@ -27,7 +27,7 @@ namespace DotRecast.Recast.Geom { private readonly Vector3f bmin; private readonly Vector3f bmax; - private readonly TriMesh[] _meshes; + private readonly TriMesh _mesh; public SingleTrimeshInputGeomProvider(float[] vertices, int[] faces) { @@ -41,7 +41,7 @@ namespace DotRecast.Recast.Geom RecastVectors.max(ref bmax, vertices, i * 3); } - _meshes = new[] { new TriMesh(vertices, faces) }; + _mesh = new TriMesh(vertices, faces); } public Vector3f getMeshBoundsMin() @@ -56,7 +56,7 @@ namespace DotRecast.Recast.Geom public IEnumerable meshes() { - return _meshes; + return ImmutableArray.Create(_mesh); } public IList convexVolumes() diff --git a/src/DotRecast.Recast/Geom/TriMesh.cs b/src/DotRecast.Recast/Geom/TriMesh.cs index a6a98ab..0a854e4 100644 --- a/src/DotRecast.Recast/Geom/TriMesh.cs +++ b/src/DotRecast.Recast/Geom/TriMesh.cs @@ -26,7 +26,7 @@ namespace DotRecast.Recast.Geom { private readonly float[] vertices; private readonly int[] faces; - private readonly ChunkyTriMesh chunkyTriMesh; + public readonly ChunkyTriMesh chunkyTriMesh; public TriMesh(float[] vertices, int[] faces) {