| | | 1 | | //======================================================================= |
| | | 2 | | // StaticSurface.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2026-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | using FixedMathSharp; |
| | | 10 | | using FixedMathSharp.Geometry; |
| | | 11 | | using Gravitas.Colliders; |
| | | 12 | | using Gravitas.CollisionHandling; |
| | | 13 | | using SwiftCollections; |
| | | 14 | | using SwiftCollections.Query; |
| | | 15 | | |
| | | 16 | | namespace Gravitas; |
| | | 17 | | |
| | | 18 | | /// <summary>Declares continuity between registered static meshes using triangle-surface collision in one context.</summ |
| | | 19 | | /// <remarks> |
| | | 20 | | /// Exact shared boundary spans participate in one physical surface while members |
| | | 21 | | /// retain their collider identities, materials, queries and overlap events. |
| | | 22 | | /// Members require <see cref="MeshColliderMode.Concave"/>; their geometry may be |
| | | 23 | | /// convex or closed, but a closed shell is not treated as a filled convex volume. |
| | | 24 | | /// Create declarations through <see cref="GravitasPhysicsService.CreateStaticSurface"/>. |
| | | 25 | | /// Context reset or disposal ends the declaration's lifetime. |
| | | 26 | | /// </remarks> |
| | | 27 | | /// <content>Owns declared member lifetime and cached finite response families.</content> |
| | | 28 | | public sealed partial class StaticSurface : IDisposable, Chronicler.IRecordable |
| | | 29 | | { |
| | | 30 | | private readonly GravitasWorldContext _context; |
| | 493 | 31 | | private LSMeshCollider[] _members = Array.Empty<LSMeshCollider>(); |
| | 493 | 32 | | private PhysicsMesh[] _meshes = Array.Empty<PhysicsMesh>(); |
| | 493 | 33 | | private FixedBoundBox[] _memberBounds = Array.Empty<FixedBoundBox>(); |
| | 493 | 34 | | private readonly SwiftHashSet<int> _changedSuppliers = new(); |
| | 493 | 35 | | private readonly SwiftHashSet<PhysicsMesh> _dirtyMeshes = new(); |
| | 493 | 36 | | private readonly SwiftDictionary<(PhysicsMesh, int), MeshSurfaceBoundaryDomain> _boundaries = new(); |
| | 986 | 37 | | private readonly SwiftList<int> _candidates = new(), _triangles = new(); |
| | 493 | 38 | | private readonly SwiftList<(LSMeshCollider Collider, int Triangle)> _surfaces = new(); |
| | 493 | 39 | | private readonly SwiftHashSet<(PhysicsMesh, int)> _owners = new(); |
| | 493 | 40 | | private readonly SwiftList<(PhysicsMesh, int)> _cachedOwners = new(); |
| | | 41 | | private Vector3d _center; |
| | | 42 | | private FixedQuaternion _rotation; |
| | | 43 | | private Fixed64 _coreLength, _radius; |
| | | 44 | | private enum ContactFamily { Rounded, Cone, Slab, Hull } |
| | | 45 | | private ContactFamily _cachedFamily; |
| | | 46 | | private bool _facesCurrent; |
| | | 47 | | private Vector2d _halfFootprint; |
| | | 48 | | private MeshSlabFaceRegions? _slabFaces; |
| | | 49 | | private MeshHullSurfaceContacts? _hullContacts; |
| | | 50 | | private PhysicsMesh? _movingMesh; |
| | | 51 | | private uint _movingVersion; |
| | | 52 | | private bool _dirty, _disposed; |
| | 493 | 53 | | internal readonly MeshCapsuleFaceRegions Faces = new(); |
| | 493 | 54 | | internal readonly MeshConeFaceRegions ConeFaces = new(); |
| | 18862 | 55 | | internal MeshSlabFaceRegions SlabFaces => _slabFaces ??= new(); |
| | 10618 | 56 | | internal MeshHullSurfaceContacts HullContacts => _hullContacts ??= new(); |
| | 4126 | 57 | | internal int ReplayMembership => _members.Length == 0 ? 0 : _members[0].ReplayOrdinal + 1; |
| | | 58 | | |
| | 493 | 59 | | internal StaticSurface(GravitasWorldContext context, ReadOnlySpan<LSMeshCollider> members) |
| | | 60 | | { |
| | 493 | 61 | | _context = context; |
| | 493 | 62 | | ReplaceMembers(members); |
| | 490 | 63 | | } |
| | | 64 | | |
| | | 65 | | /// <summary>Atomically replaces the registered members of this declaration.</summary> |
| | | 66 | | /// <param name="members">Distinct active meshes in <see cref="MeshColliderMode.Concave"/> with bodyless or explicit |
| | | 67 | | /// <remarks> |
| | | 68 | | /// Call between complete fixed steps. Rejection preserves the previous membership. |
| | | 69 | | /// Membership permits exact joining; disconnected pieces retain their boundaries. |
| | | 70 | | /// Deactivated members must be explicitly added again after reinitialization. |
| | | 71 | | /// </remarks> |
| | | 72 | | /// <exception cref="ArgumentException">A member is ineligible or belongs to another declaration.</exception> |
| | | 73 | | /// <exception cref="ObjectDisposedException">This declaration or its context has ended.</exception> |
| | | 74 | | /// <exception cref="InvalidOperationException">A fixed step is in progress.</exception> |
| | | 75 | | public void ReplaceMembers(ReadOnlySpan<LSMeshCollider> members) |
| | | 76 | | { |
| | 565 | 77 | | _context.ThrowIfDisposed(); |
| | 564 | 78 | | _context.ThrowIfFixedStepMutationNotAllowed(); |
| | 565 | 79 | | if (_disposed) throw new ObjectDisposedException(nameof(StaticSurface)); |
| | 561 | 80 | | var next = members.ToArray(); |
| | 561 | 81 | | var meshes = new PhysicsMesh[next.Length]; |
| | 561 | 82 | | var unique = new SwiftHashSet<LSMeshCollider>(); |
| | 3362 | 83 | | for (int index = 0; index < next.Length; index++) |
| | | 84 | | { |
| | 1135 | 85 | | LSMeshCollider member = next[index]; |
| | | 86 | | // Registry identity verifies context and rejects stale or recycled IDs. |
| | 1135 | 87 | | if (member == null || !unique.Add(member) |
| | 1135 | 88 | | || !_context.Physics.TryGetColliderById(member.Id, out var registered) || registered != member |
| | 1135 | 89 | | || !member.IsStatic || !member.IsActive || member.IsDeactivationInProgress |
| | 1135 | 90 | | || member.Mode != MeshColliderMode.Concave |
| | 1135 | 91 | | || member.StaticSurface != null && member.StaticSurface != this) |
| | 15 | 92 | | throw new ArgumentException("Members must be distinct registered static concave meshes in this context." |
| | | 93 | | } |
| | 546 | 94 | | bool unchanged = next.Length == _members.Length; |
| | 1419 | 95 | | foreach (LSMeshCollider member in _members) unchanged &= unique.Contains(member); |
| | 590 | 96 | | if (unchanged) return; |
| | | 97 | | // Logical live registration order survives recycled registry-slot layouts. |
| | 502 | 98 | | Array.Sort(next, static (first, second) => ((IPhysicsColliderRegistryItem)first).ReplayOrder |
| | 502 | 99 | | .CompareTo(((IPhysicsColliderRegistryItem)second).ReplayOrder)); |
| | 4118 | 100 | | for (int index = 0; index < next.Length; index++) meshes[index] = next[index].Mesh; |
| | | 101 | | // Prepare before publishing associations so failed admission leaves the old declaration usable. |
| | 502 | 102 | | var prepared = PrepareBoundaries(meshes); |
| | 502 | 103 | | var bounds = new FixedBoundBox[next.Length]; |
| | 4118 | 104 | | for (int index = 0; index < next.Length; index++) bounds[index] = next[index].Bounds; |
| | 502 | 105 | | LSMeshCollider[] previousMembers = _members; |
| | 1076 | 106 | | foreach (LSMeshCollider previous in previousMembers) |
| | 60 | 107 | | if (!unique.Contains(previous)) Invalidate(changed: previous); |
| | 1112 | 108 | | foreach (LSMeshCollider previous in previousMembers) previous.StaticSurface = null; |
| | 1506 | 109 | | _members = next; _meshes = meshes; _memberBounds = bounds; |
| | 502 | 110 | | _dirtyMeshes.Clear(); |
| | 4518 | 111 | | _continuousBoundaries.Clear(); Faces.ReleaseJoined(); ConeFaces.ReleaseJoined(); _slabFaces?.ReleaseJoined(); _h |
| | 502 | 112 | | _boundaries.Clear(); |
| | 4226 | 113 | | foreach (var entry in prepared) _boundaries.Add(entry.Key, entry.Value); |
| | 4118 | 114 | | foreach (LSMeshCollider member in _members) member.StaticSurface = this; |
| | 3080 | 115 | | foreach (LSMeshCollider member in _members) |
| | 2064 | 116 | | if (Array.IndexOf(previousMembers, member) < 0) Invalidate(changed: member); |
| | 502 | 117 | | _dirty = false; |
| | 502 | 118 | | } |
| | | 119 | | |
| | | 120 | | private static SwiftDictionary<(PhysicsMesh, int), MeshSurfaceBoundaryDomain> PrepareBoundaries(PhysicsMesh[] meshes |
| | | 121 | | { |
| | 502 | 122 | | var result = new SwiftDictionary<(PhysicsMesh, int), MeshSurfaceBoundaryDomain>(); |
| | 3080 | 123 | | for (int member = 0; member < meshes.Length; member++) |
| | | 124 | | { |
| | 1038 | 125 | | PhysicsMesh mesh = meshes[member]; |
| | 8542 | 126 | | for (int triangle = 0; triangle < mesh.TriangleCount; triangle++) |
| | | 127 | | { |
| | 3233 | 128 | | int owner = mesh.GetManifoldSurfaceOwner(triangle); |
| | 3233 | 129 | | if (result.ContainsKey((mesh, owner))) continue; |
| | 1074 | 130 | | var domain = new MeshSurfaceBoundaryDomain(); |
| | 1074 | 131 | | domain.Build(meshes, member, triangle); |
| | 1074 | 132 | | result.Add((mesh, owner), domain); |
| | | 133 | | } |
| | | 134 | | } |
| | 502 | 135 | | return result; |
| | | 136 | | } |
| | | 137 | | |
| | | 138 | | internal void Invalidate(bool geometryChanged = false, LSMeshCollider? changed = null, bool includeNeighbors = true) |
| | | 139 | | { |
| | 1579 | 140 | | _dirty |= geometryChanged; |
| | 1579 | 141 | | _facesCurrent = false; |
| | 1579 | 142 | | _mixedSlab = false; |
| | 1579 | 143 | | _changedSuppliers.Clear(); |
| | 3158 | 144 | | FixedBoundBox before = default, after = default; |
| | 1579 | 145 | | if (changed != null) |
| | | 146 | | { |
| | 1089 | 147 | | int index = Array.IndexOf(_members, changed); |
| | 2178 | 148 | | before = _memberBounds[index]; after = changed.Bounds; |
| | 1089 | 149 | | _memberBounds[index] = after; |
| | | 150 | | } |
| | 11326 | 151 | | for (int index = 0; index < _members.Length; index++) |
| | 4084 | 152 | | if (changed == null || _members[index] == changed || includeNeighbors |
| | 4084 | 153 | | && (_memberBounds[index].Intersects(before) || _memberBounds[index].Intersects(after))) |
| | | 154 | | { |
| | 3197 | 155 | | _changedSuppliers.Add(_members[index].Id + 1); |
| | 3197 | 156 | | _members[index].MarkContactDependencyChanged(notifySurface: false); |
| | 3228 | 157 | | if (geometryChanged) _dirtyMeshes.Add(_meshes[index]); |
| | | 158 | | } |
| | | 159 | | // Borrowed rows can live on a carrier without an overlap pair for the |
| | | 160 | | // edited supplier. Scan existing references only when a member changes. |
| | 11326 | 161 | | foreach (LSMeshCollider member in _members) |
| | 4084 | 162 | | _context.Physics.ClearWarmStartCachesForCollider(member, _changedSuppliers); |
| | 1579 | 163 | | _context.MixedCollisions.InvalidateSurfaceContacts(this, null, _changedSuppliers); |
| | 1579 | 164 | | _changedSuppliers.Clear(); |
| | 1579 | 165 | | } |
| | | 166 | | |
| | | 167 | | internal void Remove(LSMeshCollider member) |
| | | 168 | | { |
| | 11 | 169 | | int index = Array.IndexOf(_members, member); |
| | 12 | 170 | | if (index < 0) return; |
| | 10 | 171 | | Invalidate(geometryChanged: true, changed: member); |
| | 10 | 172 | | member.StaticSurface = null; |
| | 100 | 173 | | _continuousBoundaries.Clear(); Faces.ReleaseJoined(); ConeFaces.ReleaseJoined(); _slabFaces?.ReleaseJoined(); _h |
| | 10 | 174 | | Array.Copy(_members, index + 1, _members, index, _members.Length - index - 1); |
| | 10 | 175 | | Array.Copy(_memberBounds, index + 1, _memberBounds, index, _memberBounds.Length - index - 1); |
| | 10 | 176 | | Array.Resize(ref _members, _members.Length - 1); |
| | 10 | 177 | | Array.Resize(ref _memberBounds, _members.Length); |
| | 10 | 178 | | _meshes = new PhysicsMesh[_members.Length]; |
| | 47 | 179 | | for (int i = 0; i < _members.Length; i++) _meshes[i] = _members[i].Mesh; |
| | 10 | 180 | | _dirtyMeshes.Clear(); |
| | 47 | 181 | | foreach (PhysicsMesh mesh in _meshes) _dirtyMeshes.Add(mesh); |
| | 10 | 182 | | } |
| | | 183 | | |
| | 49205 | 184 | | internal int Gather(LSCollider mover, FixedBoundVolume bounds) => Gather(mover, null, bounds); |
| | | 185 | | |
| | | 186 | | private int Gather(LSCollider? mover, LSCollider2D? embedded, FixedBoundVolume bounds) |
| | | 187 | | { |
| | 52669 | 188 | | if (_dirty) |
| | | 189 | | { |
| | 54 | 190 | | for (int member = 0; member < _meshes.Length; member++) |
| | | 191 | | { |
| | 17 | 192 | | PhysicsMesh mesh = _meshes[member]; |
| | 17 | 193 | | if (!_dirtyMeshes.Contains(mesh)) continue; |
| | 84 | 194 | | for (int triangle = 0; triangle < mesh.TriangleCount; triangle++) |
| | | 195 | | { |
| | 28 | 196 | | int owner = mesh.GetManifoldSurfaceOwner(triangle); |
| | 28 | 197 | | if (owner != triangle) continue; |
| | 14 | 198 | | if (!_boundaries.TryGetValue((mesh, owner), out MeshSurfaceBoundaryDomain domain)) |
| | 7 | 199 | | _boundaries.Add((mesh, owner), domain = new()); |
| | 14 | 200 | | domain.Build(_meshes, member, triangle); |
| | | 201 | | } |
| | | 202 | | } |
| | 10 | 203 | | _dirtyMeshes.Clear(); |
| | 10 | 204 | | _dirty = false; |
| | | 205 | | } |
| | 105338 | 206 | | _surfaces.Clear(); _owners.Clear(); |
| | 52669 | 207 | | LSCollider? participant = mover?.CompoundOwner ?? mover; |
| | 52669 | 208 | | LSCollider2D? planar = embedded?.CompoundOwner ?? embedded; |
| | | 209 | | // Reuse the committed index; Y rejection keeps its planar candidates conservative in 3D. |
| | 52669 | 210 | | _context.Collisions.QueryPlanarColliderCandidates(new(bounds.Min.X, bounds.Min.Z, bounds.Max.X, bounds.Max.Z), _ |
| | 377952 | 211 | | foreach (int id in _candidates.AsReadOnlySpan()) |
| | | 212 | | { |
| | 136307 | 213 | | _context.Physics.TryGetColliderById(id, out var candidate); |
| | 136307 | 214 | | if (candidate is not LSMeshCollider mesh |
| | 136307 | 215 | | || mesh.StaticSurface != this || mesh.IsTrigger |
| | 136307 | 216 | | || (participant != null ? !_context.Physics.RequireCollisionPair(mesh, participant) |
| | 136307 | 217 | | : !_context.MixedCollisions.RequireCollisionPair(mesh, planar!)) |
| | 136307 | 218 | | || mesh.BoundsMax.Y < bounds.Min.Y || mesh.BoundsMin.Y > bounds.Max.Y) continue; |
| | 86638 | 219 | | mesh.GetTrianglesInBounds(bounds, _triangles); |
| | 599440 | 220 | | foreach (int triangle in _triangles.AsReadOnlySpan()) |
| | 299772 | 221 | | if (_owners.Add((mesh.Mesh, mesh.Mesh.GetManifoldSurfaceOwner(triangle)))) _surfaces.Add((mesh, triangle |
| | | 222 | | } |
| | 52669 | 223 | | return _surfaces.Count; |
| | | 224 | | } |
| | | 225 | | |
| | | 226 | | internal int GatherProjectedSupport(LSCollider mover) |
| | | 227 | | { |
| | | 228 | | // A support projected onto an intersecting plane is within sqrt(2) R |
| | | 229 | | // of the shape center. 2 R conservatively includes its finite supplier, |
| | | 230 | | // even when that piece has no initial overlap or broad-phase pair. |
| | 13065 | 231 | | Fixed64 reach = mover.CanonicalCenteredProxyRadius * Fixed64.Two; |
| | 13065 | 232 | | FixedBoundBox bounds = FixedBoundBox.FromCenterAndScopeClippedToDomain(mover.Center, Vector3d.One * reach); |
| | 13065 | 233 | | return Gather(mover, new(bounds.Min, bounds.Max)); |
| | | 234 | | } |
| | | 235 | | |
| | | 236 | | internal void BuildHull(LSMeshCollider mover) |
| | | 237 | | { |
| | 5955 | 238 | | bool reuse = _facesCurrent && _cachedFamily == ContactFamily.Hull && _movingMesh == mover.Mesh |
| | 5955 | 239 | | && _movingVersion == mover.RuntimeShapeVersion && _center == mover.Center && _rotation == mover.Rotation |
| | 5955 | 240 | | && _cachedOwners.Count == _owners.Count; |
| | 44334 | 241 | | foreach (var owner in _cachedOwners.AsReadOnlySpan()) reuse &= _owners.Contains(owner); |
| | 7247 | 242 | | if (reuse) return; |
| | 9326 | 243 | | _facesCurrent = false; _cachedFamily = ContactFamily.Hull; |
| | 4663 | 244 | | HullContacts.Build(_surfaces.AsReadOnlySpan(), mover, _meshes, _boundaries); |
| | 4663 | 245 | | _cachedOwners.Clear(); |
| | 26270 | 246 | | foreach (var surface in _surfaces.AsReadOnlySpan()) |
| | 8472 | 247 | | _cachedOwners.Add((surface.Collider.Mesh, surface.Collider.Mesh.GetManifoldSurfaceOwner(surface.Triangle))); |
| | 9326 | 248 | | _movingMesh = mover.Mesh; _movingVersion = mover.RuntimeShapeVersion; |
| | 13989 | 249 | | _center = mover.Center; _rotation = mover.Rotation; _facesCurrent = true; |
| | 4663 | 250 | | } |
| | | 251 | | |
| | | 252 | | internal void BuildRounded(Vector3d center, FixedQuaternion rotation, Fixed64 coreLength, Fixed64 radius) |
| | | 253 | | { |
| | | 254 | | // Gather rechecks live eligibility. Reuse requires the complete owner set, not a hash of it. |
| | 13192 | 255 | | bool reuse = _facesCurrent && _cachedFamily == ContactFamily.Rounded && _center == center && _rotation == rotati |
| | 13192 | 256 | | && _radius == radius && _cachedOwners.Count == _owners.Count; |
| | 106601 | 257 | | foreach (var owner in _cachedOwners.AsReadOnlySpan()) reuse &= _owners.Contains(owner); |
| | 20205 | 258 | | if (reuse) return; |
| | 12358 | 259 | | _facesCurrent = false; _cachedFamily = ContactFamily.Rounded; |
| | 6179 | 260 | | Faces.BuildJoined(_surfaces.AsReadOnlySpan(), center, rotation, coreLength, radius, _meshes, _boundaries); |
| | 6179 | 261 | | _cachedOwners.Clear(); |
| | 37416 | 262 | | foreach (var surface in _surfaces.AsReadOnlySpan()) |
| | 12529 | 263 | | _cachedOwners.Add((surface.Collider.Mesh, surface.Collider.Mesh.GetManifoldSurfaceOwner(surface.Triangle))); |
| | 24716 | 264 | | _center = center; _rotation = rotation; _coreLength = coreLength; _radius = radius; |
| | 6179 | 265 | | _facesCurrent = true; |
| | 6179 | 266 | | } |
| | | 267 | | |
| | | 268 | | internal void BuildCone(LSConeCollider cone) |
| | | 269 | | { |
| | 6381 | 270 | | bool reuse = _facesCurrent && _cachedFamily == ContactFamily.Cone && _center == cone.Center && _rotation == cone |
| | 6381 | 271 | | && _coreLength == cone.Height && _radius == cone.ScaledRadius && _cachedOwners.Count == _owners.Count; |
| | 51501 | 272 | | foreach (var owner in _cachedOwners.AsReadOnlySpan()) reuse &= _owners.Contains(owner); |
| | 9722 | 273 | | if (reuse) return; |
| | 6080 | 274 | | _facesCurrent = false; _cachedFamily = ContactFamily.Cone; |
| | 3040 | 275 | | ConeFaces.BuildJoined(_surfaces.AsReadOnlySpan(), cone, _meshes, _boundaries); |
| | 3040 | 276 | | _cachedOwners.Clear(); |
| | 18410 | 277 | | foreach (var surface in _surfaces.AsReadOnlySpan()) |
| | 6165 | 278 | | _cachedOwners.Add((surface.Collider.Mesh, surface.Collider.Mesh.GetManifoldSurfaceOwner(surface.Triangle))); |
| | 12160 | 279 | | _center = cone.Center; _rotation = cone.Rotation; _coreLength = cone.Height; _radius = cone.ScaledRadius; |
| | 3040 | 280 | | _facesCurrent = true; |
| | 3040 | 281 | | } |
| | | 282 | | |
| | | 283 | | internal void BuildSlab(LSCollider mover, Fixed64 radius, Fixed64 halfThickness, Vector2d halfFootprint) |
| | | 284 | | { |
| | 7110 | 285 | | bool reuse = _facesCurrent && _cachedFamily == ContactFamily.Slab && !_mixedSlab && _center == mover.Center && _ |
| | 7110 | 286 | | && _coreLength == halfThickness && _radius == radius && _halfFootprint == halfFootprint && _cachedOwners.Cou |
| | 53685 | 287 | | foreach (var owner in _cachedOwners.AsReadOnlySpan()) reuse &= _owners.Contains(owner); |
| | 8703 | 288 | | if (reuse) return; |
| | 11034 | 289 | | _facesCurrent = false; _cachedFamily = ContactFamily.Slab; |
| | 5517 | 290 | | _mixedSlab = false; |
| | 5517 | 291 | | SlabFaces.BuildJoined(_surfaces.AsReadOnlySpan(), mover, radius, halfThickness, halfFootprint, _meshes, _boundar |
| | 5517 | 292 | | _cachedOwners.Clear(); |
| | 31370 | 293 | | foreach (var surface in _surfaces.AsReadOnlySpan()) |
| | 10168 | 294 | | _cachedOwners.Add((surface.Collider.Mesh, surface.Collider.Mesh.GetManifoldSurfaceOwner(surface.Triangle))); |
| | 27585 | 295 | | _center = mover.Center; _rotation = mover.Rotation; _coreLength = halfThickness; _radius = radius; _halfFootprin |
| | 5517 | 296 | | _facesCurrent = true; |
| | 5517 | 297 | | } |
| | | 298 | | |
| | | 299 | | /// <summary>Ends this declaration and restores independent member response.</summary> |
| | | 300 | | /// <remarks>Call between complete fixed steps. Members remain registered. Repeated disposal is harmless.</remarks> |
| | | 301 | | /// <exception cref="InvalidOperationException">A fixed step is in progress.</exception> |
| | | 302 | | public void Dispose() |
| | | 303 | | { |
| | 636 | 304 | | if (_disposed) return; |
| | 484 | 305 | | _context.ThrowIfFixedStepMutationNotAllowed(); |
| | 483 | 306 | | Release(); |
| | 483 | 307 | | _context.Physics.RemoveStaticSurface(this); |
| | 483 | 308 | | } |
| | | 309 | | |
| | | 310 | | internal void Release() |
| | | 311 | | { |
| | 490 | 312 | | Invalidate(); |
| | 3956 | 313 | | foreach (LSMeshCollider member in _members) member.StaticSurface = null; |
| | 980 | 314 | | _members = Array.Empty<LSMeshCollider>(); _meshes = Array.Empty<PhysicsMesh>(); |
| | 980 | 315 | | _memberBounds = Array.Empty<FixedBoundBox>(); _dirtyMeshes.Clear(); |
| | 1960 | 316 | | _boundaries.Clear(); _surfaces.Clear(); _cachedOwners.Clear(); _owners.Clear(); |
| | 3430 | 317 | | _continuousBoundaries.Clear(); Faces.ReleaseJoined(); ConeFaces.ReleaseJoined(); _slabFaces?.ReleaseJoined(); _h |
| | 490 | 318 | | } |
| | | 319 | | } |